@Override public boolean contains(int ch) { return Character.isUnicodeIdentifierPart(ch); } };
/** * Create a valid filename using a name We remove all special characters, spaces, etc. * * @param name * The name to use as a base for the filename * @return a valid filename */ public static String createFilename( String name ) { StringBuilder filename = new StringBuilder(); for ( int i = 0; i < name.length(); i++ ) { char c = name.charAt( i ); if ( Character.isUnicodeIdentifierPart( c ) ) { filename.append( c ); } else if ( Character.isWhitespace( c ) ) { filename.append( '_' ); } } return filename.toString().toLowerCase(); }
&& Character.isUnicodeIdentifierPart(pattern.charAt(i))) { convBuf.append(pattern.charAt(i)); currentLiteral.append(pattern.charAt(i));
public static String createName( String filename ) { if ( Utils.isEmpty( filename ) ) { return filename; } String pureFilename = filenameOnly( filename ); if ( pureFilename.endsWith( ".ktr" ) || pureFilename.endsWith( ".kjb" ) || pureFilename.endsWith( ".xml" ) ) { pureFilename = pureFilename.substring( 0, pureFilename.length() - 4 ); } StringBuilder sb = new StringBuilder(); for ( int i = 0; i < pureFilename.length(); i++ ) { char c = pureFilename.charAt( i ); if ( Character.isUnicodeIdentifierPart( c ) ) { sb.append( c ); } else if ( Character.isWhitespace( c ) ) { sb.append( ' ' ); } else if ( c == '-' ) { sb.append( c ); } } return sb.toString(); }
private KeyWithIndex findKey(final String txt, final int cur) { if (cur <= 0 || Character.isWhitespace(txt.charAt(cur - 1))) { return new KeyWithIndex("", txt.length()); } else { String res = ""; int eos = cur - 1; for (int i = eos; i >= 0; i--) { final boolean isIdentifier = Character.isUnicodeIdentifierPart(txt.charAt(i)) || PARAM_CHAR.charAt(0) == txt.charAt(i); if (isIdentifier) { eos = i; } if (!isIdentifier || i == 0) { res = new String(txt.substring(eos, cur)); break; } } return new KeyWithIndex(res, eos); } }
public boolean isNameChar(int c) { return Character.isUnicodeIdentifierPart(c); }
int break2 = length - maxLength; for (final int lower = (maxLength >> 1); break1 >= lower; break1--) { if (!Character.isUnicodeIdentifierPart(text.charAt(break1))) { break1--; while (break1 >= lower && !Character.isUnicodeIdentifierPart(text.charAt(break1))) { break1--; if (!Character.isUnicodeIdentifierPart(text.charAt(break2))) { break2++; while (break2 < upper && !Character.isUnicodeIdentifierPart(text.charAt(break2))) { break2++;
&& Character.isUnicodeIdentifierPart(pattern.charAt(i))) { convBuf.append(pattern.charAt(i)); currentLiteral.append(pattern.charAt(i));
while (upper < length && Character.isUnicodeIdentifierPart(text.charAt(upper))) { upper++;
boolean isIdentifierChar(char c) { switch ( c ) { case '-': case '.': return true; } return Character.isUnicodeIdentifierPart( c ); }
/** * Returns the index after the last identifier character. */ private static int skipIdentifierPart(final String text, int i) { while (i < text.length()) { final int c = text.codePointAt(i); if (!Character.isUnicodeIdentifierPart(c)) break; i += Character.charCount(c); } return i; }
private int getStart(String string, int end) { int start= end; if (start >= 1 && string.charAt(start - 1) == '$') return start - 1; while ((start != 0) && Character.isUnicodeIdentifierPart(string.charAt(start - 1))) start--; if (start >= 2 && string.charAt(start - 1) == '{' && string.charAt(start - 2) == '$') return start - 2; return end; }
private int getStart(String string, int end) { int start= end; if (start >= 1 && string.charAt(start - 1) == '$') return start - 1; while ((start != 0) && Character.isUnicodeIdentifierPart(string.charAt(start - 1))) start--; if (start >= 2 && string.charAt(start - 1) == '{' && string.charAt(start - 2) == '$') return start - 2; return end; }
/** * Returns {@code true} if the given codepoint is an unicode identifier start or part. */ private static boolean isUnicodeIdentifier(final int codepoint, final boolean part) { return part ? Character.isUnicodeIdentifierPart (codepoint) : Character.isUnicodeIdentifierStart(codepoint); }
private boolean NameChar_sempred(RuleContext _localctx, int predIndex) { switch (predIndex) { case 0: return Character.isUnicodeIdentifierPart(_input.LA(-1)); } return true; } private boolean NameStartChar_sempred(RuleContext _localctx, int predIndex) {
/** * Ensures that the given code point is a valid Unicode code point but not a Unicode identifier part. */ private static void ensureValidQuoteOrBracket(final String name, final int code) { ensureValidUnicodeCodePoint(name, code); if (Character.isUnicodeIdentifierPart(code) || Character.isSpaceChar(code) || code == FRAGMENT_VALUE) { throw new IllegalArgumentException(Errors.format(Errors.Keys.IllegalCharacter_2, name, String.valueOf(Character.toChars(code)))); } }
protected Name readIdentifier() { int start = bp; nextChar(); while (bp < buflen && Character.isUnicodeIdentifierPart(ch)) nextChar(); return names.fromChars(buf, start, bp - start); }
protected Name readTagName() { int start = bp; nextChar(); while (bp < buflen && (Character.isUnicodeIdentifierPart(ch) || ch == '.' || ch == '-' || ch == ':')) { nextChar(); } return names.fromChars(buf, start, bp - start); }
protected Name readIdentifier() { int start = bp; nextChar(); while (bp < buflen && Character.isUnicodeIdentifierPart(ch)) nextChar(); return names.fromChars(buf, start, bp - start); }
protected Name readTagName() { int start = bp; nextChar(); while (bp < buflen && (Character.isUnicodeIdentifierPart(ch) || ch == '.')) nextChar(); return names.fromChars(buf, start, bp - start); }