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:com.l2jfree.gameserver.handler.admincommands.AdminEditChar.java

@Override
public boolean useAdminCommand(String command, L2Player activeChar) {
    if (command.equals("admin_current_player")) {
        showCharacterInfo(activeChar, null);
    } else if ((command.startsWith("admin_character_list")) || (command.startsWith("admin_character_info"))) {
        try {//w  w w .  jav a  2s  .c  om
            String val = command.substring(21);
            L2Player target = L2World.getInstance().getPlayer(val);
            if (target != null)
                showCharacterInfo(activeChar, target);
            else
                activeChar.sendPacket(SystemMessageId.CHARACTER_DOES_NOT_EXIST);
        } catch (StringIndexOutOfBoundsException e) {
            activeChar.sendMessage("Usage: //character_info <player_name>");
        }
    } else if (command.startsWith("admin_show_characters")) {
        try {
            String val = command.substring(22);
            int page = Integer.parseInt(val);
            listCharacters(activeChar, page);
        } catch (Exception e) {
            //Case of empty page number
            activeChar.sendMessage("Usage: //show_characters <page_number>");
        }
    } else if (command.startsWith("admin_find_character")) {
        try {
            String val = command.substring(21);
            findCharacter(activeChar, val);
        } catch (StringIndexOutOfBoundsException e) { //Case of empty character name
            activeChar.sendMessage("Usage: //find_character <character_name>");
            listCharacters(activeChar, 0);
        }
    } else if (command.startsWith("admin_find_ip")) {
        try {
            String val = command.substring(14);
            findCharactersPerIp(activeChar, val);
        } catch (Exception e) { //Case of empty or malformed IP number
            activeChar.sendMessage("Usage: //find_ip <www.xxx.yyy.zzz>");
            listCharacters(activeChar, 0);
        }
    } else if (command.startsWith("admin_find_account")) {
        try {
            String val = command.substring(19);
            findCharactersPerAccount(activeChar, val);
        } catch (Exception e) { //Case of empty or malformed player name
            activeChar.sendMessage("Usage: //find_account <player_name>");
            listCharacters(activeChar, 0);
        }
    } else if (command.equals("admin_edit_character"))
        editCharacter(activeChar);
    // Karma control commands
    else if (command.equals("admin_nokarma"))
        setTargetKarma(activeChar, 0);
    else if (command.startsWith("admin_setkarma")) {
        try {
            String val = command.substring(15);
            int karma = Integer.parseInt(val);

            setTargetKarma(activeChar, karma);
        } catch (Exception e) {
            activeChar.sendMessage("Usage: //setkarma <new_karma_value>");
        }
    } else if (command.startsWith("admin_setfame")) {
        try {
            String val = command.substring(14);
            int fame = Integer.parseInt(val);
            L2Object target = activeChar.getTarget();
            if (target instanceof L2Player) {
                L2Player player = (L2Player) target;
                player.setFame(fame);
                player.sendPacket(new UserInfo(player));
                player.sendMessage("A GM changed your Reputation points to " + fame);
            } else {
                activeChar.sendPacket(SystemMessageId.INCORRECT_TARGET);
            }
        } catch (Exception e) {
            activeChar.sendMessage("Usage: //setfame <new_fame_value>");
        }
    } else if (command.startsWith("admin_save_modifications")) {
        try {
            String val = command.substring(24);
            adminModifyCharacter(activeChar, val);
        } catch (StringIndexOutOfBoundsException e) { //Case of empty character name
            activeChar.sendMessage("Error while modifying character.");
            listCharacters(activeChar, 0);
        }
    } else if (command.startsWith("admin_rec")) {
        try {
            StringTokenizer st = new StringTokenizer(command, " ");
            st.nextToken();
            int recVal = Integer.parseInt(st.nextToken());
            boolean temp = true;
            try {
                temp = !st.nextToken().equals("y");
            } catch (NoSuchElementException nsee) {
            }
            L2Object target = activeChar.getTarget();
            L2Player player = null;
            if (target instanceof L2Player)
                player = (L2Player) target;
            else
                return false;
            if (temp)
                player.setEvalPoints(recVal);
            else
                RecommendationManager.getInstance().onGmEvaluation(player, recVal);
            player.sendMessage("You have been evaluated by a GM!" + (temp ? " (temporarily)" : ""));
            player.broadcastUserInfo();
        } catch (Exception e) {
            activeChar.sendMessage("Usage: //rec number [save? y/n]");
        }
    } else if (command.startsWith("admin_setclass")) {
        try {
            String val = command.substring(15);
            int classidval = Integer.parseInt(val);
            L2Object target = activeChar.getTarget();
            L2Player player = null;
            if (target instanceof L2Player)
                player = (L2Player) target;
            else
                return false;
            boolean valid = false;
            for (ClassId classid : ClassId.values())
                if (classidval == classid.getId())
                    valid = true;
            if (valid && (player.getClassId().getId() != classidval)) {
                player.setClassId(classidval);
                if (!player.isSubClassActive())
                    player.setBaseClass(classidval);
                String newclass = player.getTemplate().getClassName();
                player.store();
                if (player != activeChar)
                    player.sendMessage("A GM changed your class to " + newclass);
                activeChar.sendMessage(player.getName() + " changed to " + newclass);

                // Quickly transform them to force the client to reload the character textures
                TransformationManager.getInstance().transformPlayer(105, player);
                ThreadPoolManager.getInstance().scheduleGeneral(new Untransform(player), 200);
            } else
                activeChar.sendMessage("Usage: //setclass <valid_new_classid>");
        } catch (Exception e) {
            AdminHelpPage.showHelpPage(activeChar, "charclasses.htm");
        }
    } else if (command.startsWith("admin_settitle")) {
        String val = "";
        StringTokenizer st = new StringTokenizer(command);
        st.nextToken();
        L2Object target = activeChar.getTarget();
        L2Player player = null;
        L2Npc npc = null;

        if (target == null)
            player = activeChar;
        else if (target instanceof L2Player)
            player = (L2Player) target;
        else if (target instanceof L2Npc)
            npc = (L2Npc) target;
        else
            return false;

        if (st.hasMoreTokens())
            val = st.nextToken();
        while (st.hasMoreTokens())
            val += " " + st.nextToken();

        if (player != null) {
            player.setTitle(val);
            if (player != activeChar)
                player.sendMessage("Your title has been changed by a GM");
            player.broadcastTitleInfo();
        } else if (npc != null) {
            npc.setTitle(val);
            npc.updateAbnormalEffect();
        }
    } else if (command.startsWith("admin_changename")) {
        try {

            StringTokenizer st = new StringTokenizer(command);
            st.nextToken();
            String val = st.nextToken();
            L2Object target = activeChar.getTarget();
            L2Player player = null;

            String oldName = null;

            if (target instanceof L2Player) {
                player = (L2Player) target;
                oldName = player.getName();

                if (CharNameTable.getInstance().getByName(val) != null) {
                    activeChar.sendMessage("Player with name already exists!");
                    return false;
                }

                L2World.getInstance().removeOnlinePlayer(player);
                player.setName(val);
                player.store();
                L2World.getInstance().addOnlinePlayer(player);

                player.sendMessage("Your name has been changed by a GM.");
                player.broadcastUserInfo();

                if (player.isInParty()) {
                    // Delete party window for other party members
                    player.getParty().refreshPartyView();
                }
                if (player.getClan() != null) {
                    player.getClan().broadcastClanStatus();
                }

                RegionBBSManager.changeCommunityBoard(player, PlayerStateOnCommunity.NONE);
            } else if (target instanceof L2Npc) {
                L2Npc npc = (L2Npc) target;
                oldName = npc.getName();
                npc.setName(val);
                npc.updateAbnormalEffect();
            }
            if (oldName == null)
                activeChar.sendPacket(SystemMessageId.INCORRECT_TARGET);
            else
                activeChar.sendMessage("Name changed from " + oldName + " to " + val);
        } catch (Exception e) { //Case of empty character name
            activeChar.sendMessage("Usage: //setname new_name_for_target");
        }
    } else if (command.startsWith("admin_setsex")) {
        L2Object target = activeChar.getTarget();
        L2Player player = null;
        if (target instanceof L2Player) {
            player = (L2Player) target;
        } else {
            return false;
        }
        player.getAppearance().setSex(player.getAppearance().getSex() ? false : true);
        player.sendMessage("Your gender has been changed by a GM");

        // Quickly transform them to force the client to reload the character textures
        TransformationManager.getInstance().transformPlayer(105, player);
        ThreadPoolManager.getInstance().scheduleGeneral(new Untransform(player), 200);
    } else if (command.startsWith("admin_setcolor")) {
        try {
            String val = command.substring(15);
            L2Object target = activeChar.getTarget();
            L2Player player = null;
            if (target instanceof L2Player)
                player = (L2Player) target;
            else
                return false;
            player.getAppearance().setNameColor(Integer.decode("0x" + val));
            player.sendMessage("Your name color has been changed by a GM");
            player.broadcastUserInfo();
        } catch (Exception e) { //Case of empty color or invalid hex string
            activeChar.sendMessage("You need to specify a valid new color.");
        }
    } else if (command.startsWith("admin_fullfood")) {
        L2Object target = activeChar.getTarget();
        if (target instanceof L2PetInstance) {
            L2PetInstance targetPet = (L2PetInstance) target;
            targetPet.setCurrentFed(targetPet.getMaxFed());
            targetPet.getOwner()
                    .sendPacket(new SetSummonRemainTime(targetPet.getMaxFed(), targetPet.getCurrentFed()));
        } else
            activeChar.sendPacket(SystemMessageId.INCORRECT_TARGET);
    }
    // [L2J_JP ADD START]
    else if (command.startsWith("admin_sethero") || command.startsWith("admin_manualhero")) {
        L2Object target = activeChar.getTarget();
        L2Player player = null;
        if (target instanceof L2Player)
            player = (L2Player) target;
        else
            return false;
        player.setHero(!player.isHero());
        if (player.isHero())
            player.broadcastPacket(new SocialAction(player.getObjectId(), 16));
        player.sendMessage("Admin changed your hero status");
        player.broadcastUserInfo();
    }
    // [L2J_JP ADD END]
    else if (command.equals("admin_remclanwait")) {
        L2Object target = activeChar.getTarget();
        L2Player player = null;
        if (target instanceof L2Player) {
            player = (L2Player) target;
        } else {
            return false;
        }

        if (player.getClan() == null) {
            player.setClanJoinExpiryTime(0);
            player.setClanCreateExpiryTime(0);
            player.sendMessage(
                    "A GM has reset your clan wait time, You may now join another clan or create one.");
            activeChar.sendMessage(
                    "You have reset " + player.getName() + "'s wait time to join/create another clan.");
        } else {
            activeChar.sendMessage("Sorry, but " + player.getName()
                    + " must not be in a clan. Player must leave clan before the wait limit can be reset.");
        }
    } else if (command.startsWith("admin_find_dualbox")) {
        int multibox = 2;
        try {
            String val = command.substring(19);
            multibox = Integer.parseInt(val);
            if (multibox < 1) {
                activeChar.sendMessage("Usage: //find_dualbox [number > 0]");
                return false;
            }
        } catch (Exception e) {
        }
        findDualbox(activeChar, multibox);
    }

    return true;
}

From source file:org.openhab.binding.plclogo.internal.PLCLogoBinding.java

@Override
public void updated(Dictionary<String, ?> config) throws ConfigurationException {
    Boolean configured = false;/*from  w w  w.  j a v  a2 s  . c o  m*/
    if (config != null) {
        String refreshIntervalString = Objects.toString(config.get("refresh"), null);
        if (StringUtils.isNotBlank(refreshIntervalString)) {
            refreshInterval = Long.parseLong(refreshIntervalString);
        }

        if (controllers == null) {
            controllers = new HashMap<String, PLCLogoConfig>();
        }

        Enumeration<String> keys = config.keys();
        while (keys.hasMoreElements()) {
            String key = keys.nextElement();

            // the config-key enumeration contains additional keys that we
            // don't want to process here ...
            if ("service.pid".equals(key)) {
                continue;
            }

            Matcher matcher = EXTRACT_CONFIG_PATTERN.matcher(key);
            if (!matcher.matches()) {
                continue;
            }

            matcher.reset();
            matcher.find();
            String controllerName = matcher.group(1);
            PLCLogoConfig deviceConfig = controllers.get(controllerName);

            if (deviceConfig == null) {
                deviceConfig = new PLCLogoConfig();
                controllers.put(controllerName, deviceConfig);
                logger.info("Create new config for {}", controllerName);
            }
            if (matcher.group(2).equals("host")) {
                String ip = config.get(key).toString();
                deviceConfig.setIP(ip);
                logger.info("Set host of {}: {}", controllerName, ip);
                configured = true;
            }
            if (matcher.group(2).equals("remoteTSAP")) {
                String tsap = config.get(key).toString();
                deviceConfig.setRemoteTSAP(Integer.decode(tsap));
                logger.info("Set remote TSAP for {}: {}", controllerName, tsap);
            }
            if (matcher.group(2).equals("localTSAP")) {
                String tsap = config.get(key).toString();
                deviceConfig.setLocalTSAP(Integer.decode(tsap));
                logger.info("Set local TSAP for {}: {}", controllerName, tsap);
            }
            if (matcher.group(2).equals("model")) {
                PLCLogoModel model = null;
                String modelName = config.get(key).toString();
                if (modelName.equalsIgnoreCase("0BA7")) {
                    model = PLCLogoModel.LOGO_MODEL_0BA7;
                } else if (modelName.equalsIgnoreCase("0BA8")) {
                    model = PLCLogoModel.LOGO_MODEL_0BA8;
                } else {
                    logger.info("Found unknown model for {}: {}", controllerName, modelName);
                }

                if (model != null) {
                    deviceConfig.setModel(model);
                    logger.info("Set model for {}: {}", controllerName, modelName);
                }
            }
        } // while

        Iterator<Entry<String, PLCLogoConfig>> entries = controllers.entrySet().iterator();
        while (entries.hasNext()) {
            Entry<String, PLCLogoConfig> thisEntry = entries.next();
            String controllerName = thisEntry.getKey();
            PLCLogoConfig deviceConfig = thisEntry.getValue();
            S7Client LogoS7Client = deviceConfig.getS7Client();
            if (LogoS7Client == null) {
                LogoS7Client = new Moka7.S7Client();
            } else {
                LogoS7Client.Disconnect();
            }
            LogoS7Client.SetConnectionParams(deviceConfig.getlogoIP(), deviceConfig.getlocalTSAP(),
                    deviceConfig.getremoteTSAP());
            logger.info("About to connect to {}", controllerName);

            if ((LogoS7Client.Connect() == 0) && LogoS7Client.Connected) {
                logger.info("Connected to PLC LOGO! device {}", controllerName);
            } else {
                logger.error("Could not connect to PLC LOGO! device {} : {}", controllerName,
                        S7Client.ErrorText(LogoS7Client.LastError));
                throw new ConfigurationException("Could not connect to PLC LOGO! device ",
                        controllerName + " " + deviceConfig.getlogoIP());
            }
            deviceConfig.setS7Client(LogoS7Client);
        }

        setProperlyConfigured(configured);
    } else {
        logger.info("No configuration for PLCLogoBinding");
    }
}

From source file:com.osbitools.ws.shared.auth.SamlSecurityProvider.java

/**
 * Look for a session and if it's completed or not found try 
 *                            re-validate existing security token
 *///ww w.ja v a 2s.  c o m
@Override
public void validate(HttpServletRequest req, String stoken) throws WsSrvException {
    Session session = activeSessions.get(stoken);

    if (!(session == null || session.isFinished()))
        // Everything fine
        return;

    getLogger(req).debug("Local session validation faied." + " Sending POST request to validate SAML session");

    // Revalidate session
    PostMethod post = new PostMethod(_login);

    try {
        String ars = createAuthnRequest(getServiceLocation(req), getRefererUrl(req));
        post.setParameter("SAMLRequest", ars);
    } catch (MarshallingException | SignatureException | IOException e) {
        //-- 63
        throw new WsSrvException(63, e);
    }

    HttpClient hc = (new HttpClientBuilder()).buildClient();
    post.setRequestHeader("Cookie",
            (String) req.getSession().getServletContext().getAttribute("scookie_name") + "=" + stoken);

    int result;
    try {
        result = hc.executeMethod(post);
    } catch (IOException e) {
        //-- 66
        throw new WsSrvException(66, e);
    }

    // Expecting 200 if cookie valid and 302 if not, rest are errors
    if (result == HttpStatus.SC_OK) {
        // Extract end process SAML response from form
        String rb;
        try {
            rb = new String(post.getResponseBody());
        } catch (IOException e) {
            //-- 67
            throw new WsSrvException(67, e);
        }

        Matcher m = SAML_RESP.matcher(rb);

        if (m.matches() && m.groupCount() == 1) {
            String gs = m.group(1);

            // Convert hex decoded javascript variable
            String msg = "";
            int start = 0;
            Matcher m1 = HP.matcher(gs);

            while (m1.find()) {
                String dc = m1.group(1);
                int i = Integer.decode("#" + dc);

                int st = m1.start();
                int ed = m1.end();

                msg += gs.substring(start, st) + (char) i;
                start = ed;
            }

            try {
                procAuthnResponse(req, msg, stoken);
            } catch (Exception e) {
                //-- 62
                throw new WsSrvException(62, e);
            }
        }
    } else if (result == HttpStatus.SC_MOVED_TEMPORARILY) {
        //-- 64
        throw new WsSrvException(64, "Redirect received");
    } else {
        //-- 65
        throw new WsSrvException(65, "Unexpected http return code " + result);
    }
}

From source file:babybear.akbquiz.ConfigActivity.java

/**
 * /*from  w  ww.  ja va2s  .  co m*/
 */
private void loadPlaylistEditor() {

    musicList = queryMusics();
    playlistList = loadPlaylist();

    PlaylistAdapter playlistAdapter = new PlaylistAdapter(this, playlistList, new OnClickListener() {
        @Override
        public void onClick(View v) {
            int position = Integer.decode((String) v.getTag());
            onModifing = position;
            cfgflipper.showNext();
            ((TextView) findViewById(R.id.current)).setText(getString(R.string.config_bgm_onmodifing,
                    (onModifing + 1), playlistList.get(onModifing).TITLE));
            ((Button) findViewById(R.id.config_playlist_remove)).setText(R.string.remove);
        }
    });
    playlistView = (ListView) findViewById(R.id.playlist);
    playlistView.setAdapter(playlistAdapter);

    PlaylistAdapter musiclistAdapter = new PlaylistAdapter(this, musicList, new OnClickListener() {

        @Override
        public void onClick(View arg0) {
            int position = Integer.parseInt((String) arg0.getTag());
            Log.d("", "set " + onModifing + " in Playlist with " + position + " in Musiclist");
            Music temp = musicList.get(position);
            // playlistAdapter.;
            if (onModifing == playlistList.size()) {
                playlistList.add(temp);
            } else {
                playlistList.set(onModifing, temp);
            }
            PlaylistAdapter adapter = (PlaylistAdapter) playlistView.getAdapter();
            adapter.remove(adapter.getItem(onModifing));
            adapter.insert(temp, onModifing);
            savePlaylist();

            isPlaylistChanged = true;
            cfgflipper.showPrevious();
        }

    });
    ListView musiclistView = (ListView) findViewById(R.id.musiclist);
    musiclistView.setAdapter(musiclistAdapter);

    ((Button) findViewById(R.id.config_playlist_add)).setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            int position = playlistList.size();
            onModifing = position;
            cfgflipper.showNext();
            ((TextView) findViewById(R.id.current)).setText(R.string.config_bgm_add);
            ((Button) findViewById(R.id.config_playlist_remove)).setText(android.R.string.cancel);
        }

    });

    ((Button) findViewById(R.id.config_playlist_remove)).setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            if (onModifing != playlistList.size()) {

                playlistList.remove(onModifing);

                // PlaylistAdapter adapter = (PlaylistAdapter)
                // playlistView
                // .getAdapter();
                // adapter.remove(adapter.getItem(onModifing));
                savePlaylist();

                isPlaylistChanged = true;
            }
            cfgflipper.showPrevious();
        }

    });

}

From source file:org.openmainframe.ade.scores.LastSeenScorer.java

/**
 * Gets the delta values (change in seconds between each message instance) calculated by the 
 * LastSeenLogginScoreContinuous class. Reformats the delta values so it the deltas are in an integer
 * array.// ww w . j  av a 2  s  .  c  o  m
 * @param analyzedMessageSummary The analysis results of a MessageSummary object. Message summaries contain 
 * statistics and information on message instances. i.e. text body message, message id, severity, etc.
 * @return The delta values in an integer array.
 */
protected Integer[] extractDelta(IAnalyzedMessageSummary ms) {
    final String rawDelta = ms.getStatistics()
            .getStringStat(LastSeenLoggingScorerContinuous.class.getSimpleName() + "." + "res");
    if (rawDelta.equals("[]")) {
        return null;
    }
    final List<String> stringDelta = Arrays
            .asList(StringUtils.split(StringUtils.substringBetween(rawDelta, "[", "]"), ", "));
    final Integer[] delta = new Integer[stringDelta.size()];
    for (int i = 0; i < stringDelta.size(); ++i) {
        delta[i] = Integer.decode(stringDelta.get(i));
    }
    return delta;
}

From source file:com.qumoon.commons.web.HTMLInputChecker.java

protected String decodeEntities(String s) {
    StringBuffer buf = new StringBuffer();

    Pattern p = Pattern.compile("&#(\\d+);?");
    Matcher m = p.matcher(s);/*from  www.j av a 2 s .c om*/
    while (m.find()) {
        String match = m.group(1);
        int decimal = Integer.decode(match).intValue();
        appendReplacement(m, buf, HTMLInputChecker.chr(decimal));
    }
    m.appendTail(buf);
    s = buf.toString();

    buf = new StringBuffer();
    p = Pattern.compile("&#x([0-9a-f]+);?");
    m = p.matcher(s);
    while (m.find()) {
        String match = m.group(1);
        int decimal = Integer.decode(match).intValue();
        appendReplacement(m, buf, HTMLInputChecker.chr(decimal));
    }
    m.appendTail(buf);
    s = buf.toString();

    buf = new StringBuffer();
    p = Pattern.compile("%([0-9a-f]{2});?");
    m = p.matcher(s);
    while (m.find()) {
        String match = m.group(1);
        int decimal = Integer.decode(match).intValue();
        appendReplacement(m, buf, HTMLInputChecker.chr(decimal));
    }
    m.appendTail(buf);
    s = buf.toString();

    s = validateEntities(s);
    return s;
}

From source file:com.googlecode.android_scripting.rpc.MethodDescriptor.java

/** Returns the converters for {@code String}, {@code Integer} and {@code Boolean}. */
private static Map<Class<?>, Converter<?>> populateConverters() {
    Map<Class<?>, Converter<?>> converters = new HashMap<Class<?>, Converter<?>>();
    converters.put(String.class, new Converter<String>() {
        public String convert(String value) {
            return value;
        }//  w  ww.  j a v  a2 s. c o m
    });
    converters.put(Integer.class, new Converter<Integer>() {
        public Integer convert(String input) {
            try {
                return Integer.decode(input);
            } catch (NumberFormatException e) {
                throw new IllegalArgumentException("'" + input + "' is not an integer");
            }
        }
    });
    converters.put(Boolean.class, new Converter<Boolean>() {
        public Boolean convert(String input) {
            if (input == null) {
                return null;
            }
            input = input.toLowerCase();
            if (input.equals("true")) {
                return Boolean.TRUE;
            }
            if (input.equals("false")) {
                return Boolean.FALSE;
            }
            throw new IllegalArgumentException("'" + input + "' is not a boolean");
        }
    });
    return converters;
}

From source file:pcgen.core.SettingsHandler.java

public static int getGMGenOption(final String optionName, final int defaultValue) {
    return Integer.decode(getGMGenOption(optionName, String.valueOf(defaultValue))).intValue();
}

From source file:lineage2.gameserver.handler.admincommands.impl.AdminEditChar.java

/**
 * Method useAdminCommand.//  w  ww. j  av a 2s.com
 * @param comm Enum<?>
 * @param wordList String[]
 * @param fullString String
 * @param activeChar Player
 * @return boolean * @see lineage2.gameserver.handler.admincommands.IAdminCommandHandler#useAdminCommand(Enum<?>, String[], String, Player)
 */
@Override
public boolean useAdminCommand(Enum<?> comm, String[] wordList, String fullString, Player activeChar) {
    Commands command = (Commands) comm;
    if (activeChar.getPlayerAccess().CanRename) {
        if (fullString.startsWith("admin_settitle")) {
            try {
                String val = fullString.substring(15);
                GameObject target = activeChar.getTarget();
                Player player = null;
                if (target == null) {
                    return false;
                }
                if (target.isPlayer()) {
                    player = (Player) target;
                    player.setTitle(val);
                    player.sendMessage("Your title has been changed by a GM");
                    player.sendChanges();
                } else if (target.isNpc()) {
                    ((NpcInstance) target).setTitle(val);
                    target.decayMe();
                    target.spawnMe();
                }
                return true;
            } catch (StringIndexOutOfBoundsException e) {
                activeChar.sendMessage("You need to specify the new title.");
                return false;
            }
        } else if (fullString.startsWith("admin_setclass")) {
            try {
                String val = fullString.substring(15);
                int id = Integer.parseInt(val.trim());
                GameObject target = activeChar.getTarget();
                if ((target == null) || !target.isPlayer()) {
                    target = activeChar;
                }
                if (id > (ClassId.VALUES.length - 1)) {
                    activeChar.sendMessage(
                            "There are no classes over " + String.valueOf(ClassId.VALUES.length - 1) + "  id.");
                    return false;
                }
                Player player = target.getPlayer();
                player.setClassId(id, true, false);
                player.sendMessage("Your class has been changed by a GM");
                player.broadcastCharInfo();
                return true;
            } catch (StringIndexOutOfBoundsException e) {
                activeChar.sendMessage("You need to specify the new class id.");
                return false;
            }
        } else if (fullString.startsWith("admin_setname")) {
            try {
                String val = fullString.substring(14);
                GameObject target = activeChar.getTarget();
                Player player;
                if ((target != null) && target.isPlayer()) {
                    player = (Player) target;
                } else {
                    return false;
                }
                if (mysql.simple_get_int("count(*)", "characters", "`char_name` like '" + val + "'") > 0) {
                    activeChar.sendMessage("Name already exist.");
                    return false;
                }
                Log.add("Character " + player.getName() + " renamed to " + val + " by GM "
                        + activeChar.getName(), "renames");
                player.reName(val);
                player.sendMessage("Your name has been changed by a GM");
                return true;
            } catch (StringIndexOutOfBoundsException e) {
                activeChar.sendMessage("You need to specify the new name.");
                return false;
            }
        }
    }
    if (!activeChar.getPlayerAccess().CanEditChar && !activeChar.getPlayerAccess().CanViewChar) {
        return false;
    }
    if (fullString.equals("admin_current_player")) {
        showCharacterList(activeChar, null);
    } else if (fullString.startsWith("admin_character_list")) {
        try {
            String val = fullString.substring(21);
            Player target = GameObjectsStorage.getPlayer(val);
            showCharacterList(activeChar, target);
        } catch (StringIndexOutOfBoundsException e) {
        }
    } else if (fullString.startsWith("admin_show_characters")) {
        try {
            String val = fullString.substring(22);
            int page = Integer.parseInt(val);
            listCharacters(activeChar, page);
        } catch (StringIndexOutOfBoundsException e) {
        }
    } else if (fullString.startsWith("admin_find_character")) {
        try {
            String val = fullString.substring(21);
            findCharacter(activeChar, val);
        } catch (StringIndexOutOfBoundsException e) {
            activeChar.sendMessage("You didnt enter a character name to find.");
            listCharacters(activeChar, 0);
        }
    } else if (!activeChar.getPlayerAccess().CanEditChar) {
        return false;
    } else if (fullString.equals("admin_edit_character")) {
        editCharacter(activeChar);
    } else if (fullString.equals("admin_character_actions")) {
        showCharacterActions(activeChar);
    } else if (fullString.equals("admin_nokarma")) {
        setTargetKarma(activeChar, 0);
    } else if (fullString.startsWith("admin_setkarma")) {
        try {
            String val = fullString.substring(15);
            int karma = Integer.parseInt(val);
            setTargetKarma(activeChar, karma);
        } catch (StringIndexOutOfBoundsException e) {
            activeChar.sendMessage("Please specify new karma value.");
        }
    } else if (fullString.startsWith("admin_save_modifications")) {
        try {
            String val = fullString.substring(24);
            adminModifyCharacter(activeChar, val);
        } catch (StringIndexOutOfBoundsException e) {
            activeChar.sendMessage("Error while modifying character.");
            listCharacters(activeChar, 0);
        }
    } else if (fullString.equals("admin_rec")) {
        GameObject target = activeChar.getTarget();
        Player player = null;
        if ((target != null) && target.isPlayer()) {
            player = (Player) target;
        } else {
            return false;
        }
        player.setRecomHave(player.getRecomHave() + 1);
        player.sendMessage("You have been recommended by a GM");
        player.broadcastCharInfo();
    } else if (fullString.startsWith("admin_rec")) {
        try {
            String val = fullString.substring(10);
            int recVal = Integer.parseInt(val);
            GameObject target = activeChar.getTarget();
            Player player = null;
            if ((target != null) && target.isPlayer()) {
                player = (Player) target;
            } else {
                return false;
            }
            player.setRecomHave(player.getRecomHave() + recVal);
            player.sendMessage("You have been recommended by a GM");
            player.broadcastCharInfo();
        } catch (NumberFormatException e) {
            activeChar.sendMessage("Command format is //rec <number>");
        }
    } else if (fullString.startsWith("admin_sethero")) {
        GameObject target = activeChar.getTarget();
        Player player;
        if ((wordList.length > 1) && (wordList[1] != null)) {
            player = GameObjectsStorage.getPlayer(wordList[1]);
            if (player == null) {
                activeChar.sendMessage("Character " + wordList[1] + " not found in game.");
                return false;
            }
        } else if ((target != null) && target.isPlayer()) {
            player = (Player) target;
        } else {
            activeChar.sendMessage("You must specify the name or target character.");
            return false;
        }
        if (player.isHero()) {
            player.setHero(false);
            player.updatePledgeClass();
            player.removeSkill(SkillTable.getInstance().getInfo(395, 1));
            player.removeSkill(SkillTable.getInstance().getInfo(396, 1));
            player.removeSkill(SkillTable.getInstance().getInfo(1374, 1));
            player.removeSkill(SkillTable.getInstance().getInfo(1375, 1));
            player.removeSkill(SkillTable.getInstance().getInfo(1376, 1));
        } else {
            player.setHero(true);
            player.updatePledgeClass();
            player.addSkill(SkillTable.getInstance().getInfo(395, 1));
            player.addSkill(SkillTable.getInstance().getInfo(396, 1));
            player.addSkill(SkillTable.getInstance().getInfo(1374, 1));
            player.addSkill(SkillTable.getInstance().getInfo(1375, 1));
            player.addSkill(SkillTable.getInstance().getInfo(1376, 1));
        }
        player.sendSkillList();
        player.sendMessage("Admin has changed your hero status.");
        player.broadcastUserInfo();
    } else if (fullString.startsWith("admin_setnoble")) {
        GameObject target = activeChar.getTarget();
        Player player;
        if ((wordList.length > 1) && (wordList[1] != null)) {
            player = GameObjectsStorage.getPlayer(wordList[1]);
            if (player == null) {
                activeChar.sendMessage("Character " + wordList[1] + " not found in game.");
                return false;
            }
        } else if ((target != null) && target.isPlayer()) {
            player = (Player) target;
        } else {
            activeChar.sendMessage("You must specify the name or target character.");
            return false;
        }
        if (player.isNoble()) {
            Olympiad.removeNoble(player);
            player.setNoble(false);
            player.sendMessage("Admin changed your noble status, now you are not nobless.");
        } else {
            Olympiad.addNoble(player);
            player.setNoble(true);
            player.sendMessage("Admin changed your noble status, now you are Nobless.");
        }
        player.updatePledgeClass();
        player.updateNobleSkills();
        player.sendSkillList();
        player.broadcastUserInfo();
    } else if (fullString.startsWith("admin_setsex")) {
        GameObject target = activeChar.getTarget();
        Player player = null;
        if ((target != null) && target.isPlayer()) {
            player = (Player) target;
        } else {
            return false;
        }
        player.changeSex();
        player.sendMessage("Your gender has been changed by a GM");
        player.broadcastUserInfo();
    } else if (fullString.startsWith("admin_setcolor")) {
        try {
            String val = fullString.substring(15);
            GameObject target = activeChar.getTarget();
            Player player = null;
            if ((target != null) && target.isPlayer()) {
                player = (Player) target;
            } else {
                return false;
            }
            player.setNameColor(Integer.decode("0x" + val));
            player.sendMessage("Your name color has been changed by a GM");
            player.broadcastUserInfo();
        } catch (StringIndexOutOfBoundsException e) {
            activeChar.sendMessage("You need to specify the new color.");
        }
    } else if (fullString.startsWith("admin_add_exp_sp_to_character")) {
        addExpSp(activeChar);
    } else if (fullString.startsWith("admin_add_exp_sp")) {
        try {
            final String val = fullString.substring(16).trim();
            String[] vals = val.split(" ");
            long exp = NumberUtils.toLong(vals[0], 0L);
            int sp = vals.length > 1 ? NumberUtils.toInt(vals[1], 0) : 0;
            adminAddExpSp(activeChar, exp, sp);
        } catch (Exception e) {
            activeChar.sendMessage("Usage: //add_exp_sp <exp> <sp>");
        }
    } else if (fullString.startsWith("admin_trans")) {
        StringTokenizer st = new StringTokenizer(fullString);
        if (st.countTokens() > 1) {
            st.nextToken();
            int transformId = 0;
            try {
                transformId = Integer.parseInt(st.nextToken());
            } catch (Exception e) {
                activeChar.sendMessage("Specify a valid integer value.");
                return false;
            }
            if ((transformId != 0) && (activeChar.getTransformation() != 0)) {
                activeChar.sendPacket(Msg.YOU_ALREADY_POLYMORPHED_AND_CANNOT_POLYMORPH_AGAIN);
                return false;
            }
            activeChar.setTransformation(transformId);
            activeChar.sendMessage("Transforming...");
        } else {
            activeChar.sendMessage("Usage: //trans <ID>");
        }
    } else if (fullString.startsWith("admin_setsubclass")) {
        final GameObject target = activeChar.getTarget();
        if ((target == null) || !target.isPlayer()) {
            activeChar.sendPacket(Msg.SELECT_TARGET);
            return false;
        }
        final Player player = (Player) target;
        StringTokenizer st = new StringTokenizer(fullString);
        if (st.countTokens() > 1) {
            st.nextToken();
            int classId = Short.parseShort(st.nextToken());
            if (!player.addSubClass(classId, true, 0, 0, false, 0)) {
                activeChar.sendMessage(new CustomMessage(
                        "lineage2.gameserver.model.instances.L2VillageMasterInstance.SubclassCouldNotBeAdded",
                        activeChar));
                return false;
            }
            player.sendPacket(Msg.CONGRATULATIONS_YOU_HAVE_TRANSFERRED_TO_A_NEW_CLASS);
        } else {
            setSubclass(activeChar, player);
        }
    } else if (fullString.startsWith("admin_setfame")) {
        try {
            String val = fullString.substring(14);
            int fame = Integer.parseInt(val);
            setTargetFame(activeChar, fame);
        } catch (StringIndexOutOfBoundsException e) {
            activeChar.sendMessage("Please specify new fame value.");
        }
    } else if (fullString.startsWith("admin_setbday")) {
        String msgUsage = "Usage: //setbday YYYY-MM-DD";
        String date = fullString.substring(14);
        if ((date.length() != 10) || !Util.isMatchingRegexp(date, "[0-9]{4}-[0-9]{2}-[0-9]{2}")) {
            activeChar.sendMessage(msgUsage);
            return false;
        }
        SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
        try {
            dateFormat.parse(date);
        } catch (ParseException e) {
            activeChar.sendMessage(msgUsage);
        }
        if ((activeChar.getTarget() == null) || !activeChar.getTarget().isPlayer()) {
            activeChar.sendMessage("Please select a character.");
            return false;
        }
        if (!mysql.set("update characters set createtime = UNIX_TIMESTAMP('" + date + "') where obj_Id = "
                + activeChar.getTarget().getObjectId())) {
            activeChar.sendMessage(msgUsage);
            return false;
        }
        activeChar.sendMessage("New Birthday for " + activeChar.getTarget().getName() + ": " + date);
        activeChar.getTarget().getPlayer().sendMessage("Admin changed your birthday to: " + date);
    } else if (fullString.startsWith("admin_give_item")) {
        if (wordList.length < 3) {
            activeChar.sendMessage("Usage: //give_item id count <target>");
            return false;
        }
        int id = Integer.parseInt(wordList[1]);
        int count = Integer.parseInt(wordList[2]);
        if ((id < 1) || (count < 1) || (activeChar.getTarget() == null) || !activeChar.getTarget().isPlayer()) {
            activeChar.sendMessage("Usage: //give_item id count <target>");
            return false;
        }
        ItemFunctions.addItem(activeChar.getTarget().getPlayer(), id, count, true);
    } else if (fullString.startsWith("admin_add_bang")) {
        if (!Config.ALT_PCBANG_POINTS_ENABLED) {
            activeChar.sendMessage("Error! Pc Bang Points service disabled!");
            return true;
        }
        if (wordList.length < 1) {
            activeChar.sendMessage("Usage: //add_bang count <target>");
            return false;
        }
        int count = Integer.parseInt(wordList[1]);
        if ((count < 1) || (activeChar.getTarget() == null) || !activeChar.getTarget().isPlayer()) {
            activeChar.sendMessage("Usage: //add_bang count <target>");
            return false;
        }
        Player target = activeChar.getTarget().getPlayer();
        target.addPcBangPoints(count, false);
        activeChar.sendMessage("You have added " + count + " Pc Bang Points to " + target.getName());
    } else if (fullString.startsWith("admin_set_bang")) {
        if (!Config.ALT_PCBANG_POINTS_ENABLED) {
            activeChar.sendMessage("Error! Pc Bang Points service disabled!");
            return true;
        }
        if (wordList.length < 1) {
            activeChar.sendMessage("Usage: //set_bang count <target>");
            return false;
        }
        int count = Integer.parseInt(wordList[1]);
        if ((count < 1) || (activeChar.getTarget() == null) || !activeChar.getTarget().isPlayer()) {
            activeChar.sendMessage("Usage: //set_bang count <target>");
            return false;
        }
        Player target = activeChar.getTarget().getPlayer();
        target.setPcBangPoints(count);
        target.sendMessage("Your Pc Bang Points count is now " + count);
        target.sendPacket(new ExPCCafePointInfo(target, count, 1, 2, 12));
        activeChar.sendMessage("You have set " + target.getName() + "'s Pc Bang Points to " + count);
    } else if (fullString.startsWith("admin_reset_mentor_penalty")) {
        if (activeChar.getTarget().getPlayer() == null) {
            activeChar.sendMessage("You have no target selected.");
            return false;
        }
        if (Mentoring.getTimePenalty(activeChar.getTargetId()) > 0) {
            Mentoring.setTimePenalty(activeChar.getTargetId(), 0, -1);
            activeChar.getTarget().getPlayer().sendMessage("Your mentor penalty has been lifted by a GM.");
            activeChar.sendMessage(
                    activeChar.getTarget().getPlayer().getName() + "'s mentor penalty has been lifted.");
        } else {
            activeChar.sendMessage("The selected character has no penalty.");
            return false;
        }
    }
    return true;
}

From source file:it.eng.spagobi.engines.chart.bo.charttypes.barcharts.StackedBar.java

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

    if (confParameters.get(ORIENTATION) != null) {
        String orientation = (String) confParameters.get(ORIENTATION);
        if (orientation.equalsIgnoreCase("vertical")) {
            horizontalViewConfigured = true;
            horizontalView = false;/*from   ww w. java2 s. c  om*/
        } else if (orientation.equalsIgnoreCase("horizontal")) {
            horizontalViewConfigured = true;
            horizontalView = true;
        }
    }

    if (confParameters.get(CUMULATIVE) != null) {
        String orientation = (String) confParameters.get(CUMULATIVE);
        if (orientation.equalsIgnoreCase("true")) {
            cumulative = true;
        } else {
            cumulative = false;
        }
    }

    if (confParameters.get(ADD_LABELS) != null) {
        String additional = (String) confParameters.get(ADD_LABELS);
        if (additional.equalsIgnoreCase("true")) {
            additionalLabels = true;
            catSerLabels = new HashMap();
        } else
            additionalLabels = false;
    } else {
        additionalLabels = false;
    }

    if (confParameters.get(MAKE_PERCENTAGE) != null) {
        String perc = (String) confParameters.get(MAKE_PERCENTAGE);
        if (perc.equalsIgnoreCase("true")) {
            makePercentage = true;
        } else
            makePercentage = false;
    } else {
        makePercentage = false;
    }

    if (confParameters.get(PERCENTAGE_VALUE) != null) {
        String perc = (String) confParameters.get(PERCENTAGE_VALUE);
        if (perc.equalsIgnoreCase("true")) {
            percentageValue = true;
        } else
            percentageValue = false;
    } else {
        percentageValue = false;
    }

    SourceBean drillSB = (SourceBean) content.getAttribute("DRILL");
    if (drillSB == null) {
        drillSB = (SourceBean) content.getAttribute("CONF.DRILL");
    }
    if (drillSB != null) {
        String lab = (String) drillSB.getAttribute("document");
        if (lab != null)
            drillLabel = lab;
        else {
            logger.error("Drill label not found");
        }

        List parameters = drillSB.getAttributeAsList("PARAM");
        if (parameters != null) {
            drillParametersMap = new HashMap<String, DrillParameter>();

            for (Iterator iterator = parameters.iterator(); iterator.hasNext();) {
                SourceBean att = (SourceBean) iterator.next();
                String name = (String) att.getAttribute("name");
                String type = (String) att.getAttribute("type");
                String value = (String) att.getAttribute("value");

                // default is relative
                if (type != null && type.equalsIgnoreCase("absolute"))
                    type = "absolute";
                else
                    type = "relative";

                //               if(type!=null && type.equalsIgnoreCase("RELATIVE")){ // Case relative
                //               if(value.equalsIgnoreCase("serie"))serieUrlname=name;            // ?????????????'''
                //               if(value.equalsIgnoreCase("category"))categoryUrlName=name;
                //               }

                //               else{                                    // Case absolute
                //               drillParameter.put(name, value);
                //               }

                if (name.equalsIgnoreCase("seriesurlname"))
                    serieUrlname = value;
                else if (name.equalsIgnoreCase("target")) {
                    if (value != null && value.equalsIgnoreCase("tab")) {
                        setTarget("tab");
                    } else {
                        setTarget("self");
                    }
                } else if (name.equalsIgnoreCase("title")) {
                    if (value != null && !value.equals("")) {
                        setDrillDocTitle(value);
                    }
                } else if (name.equalsIgnoreCase("categoryurlname"))
                    categoryUrlName = value;
                else {
                    if (this.getParametersObject().get(name) != null) {
                        value = (String) getParametersObject().get(name);
                    }

                    DrillParameter drillPar = new DrillParameter(name, type, value);
                    drillParametersMap.put(name, drillPar);
                }

            }
        }
    }
    //reading series colors if present
    SourceBean colors = (SourceBean) content.getAttribute("SERIES_COLORS");
    if (colors == null) {
        colors = (SourceBean) content.getAttribute("CONF.SERIES_COLORS");
    }
    if (colors != null) {
        colorMap = new HashMap();
        List atts = colors.getContainedAttributes();
        String colorSerie = "";
        for (Iterator iterator = atts.iterator(); iterator.hasNext();) {
            SourceBeanAttribute object = (SourceBeanAttribute) iterator.next();

            String serieName = new String(object.getKey());
            // I put the serieName if rinominated
            String nameRinominated = (seriesLabelsMap != null && seriesLabelsMap.containsKey(serieName))
                    ? seriesLabelsMap.get(serieName).toString()
                    : serieName;

            colorSerie = new String((String) object.getValue());
            Color col = new Color(Integer.decode(colorSerie).intValue());
            if (col != null) {
                colorMap.put(nameRinominated, col);
            }
        }

    }
    logger.debug("OUT");
}