Package java.text

Examples of java.text.StringCharacterIterator.first()


        }

        path = path.replace('\\', '/');

        CharacterIterator iter = new StringCharacterIterator(path);
        for (char c = iter.first(); c != CharacterIterator.DONE;
             c = iter.next()) {
            if (c < 256 && isSpecial[c]) {
                sb.append('%');
                sb.append(escapedChar1[c]);
                sb.append(escapedChar2[c]);
View Full Code Here


   * @return the input string with no bounding whitespace
   */
  protected static String stripBoundingWhitespace(String input) {
    StringBuffer sb = new StringBuffer();
    StringCharacterIterator iter = new StringCharacterIterator(input);
    char c = iter.first();
    while (c != iter.DONE && Character.isWhitespace(c)) {
      c = iter.next();
    }
    int start_offset = iter.getIndex();
    c = iter.last();
View Full Code Here

    }

    public static String replace(String source, char target, String replacement) {
        StringBuffer sb = new StringBuffer();
        StringCharacterIterator iter = new StringCharacterIterator(source);
        for (char c = iter.first(); c != iter.DONE; c = iter.next())
                if (c == target) sb.append(replacement); else sb.append(c);
        return sb.toString();
    }

  public static Element createElement(Document document, String namespace, String name) {
View Full Code Here

    Vector results = new Vector();
    if (source == null) return results;
    StringBuffer sb = new StringBuffer();
    StringCharacterIterator iter = new StringCharacterIterator(source);
    char c;
        for (c = iter.first(); c != iter.DONE; c = iter.next())
      if (c == seperator) {
        results.addElement(sb.toString());
        sb = new StringBuffer();
      } else sb.append(c);
    if (c != seperator) results.addElement(sb.toString());
View Full Code Here

            uri = uri.substring(1);
        }

        StringBuffer sb = new StringBuffer();
        CharacterIterator iter = new StringCharacterIterator(uri);
        for (char c = iter.first(); c != CharacterIterator.DONE;
             c = iter.next()) {
            if (c == '%') {
                char c1 = iter.next();
                if (c1 != CharacterIterator.DONE) {
                    int i1 = Character.digit(c1, 16);
View Full Code Here

     */
    public String encode( String publicName ) {
        if (publicName == null) return null;
        StringBuilder sb = new StringBuilder();
        CharacterIterator iter = new StringCharacterIterator(publicName);
        for (char c = iter.first(); c != CharacterIterator.DONE; c = iter.next()) {
            char mapped = c;
            if (c == '*') {
                mapped = '\uF02A';
            } else if (c == '/') {
                mapped = '\uF02F';
View Full Code Here

     */
    public String decode( String jcrNodeName ) {
        if (jcrNodeName == null) return null;
        StringBuilder sb = new StringBuilder();
        CharacterIterator iter = new StringCharacterIterator(jcrNodeName);
        for (char c = iter.first(); c != CharacterIterator.DONE; c = iter.next()) {
            char mapped = c;
            if (c == '\uF02A') {
                mapped = '*';
            } else if (c == '\uF02F') {
                mapped = '/';
View Full Code Here

        String[] parts = classname.split("[\\.]");
        if (parts.length == 0) return false;
        for (String part : parts) {
            CharacterIterator iter = new StringCharacterIterator(part);
            // Check first character (there should at least be one character for each part) ...
            char c = iter.first();
            if (c == CharacterIterator.DONE) return false;
            if (!Character.isJavaIdentifierStart(c) && !Character.isIdentifierIgnorable(c)) return false;
            c = iter.next();
            // Check the remaining characters, if there are any ...
            while (c != CharacterIterator.DONE) {
View Full Code Here

        if (text == null) return null;
        if (text.length() == 0) return text;
        final BitSet safeChars = isSlashEncoded() ? RFC2396_UNRESERVED_CHARACTERS : RFC2396_UNRESERVED_WITH_SLASH_CHARACTERS;
        final StringBuilder result = new StringBuilder();
        final CharacterIterator iter = new StringCharacterIterator(text);
        for (char c = iter.first(); c != CharacterIterator.DONE; c = iter.next()) {
            if (safeChars.get(c)) {
                // Safe character, so just pass through ...
                result.append(c);
            } else {
                // The character is not a safe character, and must be escaped ...
View Full Code Here

    public String decode( String encodedText ) {
        if (encodedText == null) return null;
        if (encodedText.length() == 0) return encodedText;
        final StringBuilder result = new StringBuilder();
        final CharacterIterator iter = new StringCharacterIterator(encodedText);
        for (char c = iter.first(); c != CharacterIterator.DONE; c = iter.next()) {
            if (c == ESCAPE_CHARACTER) {
                boolean foundEscapedCharacter = false;
                // Found the first character in a potential escape sequence, so grab the next two characters ...
                char hexChar1 = iter.next();
                char hexChar2 = hexChar1 != CharacterIterator.DONE ? iter.next() : CharacterIterator.DONE;
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.