/** * Returns <jk>true</jk> if the specified character is a valid first character for a number. * * @param c The character to test. * @return <jk>true</jk> if the specified character is a valid first character for a number. */ public static boolean isFirstNumberChar(char c) { return firstNumberChars.contains(c); }
/** * Returns <jk>true</jk> if the specified character is a valid first character for a number. * * @param c The character to test. * @return <jk>true</jk> if the specified character is a valid first character for a number. */ public static boolean isFirstNumberChar(char c) { return firstNumberChars.contains(c); }
/** * Returns <jk>true</jk> if the specified character is a valid first character for a number. * * @param c The character to test. * @return <jk>true</jk> if the specified character is a valid first character for a number. */ public static boolean isFirstNumberChar(char c) { return firstNumberChars.contains(c); }
/** * Returns <jk>true</jk> if the specified string contains at least one character in this set. * * @param s The string to test. * @return <jk>true</jk> if the string is not null and contains at least one character in this set. */ public boolean contains(CharSequence s) { if (s == null) return false; for (int i = 0; i < s.length(); i++) if (contains(s.charAt(i))) return true; return false; }
/** * Returns <jk>true</jk> if the specified string contains at least one character in this set. * * @param s The string to test. * @return <jk>true</jk> if the string is not null and contains at least one character in this set. */ public boolean contains(CharSequence s) { if (s == null) return false; for (int i = 0; i < s.length(); i++) if (contains(s.charAt(i))) return true; return false; }
/** * Returns <jk>true</jk> if the specified string contains at least one character in this set. * * @param s The string to test. * @return <jk>true</jk> if the string is not null and contains at least one character in this set. */ public boolean contains(CharSequence s) { if (s == null) return false; for (int i = 0; i < s.length(); i++) if (contains(s.charAt(i))) return true; return false; }
/** * Returns <jk>true</jk> if the specified string contains only characters in this set. * * @param s The string to test. * @return * <jk>true</jk> if the string contains only characters in this set. * <br>Nulls always return <jk>false</jk>. * <br>Blanks always return <jk>true</jk>. */ public boolean containsOnly(String s) { if (s == null) return false; for (int i = 0; i < s.length(); i++) if (! contains(s.charAt(i))) return false; return true; } }
/** * Returns <jk>true</jk> if the specified string contains only characters in this set. * * @param s The string to test. * @return * <jk>true</jk> if the string contains only characters in this set. * <br>Nulls always return <jk>false</jk>. * <br>Blanks always return <jk>true</jk>. */ public boolean containsOnly(String s) { if (s == null) return false; for (int i = 0; i < s.length(); i++) if (! contains(s.charAt(i))) return false; return true; } }
/** * Returns <jk>true</jk> if the specified string contains only characters in this set. * * @param s The string to test. * @return * <jk>true</jk> if the string contains only characters in this set. * <br>Nulls always return <jk>false</jk>. * <br>Blanks always return <jk>true</jk>. */ public boolean containsOnly(String s) { if (s == null) return false; for (int i = 0; i < s.length(); i++) if (! contains(s.charAt(i))) return false; return true; } }
/** * Encodes a <code>application/x-www-form-urlencoded</code> string using <code>UTF-8</code> encoding scheme. * * @param s The string to encode. * @return The encoded string, or <jk>null</jk> if input is <jk>null</jk>. */ public static String encode(String s) { if (s == null) return null; boolean needsEncode = false; for (int i = 0; i < s.length() && ! needsEncode; i++) needsEncode |= (! unencodedChars.contains(s.charAt(i))); if (needsEncode) try { return URLEncoder.encode(s, "UTF-8"); } catch (UnsupportedEncodingException e) {/* Won't happen */} return s; }
/** * Encodes a <code>application/x-www-form-urlencoded</code> string using <code>UTF-8</code> encoding scheme. * * @param s The string to encode. * @return The encoded string, or <jk>null</jk> if input is <jk>null</jk>. */ public static String urlEncode(String s) { if (s == null) return null; boolean needsEncode = false; for (int i = 0; i < s.length() && ! needsEncode; i++) needsEncode |= (! unencodedChars.contains(s.charAt(i))); if (needsEncode) { try { return URLEncoder.encode(s, "UTF-8"); } catch (UnsupportedEncodingException e) {/* Won't happen */} } return s; }
/** * Encodes a <code>application/x-www-form-urlencoded</code> string using <code>UTF-8</code> encoding scheme. * * @param s The string to encode. * @return The encoded string, or <jk>null</jk> if input is <jk>null</jk>. */ public static String urlEncode(String s) { if (s == null) return null; boolean needsEncode = false; for (int i = 0; i < s.length() && ! needsEncode; i++) needsEncode |= (! unencodedChars.contains(s.charAt(i))); if (needsEncode) { try { return URLEncoder.encode(s, "UTF-8"); } catch (UnsupportedEncodingException e) {/* Won't happen */} } return s; }
/** * Encodes a <code>application/x-www-form-urlencoded</code> string using <code>UTF-8</code> encoding scheme. * * @param s The string to encode. * @return The encoded string, or <jk>null</jk> if input is <jk>null</jk>. */ public static String urlEncode(String s) { if (s == null) return null; boolean needsEncode = false; for (int i = 0; i < s.length() && ! needsEncode; i++) needsEncode |= (! unencodedChars.contains(s.charAt(i))); if (needsEncode) { try { return URLEncoder.encode(s, "UTF-8"); } catch (UnsupportedEncodingException e) {/* Won't happen */} } return s; }
private static final boolean isInEscape(int c, ParserReader r, boolean prevIsInEscape) throws Exception { if (c == '~' && ! prevIsInEscape) { c = r.peek(); if (escapedChars.contains(c)) { r.delete(); return true; } } return false; }
private static final boolean isInEscape(int c, ParserReader r, boolean prevIsInEscape) throws Exception { if (c == '~' && ! prevIsInEscape) { c = r.peek(); if (escapedChars.contains(c)) { r.delete(); return true; } } return false; }
private static final boolean isInEscape(int c, ParserReader r, boolean prevIsInEscape) throws Exception { if (c == '~' && ! prevIsInEscape) { c = r.peek(); if (escapedChars.contains(c)) { r.delete(); return true; } } return false; }
private String parseFieldName(ParserReader r) throws Exception { int c = r.peek(); if (c == '\'' || c == '"') return parseString(r); if (isStrict()) throw new ParseException(this, "Unquoted attribute detected."); if (! VALID_BARE_CHARS.contains(c)) throw new ParseException(this, "Could not find the start of the field name."); r.mark(); // Look for whitespace. while (c != -1) { c = r.read(); if (! VALID_BARE_CHARS.contains(c)) { r.unread(); String s = r.getMarked().intern(); return s.equals("null") ? null : s; } } throw new ParseException(this, "Could not find the end of the field name."); }
private String parseFieldName(ParserReader r) throws Exception { int c = r.peek(); if (c == '\'' || c == '"') return parseString(r); if (isStrict()) throw new ParseException(this, "Unquoted attribute detected."); if (! VALID_BARE_CHARS.contains(c)) throw new ParseException(this, "Could not find the start of the field name."); r.mark(); // Look for whitespace. while (c != -1) { c = r.read(); if (! VALID_BARE_CHARS.contains(c)) { r.unread(); String s = r.getMarked().intern(); return s.equals("null") ? null : s; } } throw new ParseException(this, "Could not find the end of the field name."); }
/** * Reads a numeric string from the specified reader. * * @param r The reader to read form. * @return The parsed number string. * @throws Exception */ public static String parseNumberString(ParserReader r) throws Exception { r.mark(); int c = 0; while (true) { c = r.read(); if (c == -1) break; if (! numberChars.contains((char)c)) { r.unread(); break; } } return r.getMarked(); }