List of usage examples for org.apache.commons.lang3 StringUtils EMPTY
String EMPTY
To view the source code for org.apache.commons.lang3 StringUtils EMPTY.
Click Source Link
From source file:lineage2.gameserver.data.xml.parser.WeaponItemParser.java
/** * Method readData./*from w ww . j a va2 s.c o m*/ * @param rootElement org.dom4j.Element * @throws Exception */ @Override protected void readData(org.dom4j.Element rootElement) throws Exception { for (Iterator<org.dom4j.Element> itemIterator = rootElement.elementIterator(); itemIterator.hasNext();) { org.dom4j.Element itemElement = itemIterator.next(); StatsSet set = new StatsSet(); set.set("item_id", itemElement.attributeValue("id")); set.set("name", itemElement.attributeValue("name")); set.set("add_name", itemElement.attributeValue("add_name", StringUtils.EMPTY)); int slot = 0; for (Iterator<org.dom4j.Element> subIterator = itemElement.elementIterator(); subIterator.hasNext();) { org.dom4j.Element subElement = subIterator.next(); String subName = subElement.getName(); if (subName.equalsIgnoreCase("set")) { set.set(subElement.attributeValue("name"), subElement.attributeValue("value")); } else if (subName.equalsIgnoreCase("equip")) { for (Iterator<org.dom4j.Element> slotIterator = subElement.elementIterator(); slotIterator .hasNext();) { org.dom4j.Element slotElement = slotIterator.next(); Bodypart bodypart = Bodypart.valueOf(slotElement.attributeValue("id")); if (bodypart.getReal() != null) { slot = bodypart.mask(); } else { slot |= bodypart.mask(); } } } } set.set("bodypart", slot); ItemTemplate template = null; try { if (itemElement.getName().equalsIgnoreCase("weapon")) { if (!set.containsKey("class")) { if ((slot & ItemTemplate.SLOT_L_HAND) > 0) { set.set("class", ItemTemplate.ItemClass.ARMOR); } else { set.set("class", ItemTemplate.ItemClass.WEAPON); } } template = new WeaponTemplate(set); } } catch (Exception e) { warn("Fail create item: " + set.get("item_id"), e); continue; } for (Iterator<org.dom4j.Element> subIterator = itemElement.elementIterator(); subIterator.hasNext();) { org.dom4j.Element subElement = subIterator.next(); String subName = subElement.getName(); if (subName.equalsIgnoreCase("for")) { parseFor(subElement, template); } else if (subName.equalsIgnoreCase("triggers")) { parseTriggers(subElement, template); } else if (subName.equalsIgnoreCase("skills")) { for (Iterator<org.dom4j.Element> nextIterator = subElement.elementIterator(); nextIterator .hasNext();) { org.dom4j.Element nextElement = nextIterator.next(); int id = Integer.parseInt(nextElement.attributeValue("id")); int level = Integer.parseInt(nextElement.attributeValue("level")); Skill skill = SkillTable.getInstance().getInfo(id, level); if (skill != null) { template.attachSkill(skill); } else { info("Skill not found(" + id + "," + level + ") for item:" + set.getObject("item_id") + "; file:" + getCurrentFileName()); } } } else if (subName.equalsIgnoreCase("enchant4_skill")) { int id = Integer.parseInt(subElement.attributeValue("id")); int level = Integer.parseInt(subElement.attributeValue("level")); Skill skill = SkillTable.getInstance().getInfo(id, level); if (skill != null) { template.setEnchant4Skill(skill); } } else if (subName.equalsIgnoreCase("unequip_skill")) { int id = Integer.parseInt(subElement.attributeValue("id")); int level = Integer.parseInt(subElement.attributeValue("level")); Skill skill = SkillTable.getInstance().getInfo(id, level); if (skill != null) { template.setUnequipeSkill(skill); } } else if (subName.equalsIgnoreCase("cond")) { Condition condition = parseFirstCond(subElement); if (condition != null) { int msgId = parseNumber(subElement.attributeValue("msgId")).intValue(); condition.setSystemMsg(msgId); template.setCondition(condition); } } else if (subName.equalsIgnoreCase("attributes")) { int[] attributes = new int[6]; for (Iterator<org.dom4j.Element> nextIterator = subElement.elementIterator(); nextIterator .hasNext();) { org.dom4j.Element nextElement = nextIterator.next(); Element element; if (nextElement.getName().equalsIgnoreCase("attribute")) { element = Element.getElementByName(nextElement.attributeValue("element")); attributes[element.getId()] = Integer.parseInt(nextElement.attributeValue("value")); } } template.setBaseAtributeElements(attributes); } else if (subName.equalsIgnoreCase("enchant_options")) { for (Iterator<org.dom4j.Element> nextIterator = subElement.elementIterator(); nextIterator .hasNext();) { org.dom4j.Element nextElement = nextIterator.next(); if (nextElement.getName().equalsIgnoreCase("level")) { int val = Integer.parseInt(nextElement.attributeValue("val")); int i = 0; int[] options = new int[3]; for (org.dom4j.Element optionElement : nextElement.elements()) { OptionDataTemplate optionData = OptionDataHolder.getInstance() .getTemplate(Integer.parseInt(optionElement.attributeValue("id"))); if (optionData == null) { error("Not found option_data for id: " + optionElement.attributeValue("id") + "; item_id: " + set.get("item_id")); continue; } options[i++] = optionData.getId(); } template.addEnchantOptions(val, options); } } } } getHolder().addItem(template); } }
From source file:gobblin.writer.partitioner.TimeBasedWriterPartitioner.java
private static String getWriterPartitionPrefix(State state, int numBranches, int branchId) { String propName = ForkOperatorUtils.getPropertyNameForBranch(WRITER_PARTITION_PREFIX, numBranches, branchId);/* w w w. j av a2 s .co m*/ return state.getProp(propName, StringUtils.EMPTY); }
From source file:info.magnolia.ui.form.field.transformer.composite.SwitchableTransformer.java
@Override protected String getCompositePropertyName(String propertyName) { if (StringUtils.equals(propertyName, propertyPrefix)) { propertyName = StringUtils.EMPTY; }//from w w w . ja v a2 s.com return super.getCompositePropertyName(propertyName); }
From source file:de.jcup.egradle.codeassist.RelevantCodeCutter.java
private String getRightText(String code, int offset) { char[] chars = code.toCharArray(); if (chars.length <= offset) { return StringUtils.EMPTY; }/*from ww w .j av a 2s .co m*/ StringBuilder sb = new StringBuilder(); for (int i = offset; i < chars.length; i++) { char c = chars[i]; if (isDelimiter(c)) { break; } sb.append(c); } String data = StringUtils.removeEndIgnoreCase(sb.toString(), "\r"); return data; }
From source file:de.micromata.genome.logging.spi.FileLogConfigurationDAOImpl.java
@Override protected void buildPattern() { Properties p = loadProperties(); if (p == null) { return;/* ww w. j a va2 s .c om*/ } List<Pair<String, Integer>> npattern = new ArrayList<>(); for (Map.Entry<Object, Object> me : p.entrySet()) { String pattern = Objects.toString(me.getKey(), StringUtils.EMPTY); String v = Objects.toString(me.getValue(), StringUtils.EMPTY); LogLevel ll = LogLevel.valueOf(v); int ilev = ll.getLevel(); if (pattern.equals(THRESHOLD_NAME) == true) { setMaxThreshold(ilev); } else { npattern.add(new Pair<String, Integer>(pattern, ilev)); } } Collections.sort(npattern, new Comparator<Pair<String, Integer>>() { /** * @param o1 the object1 * @param o2 the object2 * @return the compare result */ @Override public int compare(Pair<String, Integer> o1, Pair<String, Integer> o2) { return o2.getFirst().length() - o1.getFirst().length(); } }); List<Pair<Matcher<String>, Integer>> ncpattern = new ArrayList<Pair<Matcher<String>, Integer>>(); for (Pair<String, Integer> pp : npattern) { ncpattern.add(new Pair<Matcher<String>, Integer>(matcherFactory.createMatcher(pp.getFirst()), pp.getSecond())); } synchronized (this) { pattern = ncpattern; } }
From source file:cgeo.geocaching.connector.AbstractConnector.java
@Override @NonNull public String getLicenseText(@NonNull final Geocache cache) { return StringUtils.EMPTY; }
From source file:de.blizzy.backup.database.Database.java
private void open(File folder, Collection<IStorageInterceptor> storageInterceptors) throws SQLException { if (conn == null) { try {/* www . jav a2s . c o m*/ if (!folder.exists()) { FileUtils.forceMkdir(folder); } try { Class.forName("org.h2.Driver"); //$NON-NLS-1$ } catch (ClassNotFoundException e) { throw new RuntimeException(e); } StringBuilder paramsBuf = new StringBuilder("CACHE_SIZE=65536"); //$NON-NLS-1$ String password = StringUtils.EMPTY; for (IStorageInterceptor interceptor : storageInterceptors) { if (interceptor instanceof IDatabaseModifyingStorageInterceptor) { IDatabaseModifyingStorageInterceptor i = (IDatabaseModifyingStorageInterceptor) interceptor; paramsBuf.append(";").append(i.getDatabaseParameters()); //$NON-NLS-1$ password = i.getDatabasePassword() + " " + password; //$NON-NLS-1$ } } conn = DriverManager.getConnection("jdbc:h2:" + folder.getAbsolutePath() + "/backup" + //$NON-NLS-1$ //$NON-NLS-2$ ";" + paramsBuf.toString(), //$NON-NLS-1$ "sa", password); //$NON-NLS-1$ conn.setAutoCommit(true); factory = new Factory(conn, SQLDialect.MYSQL); } catch (IOException e) { throw new RuntimeException(e); } } }
From source file:com.adobe.acs.commons.reports.internal.datasources.DynamicSelectDataSourceTest.java
@Before public void setup() throws Exception { log.info("setup method"); resourceList = new ArrayList(); resourceList.add(resource);/*from w w w . j a v a2 s . c o m*/ when(request.getResourceResolver()).thenReturn(resourceResolver); when(request.getResource()).thenReturn(resource); when(resource.getValueMap()).thenReturn(valueMap); when(valueMap.get(servlet.PN_DROP_DOWN_QUERY_LANGUAGE, javax.jcr.query.Query.JCR_SQL2)) .thenReturn(javax.jcr.query.Query.JCR_SQL2); when(valueMap.get(servlet.PN_DROP_DOWN_QUERY, String.class)).thenReturn(queryStatement); when(valueMap.get(servlet.PN_ALLOW_PROPERTY_NAMES, new String[0])).thenReturn(new String[] { "jcr:title" }); when(queryHelper.findResources(resourceResolver, javax.jcr.query.Query.JCR_SQL2, queryStatement, StringUtils.EMPTY)).thenReturn(resourceList); }
From source file:lineage2.gameserver.data.xml.parser.ItemParser.java
/** * Method readData.//w ww . ja va2 s . c o m * @param rootElement org.dom4j.Element * @throws Exception */ @Override protected void readData(org.dom4j.Element rootElement) throws Exception { for (Iterator<org.dom4j.Element> itemIterator = rootElement.elementIterator(); itemIterator.hasNext();) { org.dom4j.Element itemElement = itemIterator.next(); StatsSet set = new StatsSet(); set.set("item_id", itemElement.attributeValue("id")); set.set("name", itemElement.attributeValue("name")); set.set("add_name", itemElement.attributeValue("add_name", StringUtils.EMPTY)); int slot = 0; for (Iterator<org.dom4j.Element> subIterator = itemElement.elementIterator(); subIterator.hasNext();) { org.dom4j.Element subElement = subIterator.next(); String subName = subElement.getName(); if (subName.equalsIgnoreCase("set")) { set.set(subElement.attributeValue("name"), subElement.attributeValue("value")); } else if (subName.equalsIgnoreCase("equip")) { for (Iterator<org.dom4j.Element> slotIterator = subElement.elementIterator(); slotIterator .hasNext();) { org.dom4j.Element slotElement = slotIterator.next(); Bodypart bodypart = Bodypart.valueOf(slotElement.attributeValue("id")); if (bodypart.getReal() != null) { slot = bodypart.mask(); } else { slot |= bodypart.mask(); } } } } set.set("bodypart", slot); ItemTemplate template = null; try { if (itemElement.getName().equalsIgnoreCase("armor")) { if (!set.containsKey("class")) { if ((slot & ItemTemplate.SLOTS_ARMOR) > 0) { set.set("class", ItemTemplate.ItemClass.ARMOR); } else if ((slot & ItemTemplate.SLOTS_JEWELRY) > 0) { set.set("class", ItemTemplate.ItemClass.JEWELRY); } else { set.set("class", ItemTemplate.ItemClass.ACCESSORY); } } template = new ArmorTemplate(set); } else if (itemElement.getName().equalsIgnoreCase("weapon")) { if (!set.containsKey("class")) { if ((slot & ItemTemplate.SLOT_L_HAND) > 0) { set.set("class", ItemTemplate.ItemClass.ARMOR); } else { set.set("class", ItemTemplate.ItemClass.WEAPON); } } template = new WeaponTemplate(set); } else { template = new EtcItemTemplate(set); } } catch (Exception e) { warn("Fail create item: " + set.get("item_id"), e); continue; } for (Iterator<org.dom4j.Element> subIterator = itemElement.elementIterator(); subIterator.hasNext();) { org.dom4j.Element subElement = subIterator.next(); String subName = subElement.getName(); if (subName.equalsIgnoreCase("for")) { parseFor(subElement, template); } else if (subName.equalsIgnoreCase("triggers")) { parseTriggers(subElement, template); } else if (subName.equalsIgnoreCase("skills")) { for (Iterator<org.dom4j.Element> nextIterator = subElement.elementIterator(); nextIterator .hasNext();) { org.dom4j.Element nextElement = nextIterator.next(); int id = Integer.parseInt(nextElement.attributeValue("id")); int level = Integer.parseInt(nextElement.attributeValue("level")); Skill skill = SkillTable.getInstance().getInfo(id, level); if (skill != null) { template.attachSkill(skill); } else { info("Skill not found(" + id + "," + level + ") for item:" + set.getObject("item_id") + "; file:" + getCurrentFileName()); } } } else if (subName.equalsIgnoreCase("enchant4_skill")) { int id = Integer.parseInt(subElement.attributeValue("id")); int level = Integer.parseInt(subElement.attributeValue("level")); Skill skill = SkillTable.getInstance().getInfo(id, level); if (skill != null) { template.setEnchant4Skill(skill); } } else if (subName.equalsIgnoreCase("unequip_skill")) { int id = Integer.parseInt(subElement.attributeValue("id")); int level = Integer.parseInt(subElement.attributeValue("level")); Skill skill = SkillTable.getInstance().getInfo(id, level); if (skill != null) { template.setUnequipeSkill(skill); } } else if (subName.equalsIgnoreCase("cond")) { Condition condition = parseFirstCond(subElement); if (condition != null) { int msgId = parseNumber(subElement.attributeValue("msgId")).intValue(); condition.setSystemMsg(msgId); template.setCondition(condition); } } else if (subName.equalsIgnoreCase("attributes")) { int[] attributes = new int[6]; for (Iterator<org.dom4j.Element> nextIterator = subElement.elementIterator(); nextIterator .hasNext();) { org.dom4j.Element nextElement = nextIterator.next(); Element element; if (nextElement.getName().equalsIgnoreCase("attribute")) { element = Element.getElementByName(nextElement.attributeValue("element")); attributes[element.getId()] = Integer.parseInt(nextElement.attributeValue("value")); } } template.setBaseAtributeElements(attributes); } else if (subName.equalsIgnoreCase("enchant_options")) { for (Iterator<org.dom4j.Element> nextIterator = subElement.elementIterator(); nextIterator .hasNext();) { org.dom4j.Element nextElement = nextIterator.next(); if (nextElement.getName().equalsIgnoreCase("level")) { int val = Integer.parseInt(nextElement.attributeValue("val")); int i = 0; int[] options = new int[3]; for (org.dom4j.Element optionElement : nextElement.elements()) { OptionDataTemplate optionData = OptionDataHolder.getInstance() .getTemplate(Integer.parseInt(optionElement.attributeValue("id"))); if (optionData == null) { error("Not found option data for id: " + optionElement.attributeValue("id") + "; item_id: " + set.get("item_id")); continue; } options[i++] = optionData.getId(); } template.addEnchantOptions(val, options); } } } } getHolder().addItem(template); } }
From source file:com.muk.services.util.GoogleOAuthService.java
@Override public String authorizeRequest(String scope, String privateKeyAlias, String serviceAccount) { final Cache cache = cacheManager.getCache(ServiceConstants.CacheNames.externalTokenCache); final ValueWrapper valueWrapper = cache.get(CACHE_KEY); String token = StringUtils.EMPTY; if (valueWrapper == null || valueWrapper.get() == null) { final String jwt = createClaim(scope, privateKeyAlias, serviceAccount); token = requestAccessToken(jwt); cache.put(CACHE_KEY, token);/*from www. j a v a2 s. c om*/ } else { token = (String) valueWrapper.get(); } return token; }