예제 #1
0
  private boolean compare_Character(int operation, char charval, Object value2) {
    if (operation == SUBSTRING) {
      return false;
    }
    char charval2;
    try {
      charval2 = ((String) value2).charAt(0);
    } catch (IndexOutOfBoundsException e) {
      return false;
    }

    switch (operation) {
      case EQUAL:
        {
          return charval == charval2;
        }
      case APPROX:
        {
          return (charval == charval2)
              || (Character.toUpperCase(charval) == Character.toUpperCase(charval2))
              || (Character.toLowerCase(charval) == Character.toLowerCase(charval2));
        }
      case GREATER:
        {
          return charval >= charval2;
        }
      case LESS:
        {
          return charval <= charval2;
        }
    }
    return false;
  }
예제 #2
0
 @NotNull
 private static KeyStroke getTypedOrPressedKeyStroke(char c, int modifiers) {
   if (modifiers == 0) {
     return getKeyStroke(c);
   } else if (modifiers == SHIFT_MASK) {
     return getKeyStroke(Character.toUpperCase(c));
   } else {
     return getKeyStroke(Character.toUpperCase(c), modifiers);
   }
 }
예제 #3
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);
  }
예제 #4
0
 private void updlayout() {
   synchronized (ui.sess.glob.paginae) {
     List<Pagina> cur = new ArrayList<Pagina>();
     loading = !cons(this.cur, cur);
     Collections.sort(cur, sorter);
     int i = curoff;
     hotmap.clear();
     for (int y = 0; y < gsz.y; y++) {
       for (int x = 0; x < gsz.x; x++) {
         Pagina btn = null;
         if ((this.cur != null) && (x == gsz.x - 1) && (y == gsz.y - 1)) {
           btn = bk;
         } else if ((cur.size() > ((gsz.x * gsz.y) - 1)) && (x == gsz.x - 2) && (y == gsz.y - 1)) {
           btn = next;
         } else if (i < cur.size()) {
           Resource.AButton ad = cur.get(i).act();
           if (ad.hk != 0) hotmap.put(Character.toUpperCase(ad.hk), cur.get(i));
           btn = cur.get(i++);
         }
         layout[x][y] = btn;
       }
     }
     pagseq = ui.sess.glob.pagseq;
   }
 }
예제 #5
0
 // keyboard discovery code
 private void _mapKey(char charCode, int keyindex, boolean shift, boolean altgraph) {
   log("_mapKey: " + charCode);
   // if character is not in map, add it
   if (!charMap.containsKey(new Integer(charCode))) {
     log("Notified: " + (char) charCode);
     KeyEvent event =
         new KeyEvent(
             applet(),
             0,
             0,
             (shift ? KeyEvent.SHIFT_MASK : 0) + (altgraph ? KeyEvent.ALT_GRAPH_MASK : 0),
             ((Integer) vkKeys.get(keyindex)).intValue(),
             (char) charCode);
     charMap.put(new Integer(charCode), event);
     log("Mapped char " + (char) charCode + " to KeyEvent " + event);
     if (((char) charCode) >= 'a' && ((char) charCode) <= 'z') {
       // put shifted version of a-z in automatically
       int uppercharCode = (int) Character.toUpperCase((char) charCode);
       event =
           new KeyEvent(
               applet(),
               0,
               0,
               KeyEvent.SHIFT_MASK + (altgraph ? KeyEvent.ALT_GRAPH_MASK : 0),
               ((Integer) vkKeys.get(keyindex)).intValue(),
               (char) uppercharCode);
       charMap.put(new Integer(uppercharCode), event);
       log("Mapped char " + (char) uppercharCode + " to KeyEvent " + event);
     }
   }
 }
예제 #6
0
 public char getCode() {
   if (isWhite) {
     return Character.toUpperCase(code);
   } else {
     return code;
   }
 }
예제 #7
0
 public void addMatchingSetters() {
   check(implInterface || !dataTypeIn.isInterface());
   Set<String> usedFields = new HashSet<>();
   if (constructorParams != null) {
     usedFields.addAll(constructorParams);
   }
   if (factoryParams != null) {
     usedFields.addAll(factoryParams);
   }
   for (List<String> list : setters.values()) {
     usedFields.addAll(list);
   }
   for (String fieldName : fields.keySet()) {
     FieldGen fieldGen = fields.get(fieldName);
     Method getter = fieldGen.method;
     if (getter == null) continue;
     if (usedFields.contains(fieldName)) continue;
     String setterName =
         "set" + Character.toUpperCase(fieldName.charAt(0)) + fieldName.substring(1);
     try {
       Method setter;
       if (implInterface) setter = dataTypeOut.getMethod(setterName, getter.getReturnType());
       else setter = dataTypeIn.getMethod(setterName, getter.getReturnType());
       if (!isPrivate(setter.getModifiers())) {
         addSetter(setter, asList(fieldName));
       }
     } catch (NoSuchMethodException e) {
       throw new RuntimeException(e);
     }
   }
 }
예제 #8
0
  public boolean globtype(char k, KeyEvent ev) {
    if (ev.isAltDown() || ev.isControlDown() || k == 0) {
      return false;
    }
    k = (char) ev.getKeyCode();
    if (Character.toUpperCase(k) != k) {
      return false;
    }

    if ((k == 27) && (this.cur != null)) {
      this.cur = null;
      curoff = 0;
      updlayout();
      return (true);
    } else if ((k == KeyEvent.VK_N) && (layout[gsz.x - 2][gsz.y - 1] == next)) {
      use(next);
      return (true);
    }
    Pagina r = hotmap.get(k);
    if (r != null) {
      use(r);
      return (true);
    }
    return (false);
  }
예제 #9
0
 public static Tex rendertt(Resource res, boolean withpg, boolean hotkey) {
   Resource.AButton ad = res.layer(Resource.action);
   Resource.Pagina pg = res.layer(Resource.pagina);
   String tt = ad.name;
   BufferedImage xp = null, food = null;
   if (hotkey) {
     int pos = tt.toUpperCase().indexOf(Character.toUpperCase(ad.hk));
     if (pos >= 0)
       tt =
           tt.substring(0, pos)
               + "$col[255,255,0]{"
               + tt.charAt(pos)
               + "}"
               + tt.substring(pos + 1);
     else if (ad.hk != 0) tt += " [" + ad.hk + "]";
   }
   if (withpg) {
     if (pg != null) {
       tt += "\n\n" + pg.text;
     }
     xp = getXPgain(ad.name);
     food = getFood(ad.name);
   }
   BufferedImage img = ttfnd.render(tt, 300).img;
   if (xp != null) {
     img = ItemInfo.catimgs(3, img, xp);
   }
   if (food != null) {
     img = ItemInfo.catimgs(3, img, food);
   }
   return (new TexI(img));
 }
예제 #10
0
  /**
   * There are some nasty bugs for introspection with generics. This method addresses those nasty
   * bugs and tries to find proper methods if available
   * http://bugs.sun.com/view_bug.do?bug_id=6788525 http://bugs.sun.com/view_bug.do?bug_id=6528714
   *
   * @param descriptor
   * @return
   */
  private static PropertyDescriptor fixGenericDescriptor(
      Class<?> clazz, PropertyDescriptor descriptor) {
    Method readMethod = descriptor.getReadMethod();
    Method writeMethod = descriptor.getWriteMethod();

    if (readMethod != null && (readMethod.isBridge() || readMethod.isSynthetic())) {
      String propertyName = descriptor.getName();
      // capitalize the first letter of the string;
      String baseName = Character.toUpperCase(propertyName.charAt(0)) + propertyName.substring(1);
      String setMethodName = "set" + baseName;
      String getMethodName = "get" + baseName;
      Method[] methods = clazz.getMethods();
      for (Method method : methods) {
        if (method.getName().equals(getMethodName) && !method.isBridge() && !method.isSynthetic()) {
          try {
            descriptor.setReadMethod(method);
          } catch (IntrospectionException e) {
            // move on
          }
        }
        if (method.getName().equals(setMethodName) && !method.isBridge() && !method.isSynthetic()) {
          try {
            descriptor.setWriteMethod(method);
          } catch (IntrospectionException e) {
            // move on
          }
        }
      }
    }
    return descriptor;
  }
예제 #11
0
  private String toJavaName(String name, boolean firstLetterIsUpperCase) {

    name = name.toLowerCase();

    StringBuffer res = new StringBuffer();

    boolean nextIsUpperCase = firstLetterIsUpperCase;

    for (int i = 0; i < name.length(); i++) {
      char c = name.charAt(i);

      if (nextIsUpperCase) {
        c = Character.toUpperCase(c);
      }

      if (Character.isLetter(c)) {
        res.append(c);
        nextIsUpperCase = false;
      } else {
        nextIsUpperCase = true;
      }
    }

    return res.toString();
  }
예제 #12
0
  private Object newBean(Element bean, boolean useCache) throws ConfigurationException {
    String id = bean.getAttributeValue("id");

    if (useCache && beanMap.containsKey(id)) {
      return beanMap.get(id);
    }

    String className = bean.getAttributeValue("class");
    Object beanInstance = getFactory().newInstance(className);
    List propertyList = bean.getChildren("property");
    for (Object aPropertyList : propertyList) {
      Element propertyElement = (Element) aPropertyList;
      String pName = propertyElement.getAttributeValue("name");
      String pValue = propertyElement.getAttributeValue("value");
      String pRef = propertyElement.getAttributeValue("ref");
      String methodName = "set" + Character.toUpperCase(pName.charAt(0)) + pName.substring(1);
      if (pValue == null) {
        getFactory().invoke(beanInstance, methodName, getBean(pRef));
      } else {
        getFactory().invoke(beanInstance, methodName, pValue);
      }
    }
    String startMethod = bean.getAttributeValue("start-method");
    if (startMethod != null) {
      getFactory().invoke(beanInstance, startMethod, null);
    }
    if (useCache) // indication for a singleton
    beanMap.put(id, beanInstance);
    // Return the bean instance
    return beanInstance;
  }
예제 #13
0
 public static String toCamelCase(String value, StringBuilder sb) {
   boolean changed = false;
   for (int i = 0; i < value.length(); i++) {
     char c = value.charAt(i);
     if (c == '_') {
       if (!changed) {
         if (sb != null) {
           sb.setLength(0);
         } else {
           sb = new StringBuilder();
         }
         // copy it over here
         for (int j = 0; j < i; j++) {
           sb.append(value.charAt(j));
         }
         changed = true;
       }
       if (i < value.length() - 1) {
         sb.append(Character.toUpperCase(value.charAt(++i)));
       }
     } else {
       if (changed) {
         sb.append(c);
       }
     }
   }
   if (!changed) {
     return value;
   }
   return sb.toString();
 }
예제 #14
0
 private static String getGetterSetterMethodName(String propertyName, String operation) {
   StringWriter writer = new StringWriter();
   writer.write(operation);
   writer.write(Character.toUpperCase(propertyName.charAt(0)));
   writer.write(propertyName.substring(1));
   return writer.toString();
 }
 /**
  * Checks if character is part of a hexadecimal number.
  *
  * @param ch character to be checked
  * @return true if the character is a hex digit
  */
 public static boolean isHexDigit(char ch) {
   if (isDigit(ch)) return true;
   else {
     char ch1 = Character.toUpperCase(ch);
     return ch1 == 'A' || ch1 == 'B' || ch1 == 'C' || ch1 == 'D' || ch1 == 'E' || ch1 == 'F';
   }
 }
예제 #16
0
  public void actionPerformed(ActionEvent e) {
    if (e.getSource() == from) {
      String tmpFrom = from.getText().trim();
      String tmpTo = to.getText().trim();
      if (tmpFrom.equals("MST") || tmpFrom.equals("mst")) findMinSpan();
      else {
        try { // check if from exists
          // String str = from.getText();
          // fixa så man kan skippa att skriva första med stor bokstav
          tmpFrom = Character.toUpperCase(tmpFrom.charAt(0)) + tmpFrom.substring(1);
          int pos = noderna.findLeading(tmpFrom).getNodeNo();
          route.setText(introText + "\n");
          from.setText(noderna.find(pos).toString());
        } catch (NullPointerException npe) {
          route.setText(felTextStart + "\n");
          return;
        }
        if (!tmpTo.equals("")) {
          findShort();
        }
      }
    } else if (e.getSource() == to) {
      String tmpFrom = from.getText().trim();
      String tmpTo = to.getText().trim();
      if (tmpTo.equals("MST") || tmpTo.equals("mst")) findMinSpan();
      else {
        try { // check if to exists
          // String str = to.getText();
          tmpTo = Character.toUpperCase(tmpTo.charAt(0)) + tmpTo.substring(1);
          int pos = noderna.findLeading(tmpTo).getNodeNo();
          route.setText(introText + "\n");
          to.setText(noderna.find(pos).toString());
        } catch (NullPointerException npe) {
          route.setText(felTextStart + "\n");
          return;
        }
        if (!tmpFrom.equals("")) {
          findShort();
        }
      }

      /*
      else if ( ! from.getText().equals("") )
      	findShort();
      */
    }
  }
 /**
  * Does the current buffer match the given item name? itemName is the name of the IMAP item to
  * compare against. NOTE that itemName *must* be all uppercase. If the match is successful, the
  * buffer pointer (index) is incremented past the matched item.
  */
 private boolean match(String itemName) {
   int len = itemName.length();
   for (int i = 0, j = index; i < len; )
     // IMAP tokens are case-insensitive. We store itemNames in
     // uppercase, so convert operand to uppercase before comparing.
     if (Character.toUpperCase((char) buffer[j++]) != itemName.charAt(i++)) return false;
   index += len;
   return true;
 }
예제 #18
0
  // ====================================================================
  private void findShort() {
    // svårt att behålla linjefärgerna?
    int start, s**t;
    try { // read from station
      String str = from.getText();
      str = Character.toUpperCase(str.charAt(0)) + str.substring(1);
      start = noderna.find(str).getNodeNo();
    } catch (NullPointerException npe) {
      route.setText(felTextStart + "\n");
      return;
    }
    try { // read to station
      String str = to.getText();
      str = Character.toUpperCase(str.charAt(0)) + str.substring(1);
      s**t = noderna.find(str).getNodeNo();
    } catch (NullPointerException npe) {
      route.setText(felTextSlut + "\n");
      return;
    }

    double totWeight = 0;
    int totNodes = 0;
    route.setText("");
    karta.clearLayer(DrawGraph.Layer.OVERLAY);
    Iterator<BusEdge> it = grafen.shortestPath(start, s**t);
    while (it.hasNext()) {
      BusEdge e = it.next();
      route.append(makeText1(e) + "\n");
      totNodes++;
      totWeight += e.getWeight();
      // draw the shortest path
      BusStop from = noderna.find(e.from), to = noderna.find(e.to);
      karta.drawLine(
          from.xpos, from.ypos, to.xpos, to.ypos, Color.black, 4.0, DrawGraph.Layer.OVERLAY);
    }
    karta.repaint();
    route.append("Antal: " + totNodes + " totalvikt: " + totWeight + "\n");
    from.setText("");
    to.setText("");
  } // findShort
  /* Following are the method for Lookup Device name*/
  private static String LookupDevice(String substring) {
    // TODO Auto-generated method stub
    File p =
        new File(
            "/Users/luozhongyi/Desktop/2015 Fall course/CS 6400/MacPrefix2.txt"); // The path of
                                                                                  // MacPrefix.txt
    Scanner pcon = null;

    try {
      pcon = new Scanner(p);
    } catch (FileNotFoundException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }

    String pcurrentline;
    String Device = null;
    char[] prefix = {'0', '0', '0', '0', '0', '0', '0', '0'};
    // char px;
    int flag = 0;

    // prefix=substring.substring(0, 8); // rember to transfer to uppercase
    // System.out.println(substring);
    for (int i = 0; i < 8; i++) {
      // System.out.println(i+"");
      // System.out.println(Character.toUpperCase(substring.charAt(i)));
      if (Character.isLetter(substring.charAt(i)))
        prefix[i] = Character.toUpperCase(substring.charAt(i));
      else
        // System.out.println(i+"");
        // System.out.println(substring.charAt(i));
        prefix[i] = substring.charAt(i);
    } // get the uppercase of prefix

    /* Find in MacPrefix txt */
    while (pcon.hasNextLine()) {
      pcurrentline = pcon.nextLine().toString();
      if (pcurrentline.startsWith(new String(prefix))) { // find the first match and return
        flag = 1;
        pcurrentline = pcurrentline.replaceAll("\\s+", " "); // delete duplicate " ";
        // System.out.println(pcurrentline);
        Device =
            pcurrentline.substring(
                pcurrentline.indexOf(' ') + 1,
                pcurrentline.indexOf(' ', pcurrentline.indexOf(' ') + 1));
      } else ;
    }
    if (flag == 0) Device = "DEFAULT";
    // System.out.println(Device);
    pcon.close();
    return Device;
  }
예제 #20
0
 private static String changeFirstCharacterCase(String str, boolean capitalize) {
   if (str == null || str.length() == 0) {
     return str;
   }
   StringBuilder sb = new StringBuilder(str.length());
   if (capitalize) {
     sb.append(Character.toUpperCase(str.charAt(0)));
   } else {
     sb.append(Character.toLowerCase(str.charAt(0)));
   }
   sb.append(str.substring(1));
   return sb.toString();
 }
예제 #21
0
  public static void main(String args[]) {

    int NUM_LETTERS = 27;
    char[] alfabet = {
      'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S',
      'T', 'U', 'V', 'W', 'X', 'Y', 'Z', '?'
    };

    Scanner in = new Scanner(System.in);
    int L = in.nextInt();
    in.nextLine();
    int H = in.nextInt();
    in.nextLine();
    // to store the letter in asci artM
    char[][] art = new char[H][L * NUM_LETTERS];
    String T = in.nextLine(); // text to translate

    System.err.println("create array L:" + L + "/H:" + H + "/to translate:" + T);

    // saving asci art
    for (int i = 0; i < H; i++) {
      String ROW = in.nextLine(); // first line of all letters in asci art
      // the ROW must be saved in L chars groups
      // System.err.println("readed->" + ROW);
      char[] aux = ROW.toCharArray();
      for (int j = 0; j < aux.length; j++) {
        // System.err.println("guardando->["+i+"]["+j+"]" + aux[j]);
        art[i][j] = aux[j];
      }
    }

    StringBuilder builder = new StringBuilder();
    char[] translation = T.toCharArray();
    for (int m = 0; m < H; m++) {
      StringBuilder linea = new StringBuilder();
      for (int j = 0; j < translation.length; j++) {
        // neet to get char -> letter number to get position
        int position = returnPosition(Character.toUpperCase(translation[j]), alfabet);

        int start = (position * L);
        for (int u = start; u < (start + L); u++) {
          linea.append(art[m][u]);
        }
      }
      System.out.println(linea);
    }

    // Write an action using System.out.println()
    // To debug: System.err.println("Debug messages...");

  }
 public static Map<String, Chromosome> loadFromListNameFile(String fileName)
     throws FileNotFoundException {
   ArrayList<String> listUser = new ArrayList<String>();
   ArrayList<String> listUserCase = new ArrayList<String>();
   Scanner s = new Scanner(new File(fileName));
   char[] c;
   while (s.hasNext()) {
     listUser = new ArrayList<String>(Arrays.asList(s.nextLine().split(", ")));
     for (String str : listUser) {
       str = str.toLowerCase();
       c = str.toCharArray();
       c[0] = Character.toUpperCase(c[0]);
       str = String.valueOf(c);
       listUserCase.add(str);
     }
   }
   ArrayList<ArrayList<String>> dataGenom = loadArrayList(nameHardcoreFile);
   ArrayList<ArrayList<String>> arrrrr =
       new ArrayList<ArrayList<String>>(); // <-- only needed genes with full information
   Map<String, Chromosome> chrs = getSorteredMap();
   int index = 0;
   for (String nameGeneUser : listUserCase) {
     for (ArrayList<String> gene : dataGenom) {
       if (nameGeneUser.equals(gene.get(3))) {
         arrrrr.add(new ArrayList<String>((gene)));
         break;
       }
     }
   }
   int rowIndex = 0;
   int row = 0;
   int countGenes = 0;
   while (arrrrr.size() != row) {
     Chromosome chr = new Chromosome(arrrrr.get(row).get(0));
     rowIndex = 0;
     while (arrrrr.size() > rowIndex) {
       if (chr.nameChrom.equals(arrrrr.get(rowIndex).get(0)) && arrrrr.size() > rowIndex) {
         chr.addInterval(
             new Interval(
                 Integer.parseInt(arrrrr.get(rowIndex).get(1)),
                 Integer.parseInt(arrrrr.get(rowIndex).get(2)),
                 arrrrr.get(rowIndex).get(3).toString())); // TODO::
       }
       rowIndex++;
     }
     row++;
     chrs.put(chr.nameChrom, chr);
   }
   return chrs;
 }
예제 #23
0
  /**
   * Standardization method for any URI, compatible with dbpedia extraction framework - All
   * dbpedia/wikipedia entity Uris start with http://dbpedia.org/resource/ - We then apply
   * UrlDecoder.decode() until no '%' char remains - White space are replaced by '_', same for '\t'
   * - The first letter for the suffix is uppercased. - Several spaces are transformed into one -
   * the suffix is trimmed - The following characters are percent encoded "#%<>?[\]^`{|}
   */
  public static String uriStandardization(
      String uri, String optional_prefix, String optional_language) {
    String suffix = uri;
    String standard_prefix = "http://dbpedia.org/resource/";
    if (optional_language != null && !optional_language.equals("en"))
      standard_prefix = "http://" + optional_language + ".dbpedia.org/resource/";
    if (suffix.contains("/") && !suffix.endsWith("/")) {
      int index_last_slash = suffix.lastIndexOf('/');
      suffix = uri.substring(index_last_slash + 1);
    }

    // apply UrlDecoder until there is no % remaining
    int counter = 0;
    while (suffix.contains("%") && counter < 5) {
      try {
        suffix = URLDecoder.decode(suffix, "UTF-8");
      } catch (Exception e) {
      }
      ;
      counter++;
    }

    // replace ' ' with '\t'
    suffix = suffix.trim();
    suffix = suffix.replaceAll(" +", "_");
    suffix = suffix.replaceAll("\\t", "_");
    if (suffix.length() == 0) suffix = "incorrect_uri";
    if (!Character.isUpperCase(suffix.charAt(0)))
      suffix = Character.toUpperCase(suffix.charAt(0)) + suffix.substring(1);

    // escape the following characters "#%<>?[\]^`{|}
    StringBuilder sb = new StringBuilder();
    for (int i = 0; i < suffix.length(); i++) {
      char c = suffix.charAt(i);
      boolean replaced = false;
      for (int j = 0; j < uri_to_replace.length; j++) {
        if (c == uri_to_replace[j]) {
          sb.append(uri_replacement[j]);
          replaced = true;
          break;
        }
      }
      if (!replaced) sb.append(c);
    }
    suffix = sb.toString();

    if (optional_prefix == null) return standard_prefix + suffix;
    return optional_prefix + suffix;
  }
  /**
   * Returns the NameSurferEntry associated with this name, if one exists. If the name does not
   * appear in the database, this method returns null.
   */
  public NameSurferEntry findEntry(String name) {

    char firstLetter = name.charAt(0);
    if (Character.isLowerCase(firstLetter) == true) {
      firstLetter = Character.toUpperCase(firstLetter);
    }
    String remainingLetters = name.substring(1);
    remainingLetters = remainingLetters.toLowerCase();
    name = firstLetter + remainingLetters;

    if (namesDataBase.containsKey(name)) {
      return namesDataBase.get(name);
    }
    return null;
  }
예제 #25
0
파일: Token.java 프로젝트: nikhi/basex
 /**
  * Converts the given string to camel case.
  *
  * @param string string to convert
  * @return resulting string
  */
 public static String camelCase(final String string) {
   final StringBuilder sb = new StringBuilder(string.length());
   boolean dash = false;
   for (int p = 0; p < string.length(); p++) {
     final char ch = string.charAt(p);
     if (dash) {
       sb.append(Character.toUpperCase(ch));
       dash = false;
     } else {
       dash = ch == '-';
       if (!dash) sb.append(ch);
     }
   }
   return sb.toString();
 }
예제 #26
0
 @Override
 public String HeShe() {
   final char c =
       ((genderName != null) && (genderName.length() > 0))
           ? Character.toUpperCase(genderName.charAt(0))
           : (char) getStat(STAT_GENDER);
   switch (c) {
     case 'M':
       return CMLib.lang().L("He");
     case 'F':
       return CMLib.lang().L("She");
     default:
       return CMLib.lang().L("It");
   }
 }
예제 #27
0
 private void castAndSetProperty(
     InvokeInstruction insn, String property, List<Instruction> instructions, Class<?> primitive) {
   Variable castVar = program.createVariable();
   InvokeInstruction castInvoke = new InvokeInstruction();
   castInvoke.setType(InvocationType.SPECIAL);
   String primitiveCapitalized = primitive.getName();
   primitiveCapitalized =
       Character.toUpperCase(primitiveCapitalized.charAt(0)) + primitiveCapitalized.substring(1);
   castInvoke.setMethod(
       new MethodReference(
           ResourceAccessor.class, "castFrom" + primitiveCapitalized, primitive, Object.class));
   castInvoke.getArguments().add(insn.getArguments().get(0));
   castInvoke.setReceiver(castVar);
   instructions.add(castInvoke);
   setProperty(insn, property, instructions, castVar);
 }
예제 #28
0
  public static void main(String[] args) throws FileNotFoundException {
    File file = new File(args[0]);
    Scanner in = new Scanner(file);

    while (in.hasNextLine()) {
      String result = "";
      String line = in.nextLine();
      Scanner lineScan = new Scanner(line);
      while (lineScan.hasNext()) {
        String word = lineScan.next();
        result += Character.toUpperCase(word.charAt(0)) + word.substring(1) + " ";
      }

      System.out.println(result.trim());
    }
  }
예제 #29
0
파일: EmuThread.java 프로젝트: rexut/jkcemu
 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);
     }
   }
 }
예제 #30
0
 /**
  * Getters/Setters are supposed to be kept with their associated property. Search the list of
  * entries to find the property and attach the setter.
  *
  * @param entries list of all items (methods, fields) in the class.
  */
 private void hookGetterToProperty(List<ClassContentsEntry> entries) {
   ListIterator<ClassContentsEntry> li = entries.listIterator();
   String property = MethodUtil.getPropertyName((PsiMethod) myEnd);
   while (li.hasNext()) {
     Object o = li.next();
     if (o instanceof FieldEntry) {
       FieldEntry fe = (FieldEntry) o;
       StringBuffer sb = new StringBuffer(fe.getName());
       sb.setCharAt(0, Character.toUpperCase(sb.charAt(0)));
       if (fe.getGetterMethod() == null && property.equals(sb.toString())) {
         fe.setGetterMethod(this);
         myKeptWithProperty = true;
         break;
       }
     }
   }
 }