示例#1
0
  @Override
  public void run() {
    char c;

    try {
      while (running) {
        char_recieved = telnetHelper.read();
        c = (char) char_recieved;
        c = ansiCoding(c);
        if (ansiTransmitCode) {
          if (ansiCode.toString().charAt(ansiCode.toString().length() - 1) == '\n') {
            telnetHelper.addInputStringFragment(ansiCode.toString(), true);
          } else {
            telnetHelper.addInputStringFragment(ansiCode.toString(), false);
          }
          ansiCode.delete(0, ansiCode.length());
          ansiTransmitCode = false;
        }
        if (c == '\r') {
          // Suppress \r characters
        } else if (c == '\n') {
          telnetHelper.addInputStringFragment(java.lang.Character.toString(c), true);
        } else if (char_recieved > 0) {
          telnetHelper.addInputStringFragment(java.lang.Character.toString(c), false);
        }
        LogWriter.write(EnumLogType.TELNET, java.lang.Character.toString(c));
      }
    } catch (IOException e) {
      e.printStackTrace();
    }
  }
示例#2
0
  /**
   * Return a string based on value that is safe to place into a javascript / html identifier:
   * anything not alphanumeric change to 'x'. If the first character is not alphabetic, a letter 'i'
   * is prepended.
   *
   * @param value The string to escape.
   * @return value fully escaped using javascript / html identifier rules.
   */
  public static String escapeJavascript(String value) {
    if (value == null || "".equals(value)) return "";
    try {
      StringBuilder buf = new StringBuilder();

      // prepend 'i' if first character is not a letter
      if (!java.lang.Character.isLetter(value.charAt(0))) {
        buf.append("i");
      }

      // change non-alphanumeric characters to 'x'
      for (int i = 0; i < value.length(); i++) {
        char c = value.charAt(i);
        if (!java.lang.Character.isLetterOrDigit(c)) {
          buf.append("x");
        } else {
          buf.append(c);
        }
      }

      String rv = buf.toString();
      return rv;
    } catch (Exception e) {
      M_log.warn("Validator.escapeJavascript: ", e);
      return "";
    }
  } // escapeJavascript
示例#3
0
 public ParseMessage(String msg) {
   FMValue = msg.substring(3, 5); // first one is starting index,last one is end+1
   ToValue = msg.substring(9, 11); //
   NPVal = Character.getNumericValue(msg.charAt(15));
   HCVal = Character.getNumericValue(msg.charAt(20));
   msgNumber = Integer.parseInt(msg.substring(25, 28));
   int i = msg.indexOf("DATA");
   int j = msg.indexOf("VL");
   if (i != (j + 4)) {
     VLNode = msg.substring(j + 3, i);
   } else VLNode = "";
   DATA_Val = msg.substring(i + 5);
   if (NPVal == 2) {
     int k = msg.indexOf("registered as");
     RegisteredName = "" + msg.charAt(k + 14) + msg.charAt(k + 15);
   }
   if (NPVal == 6) {
     String str = new String(DATA_Val);
     arr = new CopyOnWriteArrayList<>();
     int m = 0;
     do {
       int k = str.indexOf(",");
       arr.add(new Node(str.substring(m, k)));
       str = str.substring(k + 1);
     } while (str.indexOf(",") != -1);
     arr.add(new Node(str));
   }
 }
 public int nextInt() {
   if (!hasNext()) throw new NoSuchElementException();
   // TODO: It probably would be faster if the logic from
   // the following two methods were inlined and simplified.
   int cp = Character.codePointAt(CharSequence.this, cur);
   cur += Character.charCount(cp);
   return cp;
 }
 @Override
 public void forEachInt(IntConsumer block) {
   while (cur < length()) {
     int cp = Character.codePointAt(CharSequence.this, cur);
     cur += Character.charCount(cp);
     block.accept(cp);
   }
 }
示例#6
0
 private boolean isConstantName(String completion) {
   for (char c : completion.toCharArray()) {
     if (Character.isLetter(c) && Character.isLowerCase(c)) {
       return false;
     }
   }
   return true;
 }
示例#7
0
  public List<int[]> findSeqeuences() {

    if (isConstantName(completion)) {
      rewriteCompletion();
    }

    int[] start = new int[0];
    curSequences.add(start);

    for (pToken = 0; pToken < token.length(); pToken++) {
      char t = token.charAt(pToken);

      for (int[] activeSequence : curSequences) {
        boolean mustmatch = false;
        int startIndex =
            activeSequence.length == 0 ? 0 : activeSequence[activeSequence.length - 1] + 1;

        for (pCompletion = startIndex; pCompletion < completion.length(); pCompletion++) {
          char c = completion.charAt(pCompletion);
          if (!Character.isLetter(c)) {
            if (c == t) {
              addNewSubsequenceForNext(activeSequence);
              continue;
            }
            mustmatch = true;
            continue;
          } else if (Character.isUpperCase(c)) {
            mustmatch = true;
          }

          if (mustmatch && !isSameIgnoreCase(c, t)) {
            jumpToEndOfWord();
          } else if (isSameIgnoreCase(c, t)) {
            addNewSubsequenceForNext(activeSequence);
          }
        }
      }
      curSequences = nextSequences;
      nextSequences = Lists.newLinkedList();
    }

    // filter
    for (Iterator<int[]> it = curSequences.iterator(); it.hasNext(); ) {
      int[] candidate = it.next();
      if (candidate.length < token.length()) {
        it.remove();
        continue;
      }
    }

    return curSequences;
  }
 public void doCleanLiterals(Model model) {
   Model retractionsModel = ModelFactory.createDefaultModel();
   Model additionsModel = ModelFactory.createDefaultModel();
   model.enterCriticalSection(Lock.WRITE);
   try {
     ClosableIterator<Statement> closeIt = model.listStatements();
     try {
       for (Iterator<Statement> stmtIt = closeIt; stmtIt.hasNext(); ) {
         Statement stmt = stmtIt.next();
         if (stmt.getObject().isLiteral()) {
           Literal lit = (Literal) stmt.getObject();
           String lex = lit.getLexicalForm();
           char[] chars = lex.toCharArray();
           char[] cleanChars = new char[chars.length];
           int cleanPos = 0;
           boolean badChar = false;
           for (int i = 0; i < chars.length; i++) {
             if (java.lang.Character.getNumericValue(chars[i]) > 31
                 && java.lang.Character.isDefined(chars[i])) {
               cleanChars[cleanPos] = chars[i];
               cleanPos++;
             } else {
               log.error("Bad char in " + lex);
               log.error("Numeric value " + java.lang.Character.getNumericValue(chars[i]));
               badChar = true;
             }
           }
           String cleanLex = new String(cleanChars);
           if (badChar) {
             retractionsModel.add(stmt);
             Literal newLit = null;
             if (lit.getLanguage() != null && lit.getLanguage().length() > 0) {
               newLit = additionsModel.createLiteral(cleanLex, lit.getLanguage());
             } else if (lit.getDatatype() != null) {
               newLit = additionsModel.createTypedLiteral(cleanLex, lit.getDatatype());
             } else {
               newLit = additionsModel.createLiteral(cleanLex);
             }
             additionsModel.add(stmt.getSubject(), stmt.getPredicate(), newLit);
           }
         }
       }
     } finally {
       closeIt.close();
     }
     model.remove(retractionsModel);
     model.add(additionsModel);
     log.debug("Cleaned " + additionsModel.size() + " literals");
   } finally {
     model.leaveCriticalSection();
   }
 }
示例#9
0
  public static void findTExtLetters(String letterToFind, String filePath) throws IOException {

    BufferedReader br = new BufferedReader(new FileReader(new File(filePath)));
    boolean foundIt = false;
    int i = 1;
    String[] letterToFindarray = letterToFind.split("");

    for (String line = br.readLine(); line != null; line = br.readLine()) {

      String[] letterarray = line.split("");

      for (int j = 0; j < letterarray.length; j++) {
        for (int x = 0; x < letterToFindarray.length; x++) {
          if (letterToFindarray[x].equals(letterarray[j])) {
            System.out.println("Egyezes a(z)" + i + ". sor, " + (j + 1) + ". karakterrel");
            foundIt = true;
          } else {
            char m = letterToFindarray[x].charAt(0);
            int o = (int) m;
            if (o < 95) { // nagy betűt keresek és kis betű a keresendőben
              char n = letterarray[j].charAt(0);
              int p = (int) n;
              p = p - 32;
              n = (char) p;
              String backToString = Character.toString(n);
              if (letterToFindarray[x].equals(backToString)) {
                System.out.println("Egyezes a(z)" + i + ". sor, " + (j + 1) + ". karakterrel");
                foundIt = true;
              }
            } else { //// kis betűt keresek és nagy betű a keresendőben
              char n = letterarray[j].charAt(0);
              int p = (int) n;
              p = p + 32;
              n = (char) p;
              String backToString = Character.toString(n);
              if (letterToFindarray[x].equals(backToString)) {
                System.out.println("Egyezes a(z)" + i + ". sor, " + (j + 1) + ". karakterrel");
                foundIt = true;
              }
            }
          }
        }
      }
      i++;
    }
    if (!foundIt) {
      System.out.println("Nincs ilyen szo");
    }
  }
  public void showResult(int count) {
    Image img = null;
    int imageX, imageY = 0;

    // 6 for system tray, and then account for all 4 results
    imageX = 89 - imageBull.getWidth() * 4 - imageInter.getWidth();

    if (gamemode == gameModeBasic) {
      for (int i = 0; i < result[count - 1].length(); i++) {
        switch (result[count - 1].charAt(i)) {
          case 'b':
            img = imageBull;
            break;
          case 'w':
            img = imageCow;
            break;
          case '-':
            img = imageWrong;
            break;
        }
        displayImageAtXY(img, imageX, imageY);
        imageX += img.getWidth();
      }
    } else {
      // number of bulls
      int bulls = Character.digit(result[count - 1].charAt(0), 10);
      int cows = Character.digit(result[count - 1].charAt(2), 10);
      int imageXB = imageX, imageXW = imageX;
      int imageYB = 0, imageYW = 0;

      for (int i = 0; i < bulls; i++) {
        displayImageAtXY(imageBull, imageXB, imageYB);
        imageXB += imageBull.getWidth();
      }

      if (bulls != 0) {
        imageYW = imageBull.getHeight();
      }

      for (int i = 0; i < cows; i++) {
        displayImageAtXY(imageCow, imageXW, imageYW);
        imageXW += imageCow.getWidth();
      }

      if (bulls == 0 && cows == 0) {
        displayImageAtXY(imageWrong, imageX, imageY);
      }
    }
  }
示例#11
0
  private void rewriteCompletion() {
    StringBuilder sb = new StringBuilder();

    boolean toUpperCase = false;
    for (char c : completion.toCharArray()) {
      if (Character.isLetterOrDigit(c)) {
        sb.append(toUpperCase ? Character.toUpperCase(c) : Character.toLowerCase(c));
        toUpperCase = false;
      } else {
        sb.append(c);
        toUpperCase = true;
      }
    }
    completion = sb.toString();
  }
示例#12
0
 /**
  * ** Returns true if the specified character is a valid character to use in ** an ID ** @param ch
  * The character ** @return True if the specified character is a valid character to use in ** an
  * ID
  */
 public static boolean isValidIDChar(char ch) {
   // At a minimum, avoid the following special chars:
   //   $   - substitution character
   //   {}  - have had problems using this character in MySQL
   //   %   - MySQL wildcard character
   //   *   - generic wildcard character
   //   \   - escape character
   //   ?   - just don't use it
   //   ,   - will get confused as a field separator
   //   |   - will get confused as a field separator
   //   /   - will get confused as a field separator
   //   =   - will get confused as a key=value separator
   //   "'` - quotation characters
   //   #   - possible beginning of comment
   //   ~   - just don't use it
   //   ?   - just don't use it
   //   ^   - just don't use it
   // Pending possibles:
   //   !   - Looks like '|'?
   //   -   - ?
   //   +   - ?
   // @abc,#abc,_abc,.abc,&abc
   if (Character.isLetterOrDigit(ch)) {
     return true;
   } else if ((ch == '.') || (ch == '_')) {
     // definately accept these
     return true;
   } else if ((ch == '@') || (ch == '&') || (ch == '-')) {
     // we'll consider these
     return true;
   } else {
     return false;
   }
 }
  public static void addChangeIdentifierCaseProposal(
      Node node, Collection<ICompletionProposal> proposals, IFile file) {
    Tree.Identifier identifier = null;

    if (node instanceof Tree.TypeDeclaration) {
      identifier = ((Tree.TypeDeclaration) node).getIdentifier();
    } else if (node instanceof Tree.TypeParameterDeclaration) {
      identifier = ((Tree.TypeParameterDeclaration) node).getIdentifier();
    } else if (node instanceof Tree.TypedDeclaration) {
      identifier = ((Tree.TypedDeclaration) node).getIdentifier();
    } else if (node instanceof Tree.ImportPath) {
      List<Identifier> importIdentifiers = ((Tree.ImportPath) node).getIdentifiers();
      for (Identifier importIdentifier : importIdentifiers) {
        if (importIdentifier.getText() != null
            && !importIdentifier.getText().isEmpty()
            && Character.isUpperCase(importIdentifier.getText().charAt(0))) {
          identifier = importIdentifier;
          break;
        }
      }
    }

    if (identifier != null && !identifier.getText().isEmpty()) {
      addProposal(identifier, proposals, file);
    }
  }
  private String getIntegerInput(String prompt) {
    boolean valid = false; // indicates if the name has be retrieved
    String playersInput = null;
    Scanner keyboard = new Scanner(System.in); // keyboard input stream

    while (!valid) { // while a valid name has not been retrieved

      // prompt for the player's choice
      this.console.println(prompt);

      // get the selection from the keyboard and trim off the blanks CAPs ok
      playersInput = keyboard.nextLine();
      playersInput = playersInput.trim();
      char ch = playersInput.charAt(0);

      // if the selection is invlaid (less than one characters in length)
      if (!Character.isDigit(ch)) {
        this.console.println("Please enter a positive integer.");
        continue; // and repeat again
      }
      break; // out of the (exit) the repetition
    }

    return playersInput; // return the name
  }
示例#15
0
 public void keyTyped(char ch) {
   if (this.emuSys != null) {
     if (this.emuSys.getSwapKeyCharCase()) {
       if (Character.isUpperCase(ch)) {
         ch = Character.toLowerCase(ch);
       } else if (Character.isLowerCase(ch)) {
         ch = Character.toUpperCase(ch);
       }
     }
     if (this.emuSys.getConvertKeyCharToISO646DE()) {
       this.emuSys.keyTyped(TextUtil.toISO646DE(ch));
     } else {
       this.emuSys.keyTyped(ch);
     }
   }
 }
示例#16
0
 /* return string representation of fault code */
 public static String GetFaultString(long fault) {
   if (fault > 0L) {
     StringBuffer sb = new StringBuffer();
     if ((fault & TYPE_MASK) == TYPE_J1708) {
       // SID: "128/s123/1"
       // PID: "128/123/1"
       boolean active = DTOBDFault.DecodeActive(fault);
       int mid = DTOBDFault.DecodeSystem(fault);
       int fmi = DTOBDFault.DecodeFMI(fault);
       if (!active) {
         sb.append("[");
       }
       sb.append(mid); // MID
       sb.append("/");
       if (DTOBDFault.IsJ1708_SID(fault)) {
         int sid = DTOBDFault.DecodePidSid(fault);
         sb.append("s").append(sid); // SID "128/s123/1"
       } else {
         int pid = DTOBDFault.DecodePidSid(fault);
         sb.append(pid); // PID "128/123/1"
       }
       sb.append("/");
       sb.append(fmi); // FMI
       if (!active) {
         sb.append("]");
       }
       return sb.toString();
     } else if ((fault & TYPE_MASK) == TYPE_J1939) {
       // SPN: "128/1"
       boolean active = DTOBDFault.DecodeActive(fault);
       int spn = DTOBDFault.DecodeSystem(fault);
       int fmi = DTOBDFault.DecodeFMI(fault);
       sb.append(spn); // SPN
       sb.append("/");
       sb.append(fmi); // FMI
       return sb.toString();
     } else if ((fault & TYPE_MASK) == TYPE_OBDII) {
       // DTC: "P0071" [was "024C"]
       boolean active = DTOBDFault.DecodeActive(fault);
       int sysChar = DTOBDFault.DecodeSystem(fault); // System: powertrain
       int subSys = DTOBDFault.DecodeSPID(fault); // Mfg/Subsystem/Problem
       if (Character.isLetter((char) sysChar)) {
         sb.append((char) sysChar);
       } else {
         sb.append("U");
       }
       if ((subSys & 0x8000) != 0) {
         sb.append("1");
       } else {
         sb.append("0");
       }
       String subSysStr = String.valueOf(1000 + ((subSys & 0xFFF) % 1000));
       sb.append(subSysStr.substring(1));
       return sb.toString();
     } else {
       // unrecognized
     }
   }
   return "";
 }
示例#17
0
  public static boolean isValidPassword(String password) {

    if (password.length() < 8) // ukoliko password nema 8 karaktera vracamo
      // gresku tj invalid password

      return false;

    int counter = 0;

    for (int i = 0; i < password.length(); i++) // prolazimo kroz sve
    // karaktere unosa

    {

      if (!Character.isLetterOrDigit(password.charAt(i))) // ukoliko se u
      // unosu ne
      // nalaze slova
      // opet vracamo
      // invalid
      // password

      {

        return false;
      }

      if (Character.isDigit(password.charAt(i))) // provjeravamo brojeve i
      // ukoliko ih ima
      // brojimo ih

      {

        counter++;
      }
    }

    if (counter >= 2) { // ukoliko ih ima vise od 2 uslov za validan
      // password je ispunjen vracamo tru za printanje
      System.out.println(" Valid password");

      return true;
    } else {
      System.out.println(" Invalid password");
      return false;
    }
  }
示例#18
0
 /**
  * ** Returns true if the specified character should be hex-encoded in a URL ** @param ch The
  * character to test ** @return True if the specified character should be hex-encoded in a URL
  */
 private static boolean shouldEncodeArgChar(char ch) {
   if (Character.isLetterOrDigit(ch)) {
     return false;
   } else if ((ch == '_') || (ch == '-') || (ch == '.')) {
     return false;
   } else {
     return true;
   }
 }
  private static boolean isFirstQuestionId(String str, char c) {
    boolean isFirst = false;
    int length = str.length();

    // '1' is only digital in string for backward direction, and '0' for forward direction
    if ((str.charAt(length - 1) == c) && Character.isLetter(str.charAt(length - 2))) isFirst = true;

    return isFirst;
  }
示例#20
0
  /**
   * 将字符串中的中文转化为拼音,其他字符不变
   *
   * @param inputString
   * @return
   */
  public static String getPingYin(String inputString) {
    HanyuPinyinOutputFormat format = new HanyuPinyinOutputFormat();
    format.setCaseType(HanyuPinyinCaseType.LOWERCASE);
    format.setToneType(HanyuPinyinToneType.WITHOUT_TONE);
    format.setVCharType(HanyuPinyinVCharType.WITH_V);

    char[] input = inputString.trim().toCharArray();
    String output = "";

    try {
      for (int i = 0; i < input.length; i++) {
        if (java.lang.Character.toString(input[i]).matches("[\\u4E00-\\u9FA5]+")) {
          String[] temp = PinyinHelper.toHanyuPinyinStringArray(input[i], format);
          output += temp[0];
        } else output += java.lang.Character.toString(input[i]);
      }
    } catch (BadHanyuPinyinOutputFormatCombination e) {
      e.printStackTrace();
    }
    return output;
  }
  /**
   * Test whether a given string is a valid Java identifier.
   *
   * @param id string which should be checked
   * @return <code>true</code> if a valid identifier
   */
  public static final boolean isJavaIdentifier(String id) {
    if (id == null) {
      return false;
    }

    if (id.equals("")) {
      return false;
    }

    if (!(java.lang.Character.isJavaIdentifierStart(id.charAt(0)))) {
      return false;
    }

    for (int i = 1; i < id.length(); i++) {
      if (!(java.lang.Character.isJavaIdentifierPart(id.charAt(i)))) {
        return false;
      }
    }

    return Arrays.binarySearch(keywords, id) < 0;
  }
示例#22
0
 /* Removes whitespaces on the right end of the given string.
  */
 public static SchemaString rightTrim(SchemaString string) {
   String s = string.getValue();
   int nPosition = s.length();
   while (nPosition > 0 && Character.isWhitespace(s.charAt(nPosition - 1))) {
     nPosition--;
   }
   try {
     return new SchemaString(s.substring(0, nPosition));
   } catch (IndexOutOfBoundsException e) {
     return new SchemaString(string);
   }
 }
示例#23
0
 /* Removes whitespaces on the left end of the given string.
  */
 public static SchemaString leftTrim(SchemaString string) {
   String s = string.getValue();
   int nPosition = 0;
   while (nPosition < s.length() && Character.isWhitespace(s.charAt(nPosition))) {
     nPosition++;
   }
   try {
     return new SchemaString(string.getValue().substring(nPosition, string.getValue().length()));
   } catch (IndexOutOfBoundsException e) {
     return new SchemaString(string);
   }
 }
示例#24
0
 public Field(String s) {
   String f[] = StringTools.parseString(s, FIELD_VALUE_SEPARATOR);
   if ((f.length > 0) && (f[0].length() > 0) && Character.isLetter(f[0].charAt(0))) {
     this.isHiRes = (f.length > 0) ? f[0].equalsIgnoreCase("H") : false;
     this.type = (f.length > 1) ? StringTools.parseInt(f[1], -1) : -1;
   } else {
     this.type = (f.length > 0) ? StringTools.parseInt(f[0], -1) : -1;
     this.isHiRes = (f.length > 1) ? f[1].equalsIgnoreCase("H") : false;
   }
   this.index = (f.length > 2) ? StringTools.parseInt(f[2], 0) : 0;
   this.length = (f.length > 3) ? StringTools.parseInt(f[3], 0) : 0;
   this.isValid = (f.length == 4) && (this.type >= 0) && (this.index >= 0) && (this.length > 0);
 }
示例#25
0
 private static String correctSymbol(String symbol) { // converts to correct case
   if (DIAGNOSTICS) {
     System.out.println("In correctSymbols.");
     System.out.println("Correcting capatalization of " + symbol);
   }
   symbol = symbol.toUpperCase(); // cap all chars
   if (DIAGNOSTICS) {
     System.out.println("all caps symbol is " + symbol);
   }
   if (symbol.length() > 1) {
     if (DIAGNOSTICS) {
       System.out.println("Symbol contains more than 1 character.");
     }
     // copy first (correctly capped) char into new string
     String corrected_symbol = new String(symbol.substring(0, 1));
     // make sure second letter is lower case (always)
     Character tmp = new Character(symbol.charAt(1));
     corrected_symbol += tmp.toLowerCase(symbol.charAt(1));
     return corrected_symbol;
   }
   return symbol;
 }
示例#26
0
 private boolean asciiEqual(String[] letterToFindarray, String[] letterarray, int stepcount) {
   char m = letterToFindarray[stepcount].charAt(0);
   int o = (int) m;
   char n = letterarray[stepcount].charAt(0);
   int p = (int) n;
   if (o < 95) { // nagy betűt keresek és kis betű a keresendőben
     p = p - 32;
   } else { //// kis betűt keresek és nagy betű a keresendőben
     p = p + 32;
   }
   n = (char) p;
   String backToString = Character.toString(n);
   return letterToFindarray[stepcount].equals(backToString);
 }
  /**
   * Returns true if the specified key produces a glyph.
   *
   * @param keyCode The key code.
   * @return True if the key is a printing key.
   */
  public boolean isPrintingKey(int keyCode) {
    int type = Character.getType(nativeGetDisplayLabel(mPtr, keyCode));

    switch (type) {
      case Character.SPACE_SEPARATOR:
      case Character.LINE_SEPARATOR:
      case Character.PARAGRAPH_SEPARATOR:
      case Character.CONTROL:
      case Character.FORMAT:
        return false;
      default:
        return true;
    }
  }
示例#28
0
  public Note prevHalfStep() {
    // If the next note a half step away, return it
    if (this.nextInterval == 0.5) {
      return this.nextNote();
    }
    ;

    // Otherwise, if the length of the note name is > 1, we have a sharp
    if (this.noteName.length() > 1) {
      String startingLetter = Character.toString(this.noteName.charAt(0));
      return new Note(startingLetter);
    } else {
      return new Note(Note.lookUp(this.noteName)[3] + "#");
    }
  }
 public static boolean isPrintable(char c) {
   if (Character.isJavaIdentifierStart(c)) {
     // Letters and $ _
     return true;
   }
   if (Character.isDigit(c)) {
     return true;
   }
   switch (Character.getType(c)) {
     case Character.MODIFIER_SYMBOL:
       return true; // ` ^
     case Character.DASH_PUNCTUATION:
       return true; // -
     case Character.MATH_SYMBOL:
       return true; // = ~ + | < >
     case Character.OTHER_PUNCTUATION:
       return true; // !@#%&*;':",./?
     case Character.START_PUNCTUATION:
       return true; // ( [ {
     case Character.END_PUNCTUATION:
       return true; // ) ] }
   }
   return false;
 }
示例#30
0
 /**
  * ** Filters an ID String, convertering all letters to lowercase and ** removing invalid
  * characters ** @param text The ID String to filter ** @return The filtered ID String
  */
 public static String FilterID(String text) {
   // ie. "sky.12", "acme@123"
   if (text != null) {
     StringBuffer sb = new StringBuffer();
     for (int i = 0; i < text.length(); i++) {
       char ch = Character.toLowerCase(text.charAt(i));
       if (DBRecordKey.isValidIDChar(ch)) {
         sb.append(ch);
       }
     }
     return sb.toString();
   } else {
     return "";
   }
 }