Package java.text

Examples of java.text.StringCharacterIterator.first()


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

        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


    private void string(Object obj) {
        this.add('"');

        CharacterIterator it = new StringCharacterIterator(obj.toString());

        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

    private String escapeJSON(Object obj) {
        StringBuilder sb = new StringBuilder();

        CharacterIterator it = new StringCharacterIterator(obj.toString());

        for (char c = it.first(); c != CharacterIterator.DONE; c = it.next()) {
            if (c == '"') {
                sb.append("\\\"");
            } else if (c == '\\') {
                sb.append("\\\\");
            } else if (c == '/') {
View Full Code Here

        CharacterIterator it = new StringCharacterIterator(colString);
        StringBuffer out = new StringBuffer();
        boolean inAString = false;
        char prevChar = ' ';
        for (char c = it.first(); c != CharacterIterator.DONE; c = it.next()) {
            // Look for string introducor
            if (c == stringDelimiter && prevChar != '\\') {
                inAString = !inAString;
                out.append(stringDelimiter);
            }
View Full Code Here

  int copyTo = 0;
  // it will always be less than the original
  char[] chars = new char[original.length()];
  StringCharacterIterator iter = new StringCharacterIterator(original);
 
  for(char c = iter.first(); c != CharacterIterator.DONE;
      c = iter.next()) {

      if (c == '&') {
    changedString = true;
    copyTo = base64decode(chars, copyTo, iter);
View Full Code Here

    if(str == null)
      return "null";
    StringBuffer sb = new StringBuffer();
    sb.append('"');
        CharacterIterator it = new StringCharacterIterator(str);
        for (char c = it.first(); c != CharacterIterator.DONE; c = it.next()) {
            if (c == '"') sb.append("\\\"");
            else if (c == '\\') sb.append("\\\\");
            else if (c == '\b') sb.append("\\b");
            else if (c == '\f') sb.append("\\f");
            else if (c == '\n') sb.append("\\n");
View Full Code Here

   * @param string text to encode
   * @return number of UTF-8 bytes required to encode
   */
  public static int utf8Length(String string) {
    CharacterIterator iter = new StringCharacterIterator(string);
    char ch = iter.first();
    int size = 0;
    while (ch != CharacterIterator.DONE) {
      if ((ch >= 0xD800) && (ch < 0xDC00)) {
        // surrogate pair?
        char trail = iter.next();
View Full Code Here

    /* This is copied from within javaToJSON() */
    public static String escapePropertyValue(String str){
        String chStr;
        int len;
        StringCharacterIterator it = new StringCharacterIterator(str);
        char ch = it.first();
        StringBuilder builder =  new StringBuilder(str.length() << 2);
        while (ch != StringCharacterIterator.DONE) {
            switch (ch) {
                case '\t':
                    builder.append("\\t");
View Full Code Here

  } else if (obj instanceof String) {
      String chStr;
      int len;
      StringCharacterIterator it =
    new StringCharacterIterator((String) obj);
      char ch = it.first();
      StringBuilder builder =
        new StringBuilder(((String) obj).length() << 2);
      builder.append("\"");
      while (ch != StringCharacterIterator.DONE) {
    switch (ch) {
View Full Code Here

        StringBuffer strb = new StringBuffer(stringToPad);
        StringCharacterIterator sci = new StringCharacterIterator(padder);

        while (strb.length() < size)
        {
            for (char ch = sci.first(); ch != CharacterIterator.DONE; ch = sci.next())
            {
                if (strb.length() < size)
                {
                    strb.append(String.valueOf(ch));
                }
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.