Package java.text

Examples of java.text.CharacterIterator.first()


        this.add('"');
        if(!matcher.reset(string).find()){
          add(string);
        }else {
          CharacterIterator it = new StringCharacterIterator(string);
          for (char c = it.first(); c != CharacterIterator.DONE; c = it.next()) {
              if (c == '"') {
                  this.add("\\\"");
              } else if (c == '\\') {
                  this.add("\\\\");
              } else if (c == '/') {
View Full Code Here


     * @return The offset of the beginning of the text.
     */
    public int first() {
        CharacterIterator t = getText();

        t.first();
        return t.getIndex();
    }

    /**
     * Sets the current iteration position to the end of the text.
View Full Code Here

        List<Parameter> parameterList = new ArrayList<Parameter>();
        StringBuilder buf = new StringBuilder();

        CharacterIterator sr = new StringCharacterIterator(pattern);

        for (int c = sr.first(); c != CharacterIterator.DONE; c = sr.next()) {
            if (c == '%') {
                int c1 = sr.next();
                if (c1 != '%') {
                    if (buf.length() > 0) {
                        Parameter text = new PlainTextParameter(buf.toString());
View Full Code Here

   public static boolean isClassname( String classname ) {
        if (classname == null || classname.length() ==0) return false;

          CharacterIterator iter = new StringCharacterIterator(classname);
          // 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

    public static String decomposeToBasicLatin(String accentedString)
    {
        StringBuilder unaccentedString = new StringBuilder();
        String normalizedString = Normalizer.normalize(accentedString, Normalizer.Form.NFKD);
        CharacterIterator iterator = new StringCharacterIterator(normalizedString);
        for (char c = iterator.first(); c != CharacterIterator.DONE; c = iterator.next())
            if (decomposedChars.containsKey(c))
                unaccentedString.append(decomposedChars.get(c));
            else if (Character.UnicodeBlock.BASIC_LATIN.equals(Character.UnicodeBlock.of(c)))
                unaccentedString.append(c);
        return unaccentedString.toString();
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

      StringBuilder nextValue = new StringBuilder();

      int valueIndex = 0;

      final CharacterIterator it = new StringCharacterIterator(line);
      for (char c = it.first(); c != CharacterIterator.DONE; c = it
          .next()) {
        nextValue.append(c);

        final int valueWidth;
        if (constantWidth) {
View Full Code Here

        String label = "";
        if (o instanceof CharacterIterator) {
      CharacterIterator iter = (CharacterIterator) o;
      char[] cbuff = new char[iter.getEndIndex()-iter.getBeginIndex()];
      if (cbuff.length > 0) {
          cbuff[0] = iter.first();
      }
      for (int i=1; i<cbuff.length;++i) {
          cbuff[i] = iter.next();
      }
      label = new String(cbuff);
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.