コード例 #1
1
  private static void generateNameByString(
      Set<String> possibleNames,
      String value,
      NameValidator validator,
      boolean forStaticVariable,
      Project project) {
    if (!JavaPsiFacade.getInstance(project).getNameHelper().isIdentifier(value)) return;
    if (forStaticVariable) {
      StringBuilder buffer = new StringBuilder(value.length() + 10);
      char[] chars = new char[value.length()];
      value.getChars(0, value.length(), chars, 0);
      boolean wasLow = Character.isLowerCase(chars[0]);

      buffer.append(Character.toUpperCase(chars[0]));
      for (int i = 1; i < chars.length; i++) {
        if (Character.isUpperCase(chars[i])) {
          if (wasLow) {
            buffer.append('_');
            wasLow = false;
          }
        } else {
          wasLow = true;
        }

        buffer.append(Character.toUpperCase(chars[i]));
      }
      possibleNames.add(validator.validateName(buffer.toString(), true));
    } else {
      possibleNames.add(validator.validateName(value, true));
    }
  }
コード例 #2
0
 // by Jaume Ortola
 private boolean areEqual(final char x, final char y) {
   if (x == y) {
     return true;
   }
   if (dictionaryMetadata.getEquivalentChars() != null
       && dictionaryMetadata.getEquivalentChars().containsKey(x)
       && dictionaryMetadata.getEquivalentChars().get(x).contains(y)) {
     return true;
   }
   if (dictionaryMetadata.isIgnoringDiacritics()) {
     String xn = Normalizer.normalize(Character.toString(x), Form.NFD);
     String yn = Normalizer.normalize(Character.toString(y), Form.NFD);
     if (xn.charAt(0) == yn.charAt(0)) { // avoid case conversion, if possible
       return true;
     }
     if (dictionaryMetadata.isConvertingCase()) {
       // again case conversion only when needed -- we
       // do not need String.lowercase because we only check
       // single characters, so a cheaper method is enough
       if (Character.isLetter(xn.charAt(0))) {
         boolean testNeeded =
             Character.isLowerCase(xn.charAt(0)) != Character.isLowerCase(yn.charAt(0));
         if (testNeeded) {
           return Character.toLowerCase(xn.charAt(0)) == Character.toLowerCase(yn.charAt(0));
         }
       }
     }
     return xn.charAt(0) == yn.charAt(0);
   }
   return false;
 }
コード例 #3
0
  public static String javaToXMLName(String javaName) {

    // Strip "package name".
    int lastDot = javaName.lastIndexOf('.');
    if (lastDot != -1 && lastDot + 1 < javaName.length())
      javaName = javaName.substring(lastDot + 1);

    // Strip "inner class prefix".
    int lastDollar = javaName.lastIndexOf('$');
    if (lastDollar != -1) javaName = javaName.substring(lastDollar + 1);

    StringBuilder result = new StringBuilder();
    for (int i = 0; i < javaName.length(); i++) {
      // ASTWhen switch from lower to upper, add a dash before upper.
      if (i > 0
          && Character.isLowerCase(javaName.charAt(i - 1))
          && Character.isUpperCase(javaName.charAt(i))) result.append('-');
      // ASTWhen switch from upper to lower, add dash before upper.
      else if (i > 0
          && i < javaName.length() - 1
          && Character.isUpperCase(javaName.charAt(i))
          && Character.isLowerCase(javaName.charAt(i + 1))) result.append('-');
      result.append(Character.toLowerCase(javaName.charAt(i)));
    }
    return result.toString();
  }
コード例 #4
0
  protected static String addUnderscores(String name, boolean pluralize) {
    StringBuffer buf = new StringBuffer(name.replace('.', '_'));
    for (int i = 1; i < buf.length() - 1; i++) {
      if (Character.isLowerCase(buf.charAt(i - 1))
          && Character.isUpperCase(buf.charAt(i))
          && Character.isLowerCase(buf.charAt(i + 1))) {
        buf.insert(i++, '_');
      }
    }

    if (pluralize) {
      String[] splitTableNameFragments = buf.toString().toLowerCase().split("_");

      StringBuffer buf2 = new StringBuffer();

      for (int i = 0; i < splitTableNameFragments.length; i++) {

        if (i < (splitTableNameFragments.length - 1)) {
          buf2.append(splitTableNameFragments[i]);
          buf2.append("_");
        } else {
          buf2.append(English.plural(splitTableNameFragments[i]));
        }
      }

      return buf2.toString().toUpperCase();
    }

    return buf.toString().toUpperCase();
  }
コード例 #5
0
ファイル: Indexer.java プロジェクト: mollusc/LinguaSubtitle
  /**
   * Get the list of stems
   *
   * @return Keys is a stem object, Value is quantity of the stem in the subtitles
   */
  public Map<Stemmator, Integer> getListStems() {
    Map<Stemmator, Integer> result = new HashMap<Stemmator, Integer>();
    for (String stemString : index.keySet()) {
      ArrayList<IndexWord> indexWords = index.get(stemString);

      String currentWord = "";
      for (IndexWord indexWord : indexWords) {
        Speech speech = subtitle.getSpeech(indexWord.indexSpeech);
        String word = speech.content.substring(indexWord.start, indexWord.end);

        if (currentWord.isEmpty()) {
          currentWord = word;
          continue;
        }

        if (word.length() < currentWord.length()) currentWord = word;

        if (Character.isLowerCase(word.charAt(0)) || Character.isLowerCase(currentWord.charAt(0)))
          currentWord = currentWord.toLowerCase();
      }
      if (!currentWord.isEmpty()) {
        Stemmator stemmator = new Stemmator(currentWord, language);
        result.put(stemmator, indexWords.size());
      }
    }
    return result;
  }
コード例 #6
0
ファイル: TextFormatter.java プロジェクト: 4DvAnCeBoY/dotCMS
  private static String _formatI(String s) {
    if (s.length() == 1) {
      return s.toLowerCase();
    }

    if (Character.isUpperCase(s.charAt(0)) && Character.isLowerCase(s.charAt(1))) {

      return Character.toLowerCase(s.charAt(0)) + s.substring(1, s.length());
    }

    StringBuffer sb = new StringBuffer();

    char[] c = s.toCharArray();

    for (int i = 0; i < c.length; i++) {
      if ((i + 1 != c.length) && (Character.isLowerCase(c[i + 1]))) {

        sb.append(s.substring(i, c.length));

        break;
      } else {
        sb.append(Character.toLowerCase(c[i]));
      }
    }

    return sb.toString();
  }
コード例 #7
0
  private String getCaseCorrectedLookupString(LookupElement item) {
    String lookupString = item.getLookupString();
    if (item.isCaseSensitive()) {
      return lookupString;
    }

    final String prefix = itemPattern(item);
    final int length = prefix.length();
    if (length == 0 || !itemMatcher(item).prefixMatches(prefix)) return lookupString;
    boolean isAllLower = true;
    boolean isAllUpper = true;
    boolean sameCase = true;
    for (int i = 0; i < length && (isAllLower || isAllUpper || sameCase); i++) {
      final char c = prefix.charAt(i);
      boolean isLower = Character.isLowerCase(c);
      boolean isUpper = Character.isUpperCase(c);
      // do not take this kind of symbols into account ('_', '@', etc.)
      if (!isLower && !isUpper) continue;
      isAllLower = isAllLower && isLower;
      isAllUpper = isAllUpper && isUpper;
      sameCase = sameCase && isLower == Character.isLowerCase(lookupString.charAt(i));
    }
    if (sameCase) return lookupString;
    if (isAllLower) return lookupString.toLowerCase();
    if (isAllUpper) return StringUtil.toUpperCase(lookupString);
    return lookupString;
  }
コード例 #8
0
 public static String camelCaseToWords(String camelCase, char separator) {
   // special case if short string
   if (camelCase == null || camelCase.length() <= 2) {
     return camelCase;
   }
   StringBuffer sb = new StringBuffer(camelCase.length() + 3);
   sb.append(camelCase.charAt(0));
   sb.append(camelCase.charAt(1));
   for (int i = 2; i < camelCase.length(); i++) {
     sb.append(camelCase.charAt(i));
     if (camelCase.charAt(i - 2) == separator) {
       continue;
     } else if (Character.isUpperCase(camelCase.charAt(i - 1))
         && Character.isLowerCase(camelCase.charAt(i))) {
       sb.insert(sb.length() - 2, separator);
     } else if (Character.isLowerCase(camelCase.charAt(i - 2))
         && Character.isUpperCase(camelCase.charAt(i - 1))
         && Character.isUpperCase(camelCase.charAt(i))) {
       sb.insert(sb.length() - 2, separator);
     }
   }
   // special case if last is upper
   if (Character.isUpperCase(sb.charAt(sb.length() - 1))
       && Character.isLowerCase(sb.charAt(sb.length() - 2))) {
     sb.insert(sb.length() - 1, ' ');
   }
   return sb.toString();
 }
コード例 #9
0
 public static String posibleR(int i) {
   String list = "", oldPiece;
   int r = i / 8, c = i % 8;
   for (int j = -1; j <= 1; j += 2) {
     int temp = 1;
     try {
       while (" ".equals(chessBoard.get(r, c + temp * j))) {
         oldPiece = chessBoard.get(r, c + temp * j);
         chessBoard.set(r, c, " ");
         chessBoard.set(r, c + temp * j, "R");
         if (kingSafe()) {
           list = list + r + c + r + (c + temp * j) + oldPiece;
         }
         chessBoard.set(r, c, "R");
         chessBoard.set(r, c + temp * j, oldPiece);
         temp++;
       }
       if (Character.isLowerCase(chessBoard.get(r, c + temp * j).charAt(0))) {
         oldPiece = chessBoard.get(r, c + temp * j);
         chessBoard.set(r, c, " ");
         chessBoard.set(r, c + temp * j, "R");
         if (kingSafe()) {
           list = list + r + c + r + (c + temp * j) + oldPiece;
         }
         chessBoard.set(r, c, "R");
         chessBoard.set(r, c + temp * j, oldPiece);
       }
     } catch (Exception e) {
     }
     temp = 1;
     try {
       while (" ".equals(chessBoard.get(r + temp * j, c))) {
         oldPiece = chessBoard.get(r + temp * j, c);
         chessBoard.set(r, c, " ");
         chessBoard.set(r + temp * j, c, "R");
         if (kingSafe()) {
           list = list + r + c + (r + temp * j) + c + oldPiece;
         }
         chessBoard.set(r, c, "R");
         chessBoard.set(r + temp * j, c, oldPiece);
         temp++;
       }
       if (Character.isLowerCase(chessBoard.get(r + temp * j, c).charAt(0))) {
         oldPiece = chessBoard.get(r + temp * j, c);
         chessBoard.set(r, c, " ");
         chessBoard.set(r + temp * j, c, "R");
         if (kingSafe()) {
           list = list + r + c + (r + temp * j) + c + oldPiece;
         }
         chessBoard.set(r, c, "R");
         chessBoard.set(r + temp * j, c, oldPiece);
       }
     } catch (Exception e) {
     }
   }
   return list;
 }
コード例 #10
0
 protected static String addUnderscores(String name) {
   StringBuilder buf = new StringBuilder(name.replace('.', '_'));
   for (int i = 1; i < buf.length() - 1; i++) {
     if (Character.isLowerCase(buf.charAt(i - 1))
         && Character.isUpperCase(buf.charAt(i))
         && Character.isLowerCase(buf.charAt(i + 1))) {
       buf.insert(i++, '_');
     }
   }
   return buf.toString().toLowerCase(Locale.ROOT);
 }
コード例 #11
0
ファイル: CharacterTest.java プロジェクト: abego/java2script
  public void test_others() {
    // calling them just for completion
    // not supported		Character.getNumericValue( 'a' );
    // not supported		Character.getType( 'a' );

    //	  Character.isDefined( 'a' );//sgurin
    //	  Character.isDefined( '\uffff' );//sgurin

    Character.digit('\u0665', 10);
    Character.digit('\u06F5', 10);
    Character.digit('\u0968', 10);
    Character.digit('\u06E8', 10);
    Character.digit('\u0A68', 10);
    Character.digit('\u0AE8', 10);
    Character.digit('\u0B68', 10);
    Character.digit('\u0BE8', 10);
    Character.digit('\u0C68', 10);
    Character.digit('\u0CE8', 10);
    Character.digit('\u0D68', 10);
    Character.digit('\u0E52', 10);
    Character.digit('\u0ED2', 10);
    Character.digit('\uFF12', 10);
    Character.digit('\uFFFF', 10);

    // not supported		Character.isISOControl( 'a' );
    // not supported		Character.isIdentifierIgnorable( 'a' );
    // not supported		Character.isJavaIdentifierPart( 'a' );
    // not supported		Character.isJavaIdentifierStart( 'a' );
    // not supported		Character.isJavaLetter( 'a' );

    // sgurin: commented isJavaLetterOrDigir: nobt supported by j2s
    //	  Character.isJavaLetterOrDigit( 'a' );
    //	  harness.check(!(Character.isJavaLetterOrDigit('\uFFFF')),
    //	      "isJavaLetterOrDigit - 60");
    //	  harness.check(!(Character.isLetterOrDigit('\uFFFF')),
    //	      "isLetterOrDigit - 61");

    // not supported		Character.isLetter( 'a' );
    Character.isLetterOrDigit('a');
    Character.isLowerCase('A');
    Character.isLowerCase('a');
    Character.isWhitespace('a'); // sgurin Changed this to use non deprecated method

    // not supported		Character.isSpaceChar( 'a' );
    // not supported		Character.isTitleCase( 'a' );
    // not supported		Character.isUnicodeIdentifierPart( 'a' );
    // not supported		Character.isUnicodeIdentifierStart( 'a' );
    Character.isUpperCase('a');
    Character.isUpperCase('A');
    // not supported		Character.isWhitespace( 'a' );
    // not supported		Character.toTitleCase( 'a' );
  }
コード例 #12
0
 protected static String addUnderscores(String name) {
   if (name == null) {
     return null;
   }
   StringBuffer stringBuffer = new StringBuffer(name.replace('.', '_'));
   for (int i = 1; i < stringBuffer.length() - 1; i++) {
     if (Character.isLowerCase(stringBuffer.charAt(i - 1))
         && Character.isUpperCase(stringBuffer.charAt(i))
         && Character.isLowerCase(stringBuffer.charAt(i + 1))) {
       stringBuffer.insert(i++, '_');
     }
   }
   return stringBuffer.toString().toLowerCase();
 }
コード例 #13
0
 public static String capitalizeFirstCharacter(String s) {
   if (s != null && s.isEmpty() == false && Character.isLowerCase(s.charAt(0))) {
     return Character.toUpperCase(s.charAt(0)) + s.substring(1);
   } else {
     return s;
   }
 }
コード例 #14
0
  public static void main(String args[]) {

    Scanner in = new Scanner(System.in);

    int n = in.nextInt();

    String text = in.next();

    char[] input = new char[text.length()];

    int k = in.nextInt();

    for (int i = 0; i < text.length(); ++i) input[i] = text.charAt(i);

    for (int i = 0; i < text.length(); ++i) {
      if (Character.isLetter(input[i])) {

        int value = (int) input[i] + k % 26;

        if (Character.isLowerCase(input[i])) {

          if (value > (int) 'z') value = value - 26;

        } else if (Character.isUpperCase(input[i])) {
          if (value > (int) 'Z') value = value - 26;
        }

        input[i] = (char) value;
      }
    }

    for (int i = 0; i < n; ++i) System.out.print(input[i]);

    System.out.println();
  }
コード例 #15
0
 @Override
 public LookupResult findClassNode(String name, CompilationUnit compilationUnit) {
   // todo: ideally, we should use a precompiled DFA here, in order to choose whether to perform
   // a lookup
   // in linear time
   if (name.startsWith("org$gradle$")) {
     return null;
   }
   if (name.indexOf("$org$gradle") > 0
       || name.indexOf("$java$lang") > 0
       || name.indexOf("$groovy$lang") > 0) {
     return null;
   }
   if (name.startsWith("java.") || name.startsWith("groovy.") || name.startsWith("org.gradle")) {
     int idx = 6;
     char c;
     while ((c = name.charAt(idx)) == '.' || Character.isLowerCase(c)) {
       idx++;
     }
     if (c == '$') {
       return null;
     }
     if (name.indexOf("org.gradle", 1) > 0) {
       // ex: org.gradle.api.org.gradle....
       return null;
     }
   }
   return super.findClassNode(name, compilationUnit);
 }
コード例 #16
0
 /**
  * Determines the kind of a character.
  *
  * @param ch the character to test
  */
 private int getKind(char ch) {
   if (Character.isUpperCase(ch)) return K_UPPER;
   if (Character.isLowerCase(ch)) return K_LOWER;
   if (Character.isJavaIdentifierPart(ch)) // _, digits...
   return K_OTHER;
   return K_INVALID;
 }
コード例 #17
0
 private static String getPropertyName(String methodName) {
   String property = methodName.substring(3);
   if (Character.isLowerCase(property.charAt(0))) return null;
   if (property.length() <= 1) return property.toLowerCase();
   if (Character.isUpperCase(property.charAt(1))) return property;
   return property.substring(0, 1).toLowerCase() + property.substring(1);
 }
コード例 #18
0
ファイル: AOJ0017.java プロジェクト: gamu1012/AOJ
 public static void main(String[] args) {
   Scanner sc = new Scanner(System.in);
   int i = 0, j;
   boolean bool = false;
   String str[] = sc.nextLine().split(" ");
   for (int k = 0; k < 26; k++) {
     for (i = 0; i < str.length; i++) {
       char ch[] = str[i].toCharArray();
       for (j = 0; j < ch.length; j++) {
         if (Character.isLowerCase(ch[j])) {
           ch[j] = (char) ((ch[j] + 1) % 26 + 'a');
         }
       } // forツ j
       str[i] = new String(ch);
       if (str[i].equals("the")
           || str[i].equals("this")
           || str[i].equals("that")
           || str[i].equals("the.")
           || str[i].equals("this.")
           || str[i].equals("that.")) bool = true;
     } // for i
     if (bool) break;
   } // forツ k
   boolean f = true;
   for (i = 0; i < str.length; i++) {
     if (!f) System.out.print(" ");
     f = false;
     System.out.print(str[i]);
   }
   System.out.println();
 }
コード例 #19
0
ファイル: CharDemo.java プロジェクト: xhbang/java-class
    public static void main(String[] args)
    {
        char a[] = { 'a', '5', '?', 'A', ' ', '$', 'жа' };
        for (int i = 0; i < a.length; i++) {
            if (Character.isDigit(a[i]))
                System.out.println(a[i] + " is a digit.");
            if (Character.isLetter(a[i]))
                System.out.println(a[i] + " is a letter.");
            if (Character.isWhitespace(a[i]))
                System.out.println(a[i] + " is whitespace.");
            if (Character.isUpperCase(a[i]))
                System.out.println(a[i] + " is uppercase.");
            if (Character.isLowerCase(a[i]))
                System.out.println(a[i] + " is lowercase.");
            if (Character.isJavaIdentifierPart(a[i]))
                System.out.println(a[i]
                        + " may be part of java Identifier part.");
            if (Character.isJavaIdentifierStart(a[i]))
                System.out.println(a[i]
                        + " may be part of java Identifier Start.");
            if (Character.isUnicodeIdentifierPart(a[i]))
                System.out.println(a[i]
                        + " may be part of a Unicode identifier .");
            if (Character.isUnicodeIdentifierStart(a[i]))
                System.out
                        .println(a[i]
                                + " may be the first character in a Unicode identifier.");

        }
    }
コード例 #20
0
 private void insertDocs(File file) {
   try {
     char[] contents = Util.getFileCharContent(file, null);
     String raw = new String(contents);
     StringBuffer modified = new StringBuffer(raw);
     Pattern p =
         Pattern.compile("class (\\w+)"); // FIXME This is picking up code samples and stuff!
     Matcher m = p.matcher(raw);
     while (m.find()) {
       String className = m.group(1);
       if (Character.isLowerCase(className.charAt(0))) continue;
       String originalName = file.getName().substring(0, file.getName().length() - 3);
       if (!className.toLowerCase().equals(originalName)) continue;
       int offset = m.start();
       String before = raw.substring(0, offset).trim();
       if (before.endsWith("=end")) continue; // Already has docs for type
       String docs = getRI(className);
       modified.insert(offset, "=begin\n" + docs + "=end\n");
       //				System.out.println(docs);
     }
     if (modified.length() != raw.length()) write(file, modified);
   } catch (IOException e) {
     // TODO Auto-generated catch block
     e.printStackTrace();
   }
 }
コード例 #21
0
 public RefactoringStatus checkFinalConditions(IProgressMonitor pm)
     throws CoreException, OperationCanceledException {
   if (!newName.matches("^[a-zA-Z_]\\w*$")) {
     return createErrorStatus("Not a legal Ceylon identifier");
   } else if (escaping_.get_().isKeyword(newName)) {
     return createErrorStatus("'" + newName + "' is a Ceylon keyword");
   } else {
     int ch = newName.codePointAt(0);
     if (declaration instanceof TypedDeclaration) {
       if (!Character.isLowerCase(ch) && ch != '_') {
         return createErrorStatus("Not an initial lowercase identifier");
       }
     } else if (declaration instanceof TypeDeclaration) {
       if (!Character.isUpperCase(ch)) {
         return createErrorStatus("Not an initial uppercase identifier");
       }
     }
   }
   Declaration existing =
       declaration
           .getContainer()
           .getMemberOrParameter(declaration.getUnit(), newName, null, false);
   if (null != existing && !existing.equals(declaration)) {
     return createWarningStatus(
         "An existing declaration named '" + newName + "' already exists in the same scope");
   }
   return new RefactoringStatus();
 }
コード例 #22
0
ファイル: CCommon.java プロジェクト: LightJason/AgentSpeak
  /**
   * checks if an action is usable
   *
   * @param p_action action object
   * @return boolean usable flag
   */
  private static boolean actionusable(final IAction p_action) {
    if ((p_action.name() == null)
        || (p_action.name().isEmpty())
        || (p_action.name().get(0).trim().isEmpty())) {
      LOGGER.warning(CCommon.languagestring(CCommon.class, "actionnameempty"));
      return false;
    }

    if (!Character.isLetter(p_action.name().get(0).charAt(0))) {
      LOGGER.warning(CCommon.languagestring(CCommon.class, "actionletter", p_action));
      return false;
    }

    if (!Character.isLowerCase(p_action.name().get(0).charAt(0))) {
      LOGGER.warning(CCommon.languagestring(CCommon.class, "actionlowercase", p_action));
      return false;
    }

    if (p_action.minimalArgumentNumber() < 0) {
      LOGGER.warning(CCommon.languagestring(CCommon.class, "actionargumentsnumber", p_action));
      return false;
    }

    return true;
  }
コード例 #23
0
 protected boolean needsConvertToJavaName(String columnName) {
   if (columnName == null || columnName.trim().length() == 0) {
     String msg = "The columnName is invalid: " + columnName;
     throw new IllegalArgumentException(msg);
   }
   if (columnName.contains("_")) {
     return true; // contains (supported) connector!
   }
   // here 'BIRHDATE' or 'birthdate' or 'Birthdate'
   // or 'memberStatus' or 'MemberStatus'
   final char[] columnCharArray = columnName.toCharArray();
   boolean existsUpper = false;
   boolean existsLower = false;
   for (char ch : columnCharArray) {
     if (Character.isDigit(ch)) {
       continue;
     }
     if (Character.isUpperCase(ch)) {
       existsUpper = true;
       continue;
     }
     if (Character.isLowerCase(ch)) {
       existsLower = true;
       continue;
     }
   }
   final boolean camelCase = existsUpper && existsLower;
   // if it's camelCase, no needs to convert
   // (all characters that are upper or lower case needs to convert)
   return !camelCase;
 }
コード例 #24
0
ファイル: StringUtil.java プロジェクト: GauravAgg/CommonUtils
  private static String createRegexForReplace(String toFind) {
    char[] find = toFind.toCharArray();
    StringBuilder regexString = new StringBuilder();
    for (char f : find) {
      int d = f;
      if ((d >= 65 && d <= 90) || (d >= 97 && d <= 122)) {
        regexString.append("[");
        regexString.append(Character.toString((char) d));
        int temp = d;
        if (Character.isLowerCase(f)) {
          temp = d - 32;
        } else {
          temp = d + 32;
        }
        regexString.append(Character.toString((char) temp));
        regexString.append("]");
      } else if (d == 32) {

        regexString.append("[\\s]");
      } else {
        regexString.append("[");
        regexString.append(f);
        regexString.append("]");
      }
    }
    return regexString.toString();
  }
コード例 #25
0
ファイル: SpeADLValidator.java プロジェクト: victornoel/may
 @Check
 public void checkStartsWithoutCapital(final ContentElement ne) {
   String _name = ne.getName();
   char _charAt = _name.charAt(0);
   boolean _isLowerCase = Character.isLowerCase(_charAt);
   boolean _not = (!_isLowerCase);
   if (_not) {
     String _switchResult = null;
     boolean _matched = false;
     if (!_matched) {
       if (ne instanceof Part) {
         _matched = true;
         _switchResult = "Part";
       }
     }
     if (!_matched) {
       if (ne instanceof Port) {
         _matched = true;
         _switchResult = "Port";
       }
     }
     final String what = _switchResult;
     this.error(
         (what + " name must not start with a capital"),
         SpeadlPackage.Literals.CONTENT_ELEMENT__NAME);
   }
 }
コード例 #26
0
  @Override
  public String variableNameToPropertyName(String name, VariableKind variableKind) {
    if (variableKind == VariableKind.STATIC_FINAL_FIELD
        || variableKind == VariableKind.STATIC_FIELD && name.contains("_")) {
      StringBuilder buffer = new StringBuilder();
      for (int i = 0; i < name.length(); i++) {
        char c = name.charAt(i);
        if (c != '_') {
          if (Character.isLowerCase(c)) {
            return variableNameToPropertyNameInner(name, variableKind);
          }

          buffer.append(Character.toLowerCase(c));
          continue;
        }
        //noinspection AssignmentToForLoopParameter
        i++;
        if (i < name.length()) {
          c = name.charAt(i);
          buffer.append(c);
        }
      }
      return buffer.toString();
    }

    return variableNameToPropertyNameInner(name, variableKind);
  }
コード例 #27
0
 @Override
 public boolean value(PsiPackage aPackage) {
   return JavaPsiFacade.getInstance(aPackage.getProject())
           .getNameHelper()
           .isQualifiedName(aPackage.getQualifiedName())
       && Character.isLowerCase(aPackage.getName().charAt(0));
 }
コード例 #28
0
ファイル: BarrelSort.java プロジェクト: andyInn/OJSolutions
 public static void sort(String text) {
   String[] t = text.split(",");
   int len = t.length;
   int[] temp = new int[len];
   // 桶排序处理
   int[] arr = new int[52];
   char ch;
   for (int i = 0; i < len; i++) {
     ch = t[i].charAt(0);
     if (Character.isLowerCase(ch)) temp[i] = 2 * ch;
     else temp[i] = 2 * (ch + 32) + 1;
   }
   // 初始化arr[]
   for (int j = 0; j < 52; j++) arr[j] = 0;
   // 入桶
   for (int i = 0; i < len; i++) {
     arr[temp[i] - 194]++;
   }
   // 出桶
   int low = 0, up = 0, tt = 0;
   for (int i = 0, j = 0; i < 52; i++) {
     j = arr[i];
     while (j > 0) {
       if (i % 2 == 0) low = (i + 194) >> 1;
       else {
         tt = (i + 194 - 1) >> 1;
         up = tt - 32;
       }
       System.out.print((char) (i % 2 == 0 ? low : up));
       if (len > 1) System.out.print(",");
       j--;
       len--;
     }
   }
 }
コード例 #29
0
  private static String[] getSuggestionsByValue(final String stringValue) {
    List<String> result = new ArrayList<String>();
    StringBuffer currentWord = new StringBuffer();

    boolean prevIsUpperCase = false;

    for (int i = 0; i < stringValue.length(); i++) {
      final char c = stringValue.charAt(i);
      if (Character.isUpperCase(c)) {
        if (currentWord.length() > 0 && !prevIsUpperCase) {
          result.add(currentWord.toString());
          currentWord = new StringBuffer();
        }
        currentWord.append(c);
      } else if (Character.isLowerCase(c)) {
        currentWord.append(Character.toUpperCase(c));
      } else if (Character.isJavaIdentifierPart(c) && c != '_') {
        if (Character.isJavaIdentifierStart(c) || currentWord.length() > 0 || !result.isEmpty()) {
          currentWord.append(c);
        }
      } else {
        if (currentWord.length() > 0) {
          result.add(currentWord.toString());
          currentWord = new StringBuffer();
        }
      }

      prevIsUpperCase = Character.isUpperCase(c);
    }

    if (currentWord.length() > 0) {
      result.add(currentWord.toString());
    }
    return ArrayUtil.toStringArray(result);
  }
コード例 #30
0
ファイル: Initcap.java プロジェクト: Gbeginner/wantscart-db
 public static String initcap(Comparable<?> param) throws ParseException {
   if (param == null) {
     return null;
   }
   String inputStr = param.toString();
   StringBuilder output = new StringBuilder(inputStr);
   boolean needUpper = true;
   final int len = inputStr.length();
   for (int i = 0; i < len; i++) {
     char c = inputStr.charAt(i);
     if (needUpper && Character.isLetter(c)) {
       if (Character.isLowerCase(c)) {
         output.setCharAt(i, Character.toUpperCase(c));
       }
       needUpper = false;
     } else if (!needUpper) {
       if (!Character.isLetterOrDigit(c)) {
         needUpper = true;
       } else if (Character.isUpperCase(c)) {
         output.setCharAt(i, Character.toLowerCase(c));
       }
     }
   }
   return output.toString();
 }