Example usage for java.lang Integer decode

List of usage examples for java.lang Integer decode

Introduction

In this page you can find the example usage for java.lang Integer decode.

Prototype

public static Integer decode(String nm) throws NumberFormatException 

Source Link

Document

Decodes a String into an Integer .

Usage

From source file:uni.bielefeld.cmg.sparkhit.hadoop.decodec.util.Parameter.java

public DefaultParam importCommandLine() {

    /* Assigning Parameter ID to an ascending number */
    putParameterID();//from  w  ww  .ja v a2s. c om

    /* Assigning parameter descriptions to each parameter ID */
    addParameterInfo();

    /* need a Object parser of PosixParser class for the function parse of CommandLine class */
    PosixParser parser = new PosixParser();

    /* print out help information */
    HelpParam help = new HelpParam(parameter, parameterMap);

    /* check each parameter for assignment */
    try {
        long input_limit = -1;
        int threads = Runtime.getRuntime().availableProcessors();

        /* Set Object cl of CommandLine class for Parameter storage */
        CommandLine cl = parser.parse(parameter, arguments, true);
        if (cl.hasOption(HELP)) {
            help.printHelp();
            System.exit(0);
        }

        if (cl.hasOption(HELP2)) {
            help.printHelp();
            System.exit(0);
        }

        if (cl.hasOption(VERSION)) {
            System.exit(0);
        }

        /* Checking all parameters */

        String value;

        if ((value = cl.getOptionValue(INPUT_BZ2)) != null) {
            param.inputFqPath = value;
            param.bz2 = true;
        }

        /* not applicable for HDFS and S3 */
        /* using TextFileBufferInput for such purpose */
        //         File inputFastq = new File(param.inputFqPath).getAbsoluteFile();
        //         if (!inputFastq.exists()){
        //            err.println("Input query file not found.");
        //            return;
        //i         }
        if ((value = cl.getOptionValue(INPUT_GZ)) != null) {
            param.inputFqPath = value;
            param.gz = true;
        } else if (cl.getOptionValue(INPUT_BZ2) == null) {
            help.printHelp();
            System.exit(0);
            //throw new IOException("Input query file not specified.\nUse -help for list of options");
        }

        if ((value = cl.getOptionValue(INPUT_SPLIT)) != null) {
            param.splitsize = Long.decode(value);
        }

        if ((value = cl.getOptionValue(OUTPUT_FILE)) != null) {
            param.outputPath = value;
        } else {
            info.readMessage("Output file not set of -outfile options");
            info.screenDump();
        }

        if (cl.hasOption(OUTPUT_OVERWRITE)) {
            param.overwrite = true;
        }

        if ((value = cl.getOptionValue(OUTPUT_FORMAT)) != null) {
            param.outputFormat = Integer.decode(value);
        }

        File outfile = new File(param.outputPath).getAbsoluteFile();
        if (outfile.exists()) {
            info.readParagraphedMessages(
                    "Output file : \n\t" + param.outputPath + "\nalready exists, will be overwrite.");
            info.screenDump();
            Runtime.getRuntime().exec("rm -rf " + param.outputPath);
        }

    } catch (IOException e) { // Don`t catch this, NaNaNaNa, U can`t touch this.
        info.readMessage("Parameter settings incorrect.");
        info.screenDump();
        e.printStackTrace();
        System.exit(0);
    } catch (RuntimeException e) {
        info.readMessage("Parameter settings incorrect.");
        info.screenDump();
        e.printStackTrace();
        System.exit(0);
    } catch (ParseException e) {
        info.readMessage("Parameter settings incorrect.");
        info.screenDump();
        e.printStackTrace();
        System.exit(0);
    }

    return param;
}

From source file:org.c99.SyncProviderDemo.ContactsSyncAdapterService.java

private static void updateContactStatus(ArrayList<ContentProviderOperation> operationList, long rawContactId,
        String status) {/* www.  jav a 2s  .c  om*/
    Uri rawContactUri = ContentUris.withAppendedId(RawContacts.CONTENT_URI, rawContactId);
    Uri entityUri = Uri.withAppendedPath(rawContactUri, Entity.CONTENT_DIRECTORY);
    Cursor c = mContentResolver.query(entityUri,
            new String[] { RawContacts.SOURCE_ID, Entity.DATA_ID, Entity.MIMETYPE, Entity.DATA1 }, null, null,
            null);
    try {
        while (c.moveToNext()) {
            if (!c.isNull(1)) {
                String mimeType = c.getString(2);

                if (mimeType.equals("vnd.android.cursor.item/vnd.org.c99.SyncProviderDemo.profile")) {
                    ContentProviderOperation.Builder builder = ContentProviderOperation
                            .newInsert(ContactsContract.StatusUpdates.CONTENT_URI);
                    builder.withValue(ContactsContract.StatusUpdates.DATA_ID, c.getLong(1));
                    builder.withValue(ContactsContract.StatusUpdates.STATUS, status);
                    builder.withValue(ContactsContract.StatusUpdates.STATUS_RES_PACKAGE,
                            "org.c99.SyncProviderDemo");
                    builder.withValue(ContactsContract.StatusUpdates.STATUS_LABEL, R.string.app_name);
                    builder.withValue(ContactsContract.StatusUpdates.STATUS_ICON, R.drawable.logo);
                    builder.withValue(ContactsContract.StatusUpdates.STATUS_TIMESTAMP,
                            System.currentTimeMillis());
                    operationList.add(builder.build());

                    //Only change the text of our custom entry to the status message pre-Honeycomb, as the newer contacts app shows
                    //statuses elsewhere
                    if (Integer.decode(Build.VERSION.SDK) < 11) {
                        builder = ContentProviderOperation.newUpdate(ContactsContract.Data.CONTENT_URI);
                        builder.withSelection(BaseColumns._ID + " = '" + c.getLong(1) + "'", null);
                        builder.withValue(ContactsContract.Data.DATA3, status);
                        operationList.add(builder.build());
                    }
                }
            }
        }
    } finally {
        c.close();
    }
}

From source file:ClientManager.java

private void getConfig() throws IOException, MalformedContentNameStringException {
    Properties confFile = new Properties();
    FileInputStream confStream = new FileInputStream("config.properties");
    confFile.load(confStream);/*from w  w w .ja  va  2 s  .  c  o  m*/

    dpid = Long.decode(confFile.getProperty("dpid"));
    ip = InetAddress.getByName(confFile.getProperty("ip"));

    out.println("Datapath ID dpid=" + Long.toHexString(dpid));
    controller = confFile.getProperty("server");
    controller_port = Integer.decode(confFile.getProperty("port", "6635"));
    out.println("Found server address: " + controller + ":" + controller_port);

    content = new HashMap<ContentName, ContentProps>();

    String entrypoint;
    for (int i = 0; (entrypoint = confFile.getProperty("entry." + i)) != null; i++) {
        int cost = Integer.parseInt(confFile.getProperty("entry." + i + ".cost", "0"));
        int priority = Integer.parseInt(confFile.getProperty("entry." + i + ".priority", "0"));

        content.put(ContentName.fromURI(entrypoint), new ContentProps(cost, priority));

        out.println("Found entrypoint  " + entrypoint + " @ cost=" + cost + " and priority=" + priority);
    }
}

From source file:com.github.jessemull.microflex.plate.Well.java

/**
 * Creates a new Well object using the numerical type flag, row and column 
 * strings./*from ww  w .j ava  2 s .c  o  m*/
 * @param    int       the numerical data type
 * @param    String    the well row
 * @param    String    the well column
 * @throws   IllegalArgumentException    invalid column value
 */
public Well(int type, String row, String column) {

    try {
        this.row = Integer.decode(row);
    } catch (NumberFormatException e) {
        this.row = parseRow(row);
    }

    try {
        this.column = Integer.decode(column);
    } catch (Exception e) {
        throw new IllegalArgumentException("Illegal column value: " + column);
    }

    this.type = type;
    validateIndices(this.row, this.column);
}

From source file:org.crazydog.util.spring.NumberUtils.java

/**
 * Parse the given text into a number instance of the given target class,
 * using the corresponding {@code decode} / {@code valueOf} methods.
 * <p>Trims the input {@code String} before attempting to parse the number.
 * Supports numbers in hex format (with leading "0x", "0X" or "#") as well.
 *
 * @param text        the text to convert
 * @param targetClass the target class to parse into
 * @return the parsed number//from   ww  w  . j  a  v a  2 s  .c o  m
 * @throws IllegalArgumentException if the target class is not supported
 *                                  (i.e. not a standard Number subclass as included in the JDK)
 * @see Byte#decode
 * @see Short#decode
 * @see Integer#decode
 * @see Long#decode
 * @see #decodeBigInteger(String)
 * @see Float#valueOf
 * @see Double#valueOf
 * @see BigDecimal#BigDecimal(String)
 */
@SuppressWarnings("unchecked")
public static <T extends Number> T parseNumber(String text, Class<T> targetClass) {
    org.springframework.util.Assert.notNull(text, "Text must not be null");
    org.springframework.util.Assert.notNull(targetClass, "Target class must not be null");
    String trimmed = StringUtils.trimAllWhitespace(text);

    if (Byte.class == targetClass) {
        return (T) (isHexNumber(trimmed) ? Byte.decode(trimmed) : Byte.valueOf(trimmed));
    } else if (Short.class == targetClass) {
        return (T) (isHexNumber(trimmed) ? Short.decode(trimmed) : Short.valueOf(trimmed));
    } else if (Integer.class == targetClass) {
        return (T) (isHexNumber(trimmed) ? Integer.decode(trimmed) : Integer.valueOf(trimmed));
    } else if (Long.class == targetClass) {
        return (T) (isHexNumber(trimmed) ? Long.decode(trimmed) : Long.valueOf(trimmed));
    } else if (BigInteger.class == targetClass) {
        return (T) (isHexNumber(trimmed) ? decodeBigInteger(trimmed) : new BigInteger(trimmed));
    } else if (Float.class == targetClass) {
        return (T) Float.valueOf(trimmed);
    } else if (Double.class == targetClass) {
        return (T) Double.valueOf(trimmed);
    } else if (BigDecimal.class == targetClass || Number.class == targetClass) {
        return (T) new BigDecimal(trimmed);
    } else {
        throw new IllegalArgumentException(
                "Cannot convert String [" + text + "] to target class [" + targetClass.getName() + "]");
    }
}

From source file:com.github.jessemull.microflexbigdecimal.plate.WellPrecursor.java

/**
 * Creates a new Well object using the numerical type flag, row and column 
 * strings.//from www .j  a  va  2 s  .co  m
 * @param    int       the numerical data type
 * @param    String    the well row
 * @param    String    the well column
 * @throws   IllegalArgumentException    invalid column value
 */
public WellPrecursor(int type, String row, String column) {

    try {
        this.row = Integer.decode(row);
    } catch (NumberFormatException e) {
        this.row = parseRow(row);
    }

    try {
        this.column = Integer.decode(column);
    } catch (Exception e) {
        throw new IllegalArgumentException("Illegal column value: " + column);
    }

    this.type = type;
    validateIndices(this.row, this.column);
}

From source file:it.eng.spagobi.engines.chart.bo.charttypes.dialcharts.Thermometer.java

/**
 * set parameters for the creation of the chart getting them from template or from LOV.
 * //from w ww .  j a  v  a 2s  .  c  o m
 * @param content the content of the template.
 * 
 * @return A chart that displays a value as a dial.
 */

public void configureChart(SourceBean content) {
    logger.debug("IN");
    super.configureChart(content);

    if (!isLovConfDefined) {

        if (confParameters.get(UNIT) != null) {
            String unit = (String) confParameters.get(UNIT);
            setUnits(unit);
        } else
            setUnits("");

        //reading intervals information
        SourceBean subrangesSB = (SourceBean) content.getAttribute("INTERVALS");
        if (subrangesSB == null) {
            subrangesSB = (SourceBean) content.getAttribute("CONF.INTERVALS");
        }
        List subrangesAttrsList = null;
        if (subrangesSB != null) {
            subrangesAttrsList = subrangesSB.getContainedSourceBeanAttributes();
        }

        if (subrangesAttrsList == null || subrangesAttrsList.isEmpty()) { // if subranges are not defined 
            logger.error("subranges not correctly defined");
        } else {

            Iterator subrangesAttrsIter = subrangesAttrsList.iterator();
            while (subrangesAttrsIter.hasNext()) {
                SourceBeanAttribute paramSBA = (SourceBeanAttribute) subrangesAttrsIter.next();
                SourceBean param = (SourceBean) paramSBA.getValue();
                String range = (String) param.getAttribute(LABEL_INTERVAL);
                String min = (String) param.getAttribute(MIN_INTERVAL);
                String max = (String) param.getAttribute(MAX_INTERVAL);
                String col = (String) param.getAttribute(COLOR_INTERVAL);

                KpiInterval subrange = new KpiInterval();

                subrange.setLabel(range);
                subrange.setMin(Double.valueOf(min).doubleValue());
                subrange.setMax(Double.valueOf(max).doubleValue());

                Color color = new Color(Integer.decode(col).intValue());
                if (color != null) {
                    subrange.setColor(color);
                } else {
                    subrange.setColor(Color.RED);
                }
                addIntervals(subrange);
            }
        }
    } else {

        String unit = (String) sbRow.getAttribute(UNIT);
        if (unit != null)
            setUnits(unit);
        else
            setUnits("");

        String subranges = (String) sbRow.getAttribute("subranges");
        if (subranges != null && subranges.equalsIgnoreCase("NO")) { // if intervals are not specified
            logger.warn("no subranges defined");
        } else {
            for (int i = 1; i <= 3; i++) {
                KpiInterval subrange = new KpiInterval();
                String label = (String) sbRow.getAttribute("label" + (new Integer(i)).toString());
                String min = (String) sbRow.getAttribute("min" + (new Integer(i)).toString());
                String max = (String) sbRow.getAttribute("max" + (new Integer(i)).toString());
                String col = (String) sbRow.getAttribute("color" + (new Integer(i)).toString());

                subrange.setLabel(label);
                subrange.setMin(Double.valueOf(min).doubleValue());
                subrange.setMax(Double.valueOf(max).doubleValue());
                Color color = new Color(Integer.decode(col).intValue());
                subrange.setColor(color);
                addIntervals(subrange);

            }
        }
    }
    logger.debug("OUT");
}

From source file:uni.bielefeld.cmg.sparkhit.util.ParameterForScriptPiper.java

public DefaultParam importCommandLine() {

    /* Assigning Parameter ID to an ascending number */
    putParameterID();//from w  ww . ja va2 s  .  c  o m

    /* Assigning parameter descriptions to each parameter ID */
    addParameterInfo();

    /* need a Object parser of PosixParser class for the function parse of CommandLine class */
    PosixParser parser = new PosixParser();

    /* print out help information */
    HelpParam help = new HelpParam(parameter, parameterMap);

    /* check each parameter for assignment */
    try {
        long input_limit = -1;
        int threads = Runtime.getRuntime().availableProcessors();

        /* Set Object cl of CommandLine class for Parameter storage */
        CommandLine cl = parser.parse(parameter, arguments, true);
        if (cl.hasOption(HELP)) {
            help.printScriptPiperHelp();
            System.exit(0);
        }

        if (cl.hasOption(HELP2)) {
            help.printScriptPiperHelp();
            System.exit(0);
        }

        if (cl.hasOption(VERSION)) {
            System.exit(0);
        }

        /* Checking all parameters */

        String value;

        if ((value = cl.getOptionValue(PARTITIONS)) != null) {
            param.partitions = Integer.decode(value);
        }

        if ((value = cl.getOptionValue(INPUT_FASTQ)) != null) {
            param.inputFqPath = value;
        } else if ((value = cl.getOptionValue(INPUT_LINE)) != null) {
            param.inputFqLinePath = value;
            param.inputFqPath = value;
        } else {
            help.printScriptPiperHelp();
            System.exit(0);
            //                throw new IOException("Input file not specified.\nUse -help for list of options");
        }

        /* not applicable for HDFS and S3 */
        /* using TextFileBufferInput for such purpose */
        //         File inputFastq = new File(param.inputFqPath).getAbsoluteFile();
        //         if (!inputFastq.exists()){
        //            err.println("Input query file not found.");
        //            return;
        //i         }

        if ((value = cl.getOptionValue(OUTPUT_LINE)) != null) {
            param.outputPath = value;
        } else {
            help.printScriptPiperHelp();
            info.readMessage("Output file not set with -outfile options");
            info.screenDump();
            System.exit(0);
        }

        File outfile = new File(param.outputPath).getAbsoluteFile();
        if (outfile.exists()) {
            info.readParagraphedMessages(
                    "Output file : \n\t" + param.outputPath + "\nalready exists, will be overwrite.");
            info.screenDump();
            Runtime.getRuntime().exec("rm -rf " + param.outputPath);
        }

        if (cl.hasOption(FASTQ_FILTER)) {
            param.filterFastq = true;
        }

        if (cl.hasOption(FASTA_CONVERT)) {
            param.filterToFasta = true;
        }

        if (cl.hasOption(LINE_FASTA)) {
            param.lineToFasta = true;
        }

        if ((value = cl.getOptionValue(INPUT_TOOL)) != null) {
            param.tool = value;
            info.readParagraphedMessages("External tool locate at : \n\t" + param.tool
                    + "\nplease ensure that all nodes have such tools in the same path.\nOr it is located in a shared file system.\nOr use a Docker container");
            info.screenDump();
        } else {
            help.printScriptPiperHelp();
            info.readMessage("External tool path have not been set with parameter -tool");
            info.screenDump();
            System.exit(0);
        }

        if ((value = cl.getOptionValue(TOOL_DEPEND)) != null) {
            param.toolDepend = value;
            info.readParagraphedMessages("External tool Dependencies : \n\t" + param.toolDepend + "\n");
            info.screenDump();
        } else {
            info.readMessage(
                    "External tool dependencies have not been set, will run with tool build-in Interpreter");
            info.screenDump();
        }

        if ((value = cl.getOptionValue(TOOL_PARAM)) != null) {
            param.toolParam = value;
            info.readParagraphedMessages("External tool parameter : \n\t" + param.toolParam
                    + "\nThe entire command looks like : \n\t" + param.toolDepend + " " + param.tool + " "
                    + param.toolParam);
            info.screenDump();
            info.readParagraphedMessages("Final external command is : \n\t" + param.toolDepend + " "
                    + param.tool + " " + param.toolParam);
            info.screenDump();
        } else {
            info.readMessage("External tool parameter have not been set, will run with its default parameter");
            info.screenDump();
        }

        // param.bestNas = (param.alignLength * param.readIdentity) / 100;
        // param.bestKmers = param.alignLength - (param.alignLength - param.bestNas) * 4 - 3;

    } catch (IOException e) { // Don`t catch this, NaNaNaNa, U can`t touch this.
        info.readMessage("Parameter settings incorrect.");
        info.screenDump();
        e.printStackTrace();
        System.exit(0);
    } catch (RuntimeException e) {
        info.readMessage("Parameter settings incorrect.");
        info.screenDump();
        e.printStackTrace();
        System.exit(0);
    } catch (ParseException e) {
        info.readMessage("Parameter settings incorrect.");
        info.screenDump();
        e.printStackTrace();
        System.exit(0);
    }

    return param;
}

From source file:org.kchine.rpf.ServerDefaults.java

public static Registry getRegistry(Properties props) throws Exception {
    String namingMode;//w w w.  ja va  2 s  .  c om
    String registryHost;
    int registryPort;
    String dbUrl = null;
    String dbDriver = null;
    String dbUser;
    String dbPassword;
    namingMode = (String) props.get("naming.mode") != null && !props.get("naming.mode").equals("")
            ? (String) props.get("naming.mode")
            : DEFAULT_NAMING_MODE;

    registryHost = (String) props.get("registry.host") != null && !props.get("registry.host").equals("")
            ? (String) props.get("registry.host")
            : DEFAULT_REGISTRY_HOST;
    registryPort = (String) props.get("registry.port") != null && !props.get("registry.port").equals("")
            ? Integer.decode((String) props.get("registry.port"))
            : DEFAULT_REGISTRY_PORT;

    String _DB_TYPE = (String) props.get("db.type") != null && !props.get("db.type").equals("")
            ? (String) props.get("db.type")
            : DEFAULT_DB_TYPE;
    String _DB_HOST = (String) props.get("db.host") != null && !props.get("db.host").equals("")
            ? (String) props.get("db.host")
            : DEFAULT_DB_HOST;
    int _DB_PORT = (String) props.get("db.port") != null && !props.get("db.port").equals("")
            ? Integer.decode((String) props.get("db.port"))
            : DEFAULT_DB_PORT;
    String _DB_NAME = (String) props.get("db.name") != null && !props.get("db.name").equals("")
            ? (String) props.get("db.name")
            : DEFAULT_DB_NAME;
    String _DB_DIR = (String) props.get("db.dir") != null && !props.get("db.dir").equals("")
            ? (String) props.get("db.dir")
            : DEFAULT_DB_DIR;
    _DB_DIR = _DB_DIR.replace('\\', '/');
    if (!_DB_DIR.equals("") && !_DB_DIR.endsWith("/"))
        _DB_DIR = _DB_DIR + "/";

    System.out.println("_DB_TYPE:" + _DB_TYPE);

    if (_DB_TYPE.equals("derby")) {
        dbUrl = "jdbc:derby://" + _DB_HOST + ":" + _DB_PORT + "/" + _DB_DIR + _DB_NAME + ";create=true";
        dbDriver = "org.apache.derby.jdbc.ClientDriver";

    } else if (_DB_TYPE.equals("mysql")) {
        dbUrl = "jdbc:mysql://" + _DB_HOST + ":" + _DB_PORT + "/" + _DB_NAME;
        dbDriver = "org.gjt.mm.mysql.Driver";

    } else if (_DB_TYPE.equals("oracle")) {
        dbUrl = "jdbc:oracle:thin:@" + _DB_HOST + ":" + _DB_PORT + ":" + _DB_NAME;
        dbDriver = "oracle.jdbc.driver.OracleDriver";
    }

    dbUser = (String) props.get("db.user") != null && !props.get("db.user").equals("")
            ? (String) props.get("db.user")
            : DEFAULT_DB_USER;
    dbPassword = (String) props.get("db.password") != null && !props.get("db.password").equals("")
            ? (String) props.get("db.password")
            : DEFAULT_DB_PASSWORD;

    Registry registry = null;

    if (namingMode.equals("db")) {

        Class.forName(dbDriver);
        final String dbUrlFinal = dbUrl;
        final String dbUserFinal = dbUser;
        final String dbPasswordFinal = dbPassword;
        registry = DBLayer.getLayer(PoolUtils.getDBType(dbUrl), new ConnectionProvider() {
            public Connection newConnection() throws java.sql.SQLException {
                return DriverManager.getConnection(dbUrlFinal, dbUserFinal, dbPasswordFinal);
            };
        });

    } else if (namingMode.equals("self")) {
        registry = LocalRmiRegistry.getInstance();
    } else if (namingMode.equals("registry")) {
        registry = LocateRegistry.getRegistry(registryHost, registryPort);
    } else {
        registry = ((RegistryProvider) ServerDefaults.class.forName("genericnaming." + namingMode + "Class")
                .newInstance()).getRegistry(props);
    }

    return registry;
}

From source file:com.l2jfree.gameserver.model.skills.conditions.ConditionParser.java

private Condition parsePlayerCondition(String nodeName, String nodeValue) {
    if ("skill".equalsIgnoreCase(nodeName)) {
        boolean val = Boolean.parseBoolean(nodeValue);
        return new ConditionWithSkill(val);
    } else if ("race".equalsIgnoreCase(nodeName)) {
        Race race = Race.valueOf(nodeValue);
        return new ConditionPlayerRace(race);
    } else if ("level".equalsIgnoreCase(nodeName)) {
        int lvl = Integer.decode(nodeValue);
        return new ConditionPlayerLevel(lvl);
    } else if ("resting".equalsIgnoreCase(nodeName)) {
        boolean val = Boolean.parseBoolean(nodeValue);
        return new ConditionPlayerState(PlayerState.RESTING, val);
    } else if ("moving".equalsIgnoreCase(nodeName)) {
        boolean val = Boolean.parseBoolean(nodeValue);
        return new ConditionPlayerState(PlayerState.MOVING, val);
    } else if ("running".equalsIgnoreCase(nodeName)) {
        boolean val = Boolean.parseBoolean(nodeValue);
        return new ConditionPlayerState(PlayerState.RUNNING, val);
    } else if ("walking".equalsIgnoreCase(nodeName)) {
        boolean val = Boolean.parseBoolean(nodeValue);
        return new ConditionPlayerState(PlayerState.WALKING, val);
    } else if ("behind".equalsIgnoreCase(nodeName)) {
        boolean val = Boolean.parseBoolean(nodeValue);
        return new ConditionPlayerState(PlayerState.BEHIND, val);
    } else if ("front".equalsIgnoreCase(nodeName)) {
        boolean val = Boolean.parseBoolean(nodeValue);
        return new ConditionPlayerState(PlayerState.FRONT, val);
    } else if ("chaotic".equalsIgnoreCase(nodeName)) {
        boolean val = Boolean.parseBoolean(nodeValue);
        return new ConditionPlayerState(PlayerState.CHAOTIC, val);
    } else if ("olympiad".equalsIgnoreCase(nodeName)) {
        boolean val = Boolean.parseBoolean(nodeValue);
        return new ConditionPlayerState(PlayerState.OLYMPIAD, val);
    } else if ("flying".equalsIgnoreCase(nodeName)) {
        boolean val = Boolean.parseBoolean(nodeValue);
        return new ConditionPlayerState(PlayerState.FLYING, val);
    } else if ("hp".equalsIgnoreCase(nodeName)) {
        int hp = Integer.decode(nodeValue);
        return new ConditionPlayerHp(hp);
    } else if ("mp".equalsIgnoreCase(nodeName)) {
        int mp = Integer.decode(nodeValue);
        return new ConditionPlayerMp(mp);
    } else if ("cp".equalsIgnoreCase(nodeName)) {
        int cp = Integer.decode(nodeValue);
        return new ConditionPlayerCp(cp);
    } else if ("attack_stance".equalsIgnoreCase(nodeName)) {
        boolean val = Boolean.parseBoolean(nodeValue);
        return new ConditionPlayerAttackStance(val);
    } else if ("grade".equalsIgnoreCase(nodeName)) {
        int expIndex = Integer.decode(nodeValue);
        return new ConditionPlayerGrade(expIndex);
    } else if ("siegezone".equalsIgnoreCase(nodeName)) {
        int value = Integer.decode(nodeValue);
        return new ConditionSiegeZone(value, true);
    } else if ("battle_force".equalsIgnoreCase(nodeName)) {
        byte battleForce = Byte.decode(nodeValue);
        return new ConditionForceBuff(battleForce, (byte) 0);
    } else if ("spell_force".equalsIgnoreCase(nodeName)) {
        byte spellForce = Byte.decode(nodeValue);
        return new ConditionForceBuff((byte) 0, spellForce);
    } else if ("weight".equalsIgnoreCase(nodeName)) {
        int weight = Integer.decode(nodeValue);
        return new ConditionPlayerWeight(weight);
    } else if ("invSize".equalsIgnoreCase(nodeName)) {
        int size = Integer.decode(nodeValue);
        return new ConditionPlayerInvSize(size);
    } else if ("pledgeClass".equalsIgnoreCase(nodeName)) {
        int pledgeClass = Integer.decode(nodeValue);
        return new ConditionPlayerPledgeClass(pledgeClass);
    } else if ("clanHall".equalsIgnoreCase(nodeName)) {
        List<Integer> array = new ArrayList<Integer>();
        StringTokenizer st = new StringTokenizer(nodeValue, ",");
        while (st.hasMoreTokens()) {
            array.add(Integer.decode(st.nextToken().trim()));
        }/*from ww  w  .jav  a  2 s  .  c om*/
        return new ConditionPlayerHasClanHall(array);
    } else if ("fort".equalsIgnoreCase(nodeName)) {
        int fort = Integer.decode(nodeValue);
        return new ConditionPlayerHasFort(fort);
    } else if ("castle".equalsIgnoreCase(nodeName)) {
        int castle = Integer.decode(nodeValue);
        return new ConditionPlayerHasCastle(castle);
    } else if ("sex".equalsIgnoreCase(nodeName)) {
        int sex = Integer.decode(nodeValue);
        return new ConditionPlayerSex(sex);
    } else if ("flyMounted".equalsIgnoreCase(nodeName)) {
        boolean val = Boolean.valueOf(nodeValue);
        return new ConditionPlayerFlyMounted(val);
    } else if ("landingZone".equalsIgnoreCase(nodeName)) {
        boolean val = Boolean.valueOf(nodeValue);
        return new ConditionPlayerLandingZone(val);
    } else if ("active_skill_id".equalsIgnoreCase(nodeName)
            || "active_skill_id_lvl".equalsIgnoreCase(nodeName)) {
        return new ConditionPlayerActiveSkillId(nodeValue);
    } else if ("agathionId".equalsIgnoreCase(nodeName)) {
        int agathionId = Integer.decode(nodeValue);
        return new ConditionAgathionSummoned(agathionId);
    } else if ("active_effect_id".equalsIgnoreCase(nodeName)) {
        return new ConditionPlayerActiveEffectId(nodeValue);
    } else if ("class_id_restriction".equalsIgnoreCase(nodeName)) {
        List<Integer> array = new ArrayList<Integer>();
        StringTokenizer st = new StringTokenizer(nodeValue, ",");
        while (st.hasMoreTokens()) {
            array.add(Integer.decode(st.nextToken().trim()));
        }
        return new ConditionPlayerClassIdRestriction(array);
    } else if ("isClanLeader".equalsIgnoreCase(nodeName)) {
        boolean val = Boolean.parseBoolean(nodeValue);
        return new ConditionPlayerIsClanLeader(val);
    } else if ("subclass".equalsIgnoreCase(nodeName)) {
        boolean val = Boolean.valueOf(nodeValue);
        return new ConditionPlayerSubclass(val);
    } else if ("instanceid".equalsIgnoreCase(nodeName)) {
        List<Integer> array = new ArrayList<Integer>();
        StringTokenizer st = new StringTokenizer(nodeValue, ",");
        while (st.hasMoreTokens()) {
            array.add(Integer.decode(st.nextToken().trim()));
        }
        return new ConditionPlayerInstanceId(array);
    }
    throw new IllegalStateException("Invalid attribute at <player>: " + nodeName + "='" + nodeValue + "'");
}