Refine search
public static String collapse(String text) { return collapse( (CharSequence)text ).toString(); }
/** * Returns true if the specified string is all whitespace. */ public static boolean isWhiteSpace(CharSequence s) { for( int i=s.length()-1; i>=0; i-- ) if(!isWhiteSpace(s.charAt(i))) return false; return true; }
public static String replace(String text) { return replace( (CharSequence)text ).toString(); }
public static long _parseLong(CharSequence s) { return Long.parseLong(removeOptionalPlus(WhiteSpaceProcessor.trim(s)).toString()); }
public static double _parseDouble(CharSequence _val) { String val = WhiteSpaceProcessor.trim(_val).toString(); if (val.equals("NaN")) { return Double.NaN; } if (val.equals("INF")) { return Double.POSITIVE_INFINITY; } if (val.equals("-INF")) { return Double.NEGATIVE_INFINITY; } if (val.length() == 0 || !isDigitOrPeriodOrSign(val.charAt(0)) || !isDigitOrPeriodOrSign(val.charAt(val.length() - 1))) { throw new NumberFormatException(val); } // these screening process is necessary due to the wobble of Float.valueOf method return Double.parseDouble(val); }
public File parse(CharSequence text) { return new File(WhiteSpaceProcessor.trim(text).toString()); } public String print(File v) {
public static GregorianCalendar _parseDateTime(CharSequence s) { String val = WhiteSpaceProcessor.trim(s).toString(); return getDatatypeFactory().newXMLGregorianCalendar(val).toGregorianCalendar(); }
/** * @since 2.0 */ public static CharSequence replace(CharSequence text) { int i=text.length()-1; // look for the first whitespace char. while( i>=0 && !isWhiteSpaceExceptSpace(text.charAt(i)) ) i--; if( i<0 ) // no such whitespace. replace(text)==text. return text; // we now know that we need to modify the text. // allocate a char array to do it. StringBuilder buf = new StringBuilder(text); buf.setCharAt(i--,' '); for( ; i>=0; i-- ) if( isWhiteSpaceExceptSpace(buf.charAt(i))) buf.setCharAt(i,' '); return new String(buf); }
public static BigInteger _parseInteger(CharSequence s) { return new BigInteger(removeOptionalPlus(WhiteSpaceProcessor.trim(s)).toString()); }
public static float _parseFloat(CharSequence _val) { String s = WhiteSpaceProcessor.trim(_val).toString(); || !isDigitOrPeriodOrSign(s.charAt(0)) || !isDigitOrPeriodOrSign(s.charAt(s.length() - 1))) { throw new NumberFormatException();
public static BigDecimal _parseDecimal(CharSequence content) { content = WhiteSpaceProcessor.trim(content); if (content.length() <= 0) { return null; } return new BigDecimal(content.toString()); // from purely XML Schema perspective, // this implementation has a problem, since // in xs:decimal "1.0" and "1" is equal whereas the above // code will return different values for those two forms. // // the code was originally using com.sun.msv.datatype.xsd.NumberType.load, // but a profiling showed that the process of normalizing "1.0" into "1" // could take non-trivial time. // // also, from the user's point of view, one might be surprised if // 1 (not 1.0) is returned from "1.000" }
public static GregorianCalendar _parseDateTime(CharSequence s) { String val = WhiteSpaceProcessor.trim(s).toString(); return getDatatypeFactory().newXMLGregorianCalendar(val).toGregorianCalendar(); }
/** * @since 2.0 */ public static CharSequence replace(CharSequence text) { int i=text.length()-1; // look for the first whitespace char. while( i>=0 && !isWhiteSpaceExceptSpace(text.charAt(i)) ) i--; if( i<0 ) // no such whitespace. replace(text)==text. return text; // we now know that we need to modify the text. // allocate a char array to do it. StringBuilder buf = new StringBuilder(text); buf.setCharAt(i--,' '); for( ; i>=0; i-- ) if( isWhiteSpaceExceptSpace(buf.charAt(i))) buf.setCharAt(i,' '); return new String(buf); }
/** * Equivalent of {@link String#trim()}. * @since 2.0 */ public static CharSequence trim(CharSequence text) { int len = text.length(); int start = 0; while( start<len && isWhiteSpace(text.charAt(start)) ) start++; int end = len-1; while( end>start && isWhiteSpace(text.charAt(end)) ) end--; if(start==0 && end==len-1) return text; // no change else return text.subSequence(start,end+1); }
public static String collapse(String text) { return collapse( (CharSequence)text ).toString(); }
public static String replace(String text) { return replace( (CharSequence)text ).toString(); }
public static BigInteger _parseInteger(CharSequence s) { return new BigInteger(removeOptionalPlus(WhiteSpaceProcessor.trim(s)).toString()); }
public static double _parseDouble(CharSequence _val) { String val = WhiteSpaceProcessor.trim(_val).toString(); if (val.equals("NaN")) { return Double.NaN; } if (val.equals("INF")) { return Double.POSITIVE_INFINITY; } if (val.equals("-INF")) { return Double.NEGATIVE_INFINITY; } if (val.length() == 0 || !isDigitOrPeriodOrSign(val.charAt(0)) || !isDigitOrPeriodOrSign(val.charAt(val.length() - 1))) { throw new NumberFormatException(val); } // these screening process is necessary due to the wobble of Float.valueOf method return Double.parseDouble(val); }
public UUID parse(CharSequence text) throws SAXException { TODO.checkSpec("JSR222 Issue #42"); try { return UUID.fromString(WhiteSpaceProcessor.trim(text).toString()); } catch (IllegalArgumentException e) { UnmarshallingContext.getInstance().handleError(e); return null; } }
private void processBufferedText(boolean ignorable) throws SAXException { if (!ignorable || !WhiteSpaceProcessor.isWhiteSpace(buffer)) { visitor.text(buffer); textReported = true; } }