protected Symbol[] getTokenTable() {
    if (tokenTable == null) {
      int maxChar = 0;
      for (Iterator i = charactersToSymbols.keySet().iterator(); i.hasNext(); ) {
        Character c = (Character) i.next();
        char cv = c.charValue();
        if (caseSensitive) {
          maxChar = Math.max(maxChar, cv);
        } else {
          maxChar = Math.max(maxChar, Character.toUpperCase(cv));
          maxChar = Math.max(maxChar, Character.toLowerCase(cv));
        }
      }

      tokenTable = new Symbol[maxChar + 1];

      for (Iterator i = charactersToSymbols.entrySet().iterator(); i.hasNext(); ) {
        Map.Entry me = (Map.Entry) i.next();
        Symbol sym = (Symbol) me.getValue();
        Character c = (Character) me.getKey();
        char cv = c.charValue();
        if (caseSensitive) {
          tokenTable[cv] = sym;
        } else {
          tokenTable[Character.toUpperCase(cv)] = sym;
          tokenTable[Character.toLowerCase(cv)] = sym;
        }
      }
    }

    return tokenTable;
  }
 public void testCharacter() {
   Character c;
   c = 'a';
   assertEquals("CharacterSmall", c.charValue(), 'a');
   c = '\u1000';
   assertEquals("CharacterLarge", c.charValue(), '\u1000');
 }
示例#3
0
  public static void main(String[] args) throws NumberFormatException, IOException {
    BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
    StringBuilder output = new StringBuilder();

    int cases = Integer.parseInt(bf.readLine());
    for (int i = 0; i < cases; i++) {
      String keyPhrase = bf.readLine();
      String text = bf.readLine().replaceAll("\\s+", "");

      Table t = buildTable(keyPhrase);
      int index = 0;
      while (index < text.length()) {
        Character cur = text.charAt(index++);
        Character next = null;
        if (index < text.length()) {
          next = text.charAt(index++);
        }
        if (next != null && cur.charValue() == next.charValue()) {
          index--;
          next = 'x';
        }
        String cypher = process(cur, next, t);
        output.append(cypher.toUpperCase());
      }
      output.append("\n");
    }
    System.out.print(output.toString());
  }
  public ActionForward prepareEditObject(
      ActionMapping mapping,
      ActionForm form,
      HttpServletRequest request,
      HttpServletResponse response)
      throws FenixServiceException, ClassNotFoundException {

    Person person = checkUser();

    String documentIdNumber = person.getDocumentIdNumber();
    DynaActionForm actionForm = (DynaActionForm) form;
    Integer idPos1Index = (Integer) actionForm.get("idPos1Index");
    Integer idPos2Index = (Integer) actionForm.get("idPos2Index");
    Integer idPos3Index = (Integer) actionForm.get("idPos3Index");
    Character idPos1Value = (Character) actionForm.get("idPos1Value");
    Character idPos2Value = (Character) actionForm.get("idPos2Value");
    Character idPos3Value = (Character) actionForm.get("idPos3Value");

    if (documentIdNumber.charAt(idPos1Index - 1) == idPos1Value.charValue()
        && documentIdNumber.charAt(idPos2Index - 1) == idPos2Value.charValue()
        && documentIdNumber.charAt(idPos3Index - 1) == idPos3Value.charValue()) {

      DomainObject object = getDomainObject(actionForm, "classToManageId");

      if (object != null) {
        request.setAttribute("objectToEdit", object);
      }
    } else {
      request.setAttribute("message", "Who the hell are you!?!?!");
    }
    return mapping.findForward("prepareEditObject");
  }
  public ActionForward deleteObject(
      ActionMapping mapping,
      ActionForm form,
      HttpServletRequest request,
      HttpServletResponse response)
      throws FenixServiceException, ClassNotFoundException {

    Person person = checkUser();

    String documentIdNumber = person.getDocumentIdNumber();

    DynaActionForm actionForm = (DynaActionForm) form;
    Integer idPos1Index = (Integer) actionForm.get("idPos1Index");
    Integer idPos2Index = (Integer) actionForm.get("idPos2Index");
    Integer idPos3Index = (Integer) actionForm.get("idPos3Index");
    Character idPos1Value = (Character) actionForm.get("idPos1Value");
    Character idPos2Value = (Character) actionForm.get("idPos2Value");
    Character idPos3Value = (Character) actionForm.get("idPos3Value");

    if (documentIdNumber.charAt(idPos1Index - 1) == idPos1Value.charValue()
        && documentIdNumber.charAt(idPos2Index - 1) == idPos2Value.charValue()
        && documentIdNumber.charAt(idPos3Index - 1) == idPos3Value.charValue()) {

      String classToDelete = (String) actionForm.get("classToManage");
      String classToDeleteId = (String) actionForm.get("classToManageId");

      try {
        DeleteObjectByOID.run(classToDeleteId);
        request.setAttribute(
            "message",
            "Object "
                + classToDelete
                + " with ID:"
                + classToDeleteId
                + " Deleted. God have mercy of your soul...");

      } catch (Exception e) {
        logger.error(e.getMessage(), e);
        request.setAttribute(
            "message", "Error deleting Object " + classToDelete + " with ID:" + classToDeleteId);
      }

    } else {
      request.setAttribute("message", "Who the hell are you!?!?!");
    }

    request.setAttribute("domainClasses", getClasses());
    ((DynaActionForm) form).set("method", "prepareEditObject");
    return mapping.findForward("chooseClassToManage");
  }
示例#6
0
 public static char valueOf(Character c1, char c2) {
   if (null == c1) {
     return c2;
   } else {
     return c1.charValue();
   }
 }
示例#7
0
  /**
   * Convert a reference to a unicode character. Convert a single numeric character reference or
   * character entity reference to a unicode character.
   *
   * @param string The string to convert. Of the form &xxxx; or &amp;#xxxx; with or without the
   *     leading ampersand or trailing semi-colon.
   * @return The converted character or '\0' (zero) if the string is an invalid reference.
   */
  public static char convertToChar(String string) {
    int length;
    Character item;
    char ret;

    ret = 0;

    length = string.length();
    if (0 < length) {
      if ('&' == string.charAt(0)) {
        string = string.substring(1);
        length--;
      }
      if (0 < length) {
        if (';' == string.charAt(length - 1)) string = string.substring(0, --length);
        if (0 < length) {
          if ('#' == string.charAt(0))
            try {
              ret = (char) Integer.parseInt(string.substring(1));
            } catch (NumberFormatException nfe) {
              /* failed conversion, return 0 */
            }
          else {
            item = (Character) refChar.get(string);
            if (null != item) ret = item.charValue();
          }
        }
      }
    }

    return (ret);
  }
  /**
   * Move the cursor <i>where</i> characters, withough checking the current buffer.
   *
   * @see #where
   * @param where the number of characters to move to the right or left.
   */
  private final void moveInternal(final int where) throws IOException {
    // debug ("move cursor " + where + " ("
    // + buf.cursor + " => " + (buf.cursor + where) + ")");
    buf.cursor += where;

    char c;

    if (where < 0) {
      int len = 0;
      for (int i = buf.cursor; i < buf.cursor - where; i++) {
        if (buf.getBuffer().charAt(i) == '\t') len += TAB_WIDTH;
        else len++;
      }

      char cbuf[] = new char[len];
      Arrays.fill(cbuf, BACKSPACE);
      out.write(cbuf);

      return;
    } else if (buf.cursor == 0) {
      return;
    } else if (mask != null) {
      c = mask.charValue();
    } else {
      printCharacters(buf.buffer.substring(buf.cursor - where, buf.cursor).toCharArray());
      return;
    }

    // null character mask: don't output anything
    if (NULL_MASK.equals(mask)) {
      return;
    }

    printCharacters(c, Math.abs(where));
  }
 @Override
 public String apply(final String input) {
   String res = "";
   int i = 0;
   while ((i < input.length())) {
     {
       final char testChar = input.charAt(i);
       final Character _valueOf = Character.valueOf('^');
       final char _charValue = _valueOf.charValue();
       final boolean _tripleNotEquals = (testChar != _charValue);
       if (_tripleNotEquals) {
         final String _res = res;
         res = (_res + Character.valueOf(testChar));
       } else {
         i++;
         final String _res_1 = res;
         final char _charAt = input.charAt(i);
         final char _upperCase = Character.toUpperCase(_charAt);
         res = (_res_1 + Character.valueOf(_upperCase));
       }
       i++;
     }
   }
   return res;
 }
/*      */   public Character put(Float ok, Character ov) {
/*  262 */     char v = ov.charValue();
/*  263 */     float k = ok.floatValue();
/*      */ 
/*  265 */     int pos = HashCommon.murmurHash3(HashCommon.float2int(k)) & this.mask;
/*      */ 
/*  267 */     while (this.used[pos] != 0) {
/*  268 */       if (this.key[pos] == k) {
/*  269 */         Character oldValue = Character.valueOf(this.value[pos]);
/*  270 */         this.value[pos] = v;
/*  271 */         return oldValue;
/*      */       }
/*  273 */       pos = pos + 1 & this.mask;
/*      */     }
/*  275 */     this.used[pos] = true;
/*  276 */     this.key[pos] = k;
/*  277 */     this.value[pos] = v;
/*  278 */     if (this.size == 0) {
/*  279 */       this.first = (this.last = pos);
/*      */ 
/*  281 */       this.link[pos] = -1L;
/*      */     }
/*      */     else {
/*  284 */       this.link[this.last] ^= (this.link[this.last] ^ pos & 0xFFFFFFFF) & 0xFFFFFFFF;
/*  285 */       this.link[pos] = ((this.last & 0xFFFFFFFF) << 32 | 0xFFFFFFFF);
/*  286 */       this.last = pos;
/*      */     }
/*  288 */     if (++this.size >= this.maxFill) rehash(HashCommon.arraySize(this.size + 1, this.f));
/*      */ 
/*  290 */     return null;
/*      */   }
示例#11
0
 /**
  * Encode a UTF-16 character into an ANSEL byte
  *
  * @param c the ANSEL byte (as a char)
  * @return the character (in UTF-16) represented by the byte
  */
 public static char encode(char c) {
   Character b = charToByte.get(Character.valueOf(c));
   if (b != null) {
     return b.charValue();
   }
   return c;
 }
  /*
   IE that can be sent:
   - 8.6.1.   CALLED NUMBER
   - 8.6.2.   CALLING NUMBER
   - 8.6.3.   CALLING ANI
   - 8.6.4.   CALLING NAME
   - 8.6.5.   CALLED CONTEXT
   - 8.6.6.   USERNAME
   - 8.6.8.   CAPABILITY
   - 8.6.9.   FORMAT
   - 8.6.10.  LANGUAGE
   - 8.6.11.  VERSION (MUST, and should be first)
   - 8.6.12.  ADSICPE
   - 8.6.13.  DNID
   - 8.6.25.  AUTOANSWER
   - 8.6.31.  DATETIME
   - 8.6.38.  CALLINGPRES
   - 8.6.39.  CALLINGTON
   - 8.6.43.  ENCRYPTION
   - 8.6.45.  CODEC PREFS
  */
  public void sendNew(
      Character cno, String username, String calledNo, String callingNo, String callingName) {

    Log.debug(
        "ProtocolControlFrameNew.sendNew: calledNo="
            + calledNo
            + ", callingNo="
            + callingNo
            + ", callingName="
            + callingName
            + ", username="******"foobar","724024");
    Log.debug("Sending initial NEW");
    sendMe(ie);
  }
示例#13
0
 /**
  * Returns a cyclified string representation of the given <tt>Object</tt>. Embedded constants are
  * prefixed with "#$".
  *
  * @return a <tt>String</tt> representation in cyclified form.
  */
 public static String cyclify(Object obj) {
   if (obj == null) {
     throw new BaseClientRuntimeException("Cannot cyclify null obj");
   } else if (!isCycLObject(obj)) {
     throw new BaseClientRuntimeException(
         "Cannot cyclify: '" + obj + "' (" + obj.getClass().getName() + ").");
   }
   if (obj instanceof CycObject) {
     return ((CycObject) obj).cyclify();
   }
   if (obj instanceof String) {
     return "\"" + (String) obj + "\"";
   }
   if (obj instanceof Character) {
     // @hack -- do better job of this. Need to support other non-printable characters!!!
     Character theChar = (Character) obj;
     if (theChar == ' ') {
       return "#\\Space";
     } else if (theChar == '\n') {
       return "#\\Newline";
     } else if (theChar == '\r') {
       return "#\\Return";
     } else if (theChar == '\t') {
       return "#\\Tab";
     }
     if (Character.isWhitespace(theChar)) {
       throw new IllegalArgumentException(
           "Don't know how to trasmit the whitespace character: " + (int) theChar.charValue());
     }
     return "#\\" + obj;
   }
   return obj.toString();
 }
 public String getProblemCharacters() {
   StringBuilder chars = new StringBuilder();
   for (Character ch : problemCharacters) {
     chars.append(ch.charValue());
   }
   return chars.toString();
 }
  /** Output the specified character, both to the buffer and the output stream. */
  private final void putChar(final int c, final boolean print) throws IOException {
    buf.write((char) c);

    if (print) {
      // no masking...
      if (mask == null) {
        printCharacter(c);
      }
      // null mask: don't print anything...
      else if (mask.charValue() == 0) {;
      }
      // otherwise print the mask...
      else {
        printCharacter(mask.charValue());
      }

      drawBuffer();
    }
  }
示例#16
0
  /**
   * Verifies the consistency of the parameters and throws an IllegalStateException if necessary.
   *
   * @throws IllegalStateException
   */
  void validate() throws IllegalStateException {
    if (quoteChar != null && delimiter == quoteChar.charValue()) {
      throw new IllegalStateException(
          "The quoteChar character and the delimiter cannot be the same ('" + quoteChar + "')");
    }

    if (escape != null && delimiter == escape.charValue()) {
      throw new IllegalStateException(
          "The escape character and the delimiter cannot be the same ('" + escape + "')");
    }

    if (commentStart != null && delimiter == commentStart.charValue()) {
      throw new IllegalStateException(
          "The comment start character and the delimiter cannot be the same ('"
              + commentStart
              + "')");
    }

    if (quoteChar != null && quoteChar.equals(commentStart)) {
      throw new IllegalStateException(
          "The comment start character and the quoteChar cannot be the same ('"
              + commentStart
              + "')");
    }

    if (escape != null && escape.equals(commentStart)) {
      throw new IllegalStateException(
          "The comment start and the escape character cannot be the same ('" + commentStart + "')");
    }

    if (escape == null && quotePolicy == Quote.NONE) {
      throw new IllegalStateException("No quotes mode set but no escape character is set");
    }

    if (header != null) {
      final Set<String> set = new HashSet<String>(header.length);
      set.addAll(Arrays.asList(header));
      if (set.size() != header.length) {
        throw new IllegalStateException(
            "The header contains duplicate names: " + Arrays.toString(header));
      }
    }
  }
  /**
   * Deal with formatting characters.
   *
   * <p>Parsing is as follows: - Treat all contiguous strings of formatting characters as one block.
   * (This method processes one block.) - Only a single instance of a particular format character
   * within a block is used to determine whether to turn on/off that type of formatting; other
   * instances simply print the character itself. - If the format is to be turned on, we use the
   * _first_ instance; if it is to be turned off, we use the _last_ instance (by appending the
   * format.)
   *
   * <p>Example: **string** turns into <b>*string*</b>
   */
  private boolean parseFormatting() {
    if (!parseFormatting) {
      return false;
    }
    int endChar = nextChar;
    while ((endChar < text.length()) && isFormatChar(text.charAt(endChar))) {
      endChar += 1;
    }

    if ((endChar == nextChar) || !isWordBreak(endChar)) {
      return false;
    }

    // Keeps track of whether we've seen a character (in map if we've seen it)
    // and whether we should append a closing format token (if value in
    // map is TRUE).  Linked hashmap for consistent ordering.
    LinkedHashMap<Character, Boolean> seenCharacters = new LinkedHashMap<Character, Boolean>();

    for (int index = nextChar; index < endChar; ++index) {
      char ch = text.charAt(index);
      Character key = Character.valueOf(ch);
      if (seenCharacters.containsKey(key)) {
        // Already seen this character, just append an unmatched token, which
        // will print plaintext character
        addToken(new Format(ch, false));
      } else {
        Format start = formatStart.get(key);
        if (start != null) {
          // Match the start token, and ask an end token to be appended
          start.setMatched(true);
          formatStart.remove(key);
          seenCharacters.put(key, Boolean.TRUE);
        } else {
          // Append start token
          start = new Format(ch, true);
          formatStart.put(key, start);
          addToken(start);
          seenCharacters.put(key, Boolean.FALSE);
        }
      }
    }

    // Append any necessary end tokens
    for (Character key : seenCharacters.keySet()) {
      if (seenCharacters.get(key) == Boolean.TRUE) {
        Format end = new Format(key.charValue(), false);
        end.setMatched(true);
        addToken(end);
      }
    }

    nextChar = endChar;
    return true;
  }
  /**
   * Redraw the rest of the buffer from the cursor onwards. This is necessary for inserting text
   * into the buffer.
   *
   * @param clear the number of characters to clear after the end of the buffer
   */
  private final void drawBuffer(final int clear) throws IOException {
    // debug ("drawBuffer: " + clear);
    char[] chars = buf.buffer.substring(buf.cursor).toCharArray();
    if (mask != null) Arrays.fill(chars, mask.charValue());

    printCharacters(chars);

    clearAhead(clear);
    back(chars.length);
    flushConsole();
  }
 // replaces whitespace char with replaceWhitespaceWith
 private char[] replaceWhiteSpace(char[] token) {
   char[] replaced = new char[token.length];
   for (int i = 0; i < token.length; i++) {
     if (token[i] == ' ') {
       replaced[i] = replaceWhitespaceWith.charValue();
     } else {
       replaced[i] = token[i];
     }
   }
   return replaced;
 }
  public VisualizeUnicodeNormalization() {
    super("HFS+ Unicode Decomposition Table");
    JPanel mainPanel = new JPanel();
    JScrollPane mainPanelScroller =
        new JScrollPane(
            mainPanel,
            ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED,
            ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
    mainPanel.setLayout(new BoxLayout(mainPanel, BoxLayout.Y_AXIS));
    mainPanelScroller.getVerticalScrollBar().setUnitIncrement(20);

    UnicodeNormalizationToolkit unt = UnicodeNormalizationToolkit.getDefaultInstance();
    Map<Character, char[]> table = unt.getDecompositionTable();

    StringBuilder sb = new StringBuilder();
    Comparator<Map.Entry<Character, char[]>> cmp =
        new Comparator<Map.Entry<Character, char[]>>() {

          public int compare(Map.Entry<Character, char[]> o1, Map.Entry<Character, char[]> o2) {
            return o1.getKey().compareTo(o2.getKey());
          }

          @Override
          public boolean equals(Object obj) {
            return super.equals(obj);
          }
        };
    TreeSet<Map.Entry<Character, char[]>> ts = new TreeSet<Map.Entry<Character, char[]>>(cmp);
    for (Map.Entry<Character, char[]> ent : table.entrySet()) ts.add(ent);
    // ts.addAll(table.entrySet());
    for (Map.Entry<Character, char[]> ent : ts) {
      Character key = ent.getKey();
      char[] value = ent.getValue();
      sb.append(Util.toHexStringBE(key.charValue()));
      sb.append(": \" ");
      sb.append(key.toString());
      sb.append(" \" -> \" ");
      sb.append(value[0]);
      for (int i = 1; i < value.length; ++i) {
        sb.append(" \", \" ");
        sb.append(value[i]);
      }
      sb.append(" \"");
      JLabel cur = new JLabel(sb.toString());
      cur.setFont(new java.awt.Font("Monospaced", 0, 20));
      mainPanel.add(cur);
      sb.setLength(0);
    }

    add(mainPanelScroller, BorderLayout.CENTER);
    setDefaultCloseOperation(EXIT_ON_CLOSE);
    pack();
    setLocationRelativeTo(null);
  }
示例#21
0
 /**
  * Decode an ANSEL byte into a UTF-16 Character
  *
  * @param b the ANSEL byte (in int form)
  * @return the character (in UTF-16) represented by the byte
  */
 public static char decode(int b) {
   if (b < 0x80) {
     return (char) b;
   }
   Character result = byteToChar.get(Character.valueOf((char) b));
   if (result == null) {
     // Map unmappable characters to a question mark
     return '?';
   }
   return result.charValue();
 }
 @Nonnull
 private static String _getAsString(@Nonnull final Set<Character> aInvalidChars) {
   if (ContainerHelper.isEmpty(aInvalidChars)) return "NONE";
   final StringBuilder aSB = new StringBuilder();
   for (final Character aChar : aInvalidChars) {
     if (aSB.length() > 0) aSB.append(", ");
     final int nChar = aChar.charValue();
     aSB.append("0x").append(StringHelper.getHexStringLeadingZero(nChar, 2));
   }
   return aSB.toString();
 }
 private char[] fixWhitespace(char[] phrase) {
   if (replaceWhitespaceWith == null) return phrase;
   char[] fixed = new char[phrase.length];
   for (int i = 0; i < phrase.length; i++) {
     if (phrase[i] == replaceWhitespaceWith.charValue()) {
       fixed[i] = ' ';
     } else {
       fixed[i] = phrase[i];
     }
   }
   return fixed;
 }
示例#24
0
  /**
   * Encode a character for URLs
   *
   * @param immune characters not to encode
   * @param c character to encode
   * @return the encoded string representing c
   */
  public String encodeCharacter(char[] immune, Character c) {
    String cStr = String.valueOf(c.charValue());
    byte[] bytes;
    StringBuilder sb;

    if (UNENCODED_SET.contains(c)) return cStr;

    bytes = toUtf8Bytes(cStr);
    sb = new StringBuilder(bytes.length * 3);
    for (byte b : bytes) appendTwoUpperHex(sb.append('%'), b);
    return sb.toString();
  }
示例#25
0
 public int findNearestPosition(Character c) {
   int pos = getCursor().getColumnIndex(StationDao.NAME);
   for (int i = 0; i < getCount(); i++) {
     Cursor cursor = (Cursor) getItem(i);
     String name = cursor.getString(pos);
     int cn = name.charAt(0);
     int cc = c.charValue();
     if (cn == cc) {
       return i;
     }
     if (cn > cc) {
       return i;
     }
   }
   return 0;
 }
示例#26
0
  public void write(JSONSerializer serializer, Object object, Object fieldName, Type fieldType)
      throws IOException {
    SerializeWriter out = serializer.getWriter();

    Character value = (Character) object;
    if (value == null) {
      out.writeString("");
      return;
    }

    char c = value.charValue();
    if (c == 0) {
      out.writeString("\u0000");
    } else {
      out.writeString(value.toString());
    }
  }
  public String tokenizeSymbolList(SymbolList sl) throws IllegalAlphabetException {
    if (sl.getAlphabet() != getAlphabet()) {
      throw new IllegalAlphabetException(
          "Alphabet " + sl.getAlphabet().getName() + " does not match " + getAlphabet().getName());
    }
    StringBuffer sb = new StringBuffer();
    for (Iterator i = sl.iterator(); i.hasNext(); ) {
      Symbol sym = (Symbol) i.next();
      try {
        Character c = _tokenizeSymbol(sym);
        sb.append(c.charValue());
      } catch (IllegalSymbolException ex) {
        throw new IllegalAlphabetException(ex, "Couldn't tokenize");
      }
    }

    return sb.substring(0);
  }
示例#28
0
 /**
  * Translates an entity to a unicode character.
  *
  * @param name the name of the entity
  * @return the corresponding unicode character
  */
 public static char decodeEntity(final String name) {
   if (name.startsWith("#x")) {
     try {
       return (char) Integer.parseInt(name.substring(2), 16);
     } catch (NumberFormatException nfe) {
       return '\0';
     }
   }
   if (name.startsWith("#")) {
     try {
       return (char) Integer.parseInt(name.substring(1));
     } catch (NumberFormatException nfe) {
       return '\0';
     }
   }
   Character c = MAP.get(name);
   if (c == null) return '\0';
   else return c.charValue();
 }
示例#29
0
  public void test_Basics() {
    harness.check(!(Character.forDigit(8, 2) != '\0'), "test_forDigit - 50");
    harness.check(!(Character.forDigit(-3, 2) != '\0'), "test_forDigit - 51");
    harness.check(!(Character.forDigit(2, 8) != '2'), "test_forDigit - 52");
    harness.check(!(Character.forDigit(12, 16) != 'c'), "test_forDigit - 53");

    // sgurin
    //	  harness.check(!(Character.isJavaLetter('\uFFFF')),
    //	    "test_forDigit - 54");
    //	  harness.check(!(!Character.isJavaLetter('a')),
    //	    "test_forDigit - 55");

    harness.check(!(Character.MIN_VALUE != '\u0000'), "test_Basics - 1");
    harness.check(!(Character.MAX_VALUE != '\uffff'), "test_Basics - 2");
    harness.check(!(Character.MIN_RADIX != 2), "test_Basics - 3");
    harness.check(!(Character.MAX_RADIX != 36), "test_Basics - 4");

    Character ch = new Character('b');
    harness.check(!(ch.charValue() != 'b'), "test_Basics - 5");
  }
示例#30
0
  public String asCSV(Character separator, Character quotechar, Character endlinechar) {
    String csv = "";
    if (separator == null) separator = ',';
    if (quotechar == null) quotechar = '"';
    if (endlinechar == null) endlinechar = '\n';

    try {

      if (this.headers != null && this.headers.size() > 0) {
        for (int i = 0; i < this.headers.size(); i++) {
          if (i != 0) csv += separator.charValue();
          csv += quotechar + this.headers.get(i).getName() + quotechar;
        }
        csv += endlinechar;
      } else {
        logger.error("Table does not have any header.");
      }

      if (values == null) {
        logger.error("Table does not have any rows.");
        return csv;
      }

      for (int i = 0; i < this.values.size(); i++) {
        for (int j = 0; j < this.values.get(i).size(); j++) {
          if (j != 0) csv += separator;
          csv += quotechar + values.get(i).get(j) + quotechar;
        }
        csv += endlinechar;
      }

      return csv;

    } catch (Exception e) {
      logger.error("Error in generating CSV from the table.");
      e.printStackTrace();
      return null;
    }
  }