⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 bobberarchetypexpp3reader.java

📁 提供ESB 应用mule源代码 提供ESB 应用mule源代码
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
/* * $Id$ */package com.javaforge.bobber.archetype.model.io.xpp3;  //---------------------------------/ //- Imported classes and packages -///---------------------------------/import com.javaforge.bobber.archetype.model.BobberArchetype;import com.javaforge.bobber.archetype.model.Template;import com.javaforge.bobber.archetype.model.Variable;import java.io.IOException;import java.io.InputStream;import java.io.Reader;import java.text.DateFormat;import java.util.Locale;import org.codehaus.plexus.util.ReaderFactory;import org.codehaus.plexus.util.xml.pull.MXParser;import org.codehaus.plexus.util.xml.pull.XmlPullParser;import org.codehaus.plexus.util.xml.pull.XmlPullParserException;/** * Class BobberArchetypeXpp3Reader. *  * @version $Revision$ $Date$ */public class BobberArchetypeXpp3Reader {      //--------------------------/     //- Class/Member Variables -/    //--------------------------/    /**     * If set the parser will be loaded with all single characters     * from the XHTML specification.     * The entities used:     * <ul>     * <li>http://www.w3.org/TR/xhtml1/DTD/xhtml-lat1.ent</li>     * <li>http://www.w3.org/TR/xhtml1/DTD/xhtml-special.ent</li>     * <li>http://www.w3.org/TR/xhtml1/DTD/xhtml-symbol.ent</li>     * </ul>     */    private boolean addDefaultEntities = true;      //-----------/     //- Methods -/    //-----------/    /**     * Returns the state of the "add default entities" flag.     *      * @return boolean     */    public boolean getAddDefaultEntities()    {        return addDefaultEntities;    } //-- boolean getAddDefaultEntities()     /**     * Method getBooleanValue.     *      * @param s     * @param parser     * @param attribute     * @throws XmlPullParserException     * @return boolean     */    public boolean getBooleanValue(String s, String attribute, XmlPullParser parser)        throws XmlPullParserException    {        return getBooleanValue( s, attribute, parser, null );    } //-- boolean getBooleanValue(String, String, XmlPullParser)     /**     * Method getBooleanValue.     *      * @param s     * @param defaultValue     * @param parser     * @param attribute     * @throws XmlPullParserException     * @return boolean     */    public boolean getBooleanValue(String s, String attribute, XmlPullParser parser, String defaultValue)        throws XmlPullParserException    {        if ( s != null && s.length() != 0 )        {            return Boolean.valueOf( s ).booleanValue();        }        if ( defaultValue != null )        {            return Boolean.valueOf( defaultValue ).booleanValue();        }        return false;    } //-- boolean getBooleanValue(String, String, XmlPullParser, String)     /**     * Method getCharacterValue.     *      * @param s     * @param parser     * @param attribute     * @throws XmlPullParserException     * @return char     */    public char getCharacterValue(String s, String attribute, XmlPullParser parser)        throws XmlPullParserException    {        if ( s != null )        {            return s.charAt( 0 );        }        return 0;    } //-- char getCharacterValue(String, String, XmlPullParser)     /**     * Method getDateValue.     *      * @param s     * @param parser     * @param attribute     * @throws XmlPullParserException     * @return java.util.Date     */    public java.util.Date getDateValue(String s, String attribute, XmlPullParser parser)        throws XmlPullParserException    {        return getDateValue( s, attribute, null, parser );    } //-- java.util.Date getDateValue(String, String, XmlPullParser)     /**     * Method getDateValue.     *      * @param s     * @param parser     * @param dateFormat     * @param attribute     * @throws XmlPullParserException     * @return java.util.Date     */    public java.util.Date getDateValue(String s, String attribute, String dateFormat, XmlPullParser parser)        throws XmlPullParserException    {        if ( s != null )        {            if ( dateFormat == null )            {                return new java.util.Date( Long.valueOf( s ).longValue() );            }            else            {                DateFormat dateParser = new java.text.SimpleDateFormat( dateFormat, Locale.US );                try                {                    return dateParser.parse( s );                }                catch ( java.text.ParseException e )                {                    throw new XmlPullParserException( e.getMessage() );                }            }        }        return null;    } //-- java.util.Date getDateValue(String, String, String, XmlPullParser)     /**     * Method getDoubleValue.     *      * @param s     * @param strict     * @param parser     * @param attribute     * @throws XmlPullParserException     * @return double     */    public double getDoubleValue(String s, String attribute, XmlPullParser parser, boolean strict)        throws XmlPullParserException    {        if ( s != null )        {            try            {                return Double.valueOf( s ).doubleValue();            }            catch ( NumberFormatException e )            {                if ( strict )                {                    throw new XmlPullParserException( "Unable to parse element '" + attribute + "', must be a floating point number", parser, null );                }            }        }        return 0;    } //-- double getDoubleValue(String, String, XmlPullParser, boolean)     /**     * Method getFloatValue.     *      * @param s     * @param strict     * @param parser     * @param attribute     * @throws XmlPullParserException     * @return float     */    public float getFloatValue(String s, String attribute, XmlPullParser parser, boolean strict)        throws XmlPullParserException    {        if ( s != null )        {            try            {                return Float.valueOf( s ).floatValue();            }            catch ( NumberFormatException e )            {                if ( strict )                {                    throw new XmlPullParserException( "Unable to parse element '" + attribute + "', must be a floating point number", parser, null );                }            }        }        return 0;    } //-- float getFloatValue(String, String, XmlPullParser, boolean)     /**     * Method getIntegerValue.     *      * @param s     * @param strict     * @param parser     * @param attribute     * @throws XmlPullParserException     * @return int     */    public int getIntegerValue(String s, String attribute, XmlPullParser parser, boolean strict)        throws XmlPullParserException    {        if ( s != null )        {            try            {                return Integer.valueOf( s ).intValue();            }            catch ( NumberFormatException e )            {                if ( strict )                {                    throw new XmlPullParserException( "Unable to parse element '" + attribute + "', must be an integer", parser, null );                }            }        }        return 0;    } //-- int getIntegerValue(String, String, XmlPullParser, boolean)     /**     * Method getLongValue.     *      * @param s     * @param strict     * @param parser     * @param attribute     * @throws XmlPullParserException     * @return long     */    public long getLongValue(String s, String attribute, XmlPullParser parser, boolean strict)        throws XmlPullParserException    {        if ( s != null )        {            try            {                return Long.valueOf( s ).longValue();            }            catch ( NumberFormatException e )            {                if ( strict )                {                    throw new XmlPullParserException( "Unable to parse element '" + attribute + "', must be a long integer", parser, null );                }            }        }        return 0;    } //-- long getLongValue(String, String, XmlPullParser, boolean)     /**     * Method getRequiredAttributeValue.     *      * @param s     * @param strict     * @param parser     * @param attribute     * @throws XmlPullParserException     * @return String     */    public String getRequiredAttributeValue(String s, String attribute, XmlPullParser parser, boolean strict)        throws XmlPullParserException    {        if ( s == null )        {            if ( strict )            {                throw new XmlPullParserException( "Missing required value for attribute '" + attribute + "'", parser, null );            }        }        return s;    } //-- String getRequiredAttributeValue(String, String, XmlPullParser, boolean)     /**     * Method getShortValue.     *      * @param s     * @param strict     * @param parser

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -