/** * Returns TRUE if the passed in text is either a NULL value or is an empty string. * * @param text The string to be evaluated. */ public static boolean isNullOrEmpty(StringBuilder text) { return (text == null) || isNullOrEmpty(text.toString()); }
/** * Creates GameLog named * * @filename */ public GameLog(String filename) { try { File logDir = new File(LOG_DIR); if (!logDir.exists()) { logDir.mkdir(); } // maxFilesize = maxSize; if (PreferenceManager.getClientPreferences().stampFilenames()) { filename = StringUtil.addDateTimeStamp(filename); } logfile = new File(LOG_DIR + File.separator + filename); // writer = new BufferedWriter(new FileWriter(LOG_DIR + // File.separator + filename, append)); writer = new BufferedWriter(new FileWriter(logfile)); append("Log file opened " + new Date().toString()); //$NON-NLS-1$ } catch (IOException ex) { writer = null; System.err.println("GameLog:" + ex.getMessage()); } }
public String verify(String value) { String result = notNullOrEmpty.verify(value); if (result != null) { return result; } if (!StringUtil.isInteger(value)) { return value + " is not an integer."; } return null; } }
public static String makeLength(String s, int n) { return makeLength(s, n, false); }
public String verify(String value) { String result = notNullOrEmpty.verify(value); if (result != null) { return result; } if (!StringUtil.isPositiveInteger(value)) { return value + " is not a positive integer."; } return null; } }
public HexEntry(IHex hex, String imageFile) { this.hex = hex; filenames = StringUtil.splitString(imageFile, ";"); //$NON-NLS-1$ }
public String verify(String value) { if (StringUtil.isNumeric(value)) { return verify(Double.parseDouble(value)); } return value + " is not a number."; }
/** * @return The text of the field with XML reserved characters properly escaped. */ public String getXmlSafeText() { if (isTextNullOrEmpty()) { return ""; } return StringUtil.makeXmlSafe(getText()); }
.stringComparator()); .stringComparator())); .stringComparator())); names.put(rootName, rootName);
private static String renderArmor(int nArmor, int spaces) { if (nArmor <= 0) { if (1 == spaces) { return "x"; } return "xx"; } return StringUtil.makeLength(String.valueOf(nArmor), spaces, true); }
/** * Remove a unit from the priority target list. * * @param id The ID of the unit to be removed. */ void removePriorityUnit(final String id) { if (!StringUtil.isPositiveInteger(id)) { return; } removePriorityUnit(Integer.parseInt(id)); }
orthos++; Vector<String> filenames = StringUtil.splitString(imageName, ";"); //$NON-NLS-1$ for (String entryFile : filenames) {
/** * @return TRUE if the field's text value is a valid number. */ public boolean isTextNumeric() { if (getText().startsWith("\\+")) { setText(getText().replaceFirst("\\+", "")); } return StringUtil.isNumeric(getText()); }
nameNode.setTextContent(StringUtil.makeXmlSafe(getDescription())); behavior.appendChild(nameNode); for (final String t : getStrategicBuildingTargets()) { final Element targetElement = doc.createElement("target"); targetElement.setTextContent(StringUtil.makeXmlSafe(t)); targetsNode.appendChild(targetElement);
/** * Adds a target that Princess will attempt to move to and attack. * * @param target The target to be added. */ public void addStrategicTarget(final String target) { if (StringUtil.isNullOrEmpty(target)) { return; } strategicBuildingTargets.add(target); }
public static String makeLength(int s, int n) { return makeLength(Integer.toString(s), n, true); }
/** * Add an enemy unit to the priority list. * * @param id The ID of the unit to be added. */ public void addPriorityUnit(final String id) { if (!StringUtil.isPositiveInteger(id)) { return; } addPriorityUnit(Integer.parseInt(id)); }
/** * Saves server entity status data to a local file */ private void saveEntityStatus(String sStatus) { try { String sLogDir = PreferenceManager.getClientPreferences().getLogDirectory(); File logDir = new File(sLogDir); if (!logDir.exists()) { logDir.mkdir(); } String fileName = "entitystatus.txt"; if (PreferenceManager.getClientPreferences().stampFilenames()) { fileName = StringUtil.addDateTimeStamp(fileName); } FileWriter fw = new FileWriter(sLogDir + File.separator + fileName); fw.write(sStatus); fw.flush(); fw.close(); } catch (Exception e) { e.printStackTrace(); } }
Enumeration<String> words = StringUtil.splitString(line, " ").elements();
/** * Returns TRUE if the passed string is a valid number. * * @param number The {@link String} to be evaluated. * @return TRUE if the value can be parsed to a {@link Double} without throwing a {@link NumberFormatException}. */ public static boolean isNumeric(String number) { if (isNullOrEmpty(number)) { return false; } try { Double.parseDouble(number); return true; } catch (NumberFormatException ex) { return false; } //catch (NumberFormatException ex) }