public String getPackedVersionString() {
   ICFLibAnyObj scopeDef;
   ICFBamVersionObj versionLeafDef = getVersionLeaf();
   List<String> invertedNodeNames = new ArrayList<String>();
   while (versionLeafDef != null) {
     invertedNodeNames.add(getVersionStringForLeafDef(versionLeafDef));
     scopeDef = versionLeafDef.getObjScope();
     if (scopeDef == null) {
       versionLeafDef = null;
     } else if (scopeDef instanceof ICFBamMinorVersionObj) {
       versionLeafDef = (ICFBamMinorVersionObj) scopeDef;
     } else if (scopeDef instanceof ICFBamMajorVersionObj) {
       versionLeafDef = (ICFBamMajorVersionObj) scopeDef;
     } else if (scopeDef instanceof ICFBamVersionObj) {
       versionLeafDef = (ICFBamVersionObj) scopeDef;
     } else {
       versionLeafDef = null;
     }
   }
   String ret = "";
   for (int idx = invertedNodeNames.size() - 1; idx >= 0; idx--) {
     if (ret.length() == 0) {
       ret = invertedNodeNames.get(idx);
     } else {
       ret = ret + invertedNodeNames.get(idx);
     }
   }
   return (ret);
 }
Exemplo n.º 2
0
  /**
   * Parse a string value and covert it to its proper data type.
   *
   * @param value
   * @return The parsed value.
   * @throws ParsingException Thrown if not Advisory is available and there was an error parsing.
   */
  @SuppressWarnings("unchecked")
  public static <T> T parseValue(String value) throws ParsingException {
    final T result;

    assert value != null;

    /*
     * todo Restructure the whole class so I've got parse and parseArray as
     * static methods and the share code properly.
     */
    if ("null".equals(value)) {
      result = null;
    } else {
      final List<Object> list = new ArrayList<>();
      final Text t = new Text();
      t.append(value);

      if (any(t, list) && t.isEof()) {
        result = (T) list.get(0);
      } else {
        error("Count not parse value: " + value);
        result = null;
      }
    }

    return result;
  }
Exemplo n.º 3
0
 public static int compare(List o1, List o2) {
   int s1_size = o1.size();
   int s2_size = o2.size();
   if (s1_size < s2_size) {
     return -1;
   } else if (s1_size > s2_size) {
     return 1;
   } else {
     for (int i = 0; i != s1_size; ++i) {
       Object e1 = o1.get(i);
       Object e2 = o2.get(i);
       int c = compare(e1, e2);
       if (c != 0) {
         return c;
       }
     }
     return 0;
   }
 }
Exemplo n.º 4
0
 static void test() {
   int q = 0;
   while (true) {
     if (++q == 100) {
       System.err.println("Test");
       q = 0;
     }
     int[] a = new int[rand.nextInt(100000) + 1];
     for (int i = 0; i < a.length; i++) {
       a[i] = rand.nextInt(100);
     }
     int e = rand.nextInt(5) + 1;
     for (int i = 0; i < e; i++) {
       a[rand.nextInt(a.length)] = allLucky.get(rand.nextInt(allLucky.size()));
     }
     solve(a);
   }
 }
Exemplo n.º 5
0
 /** Given an input string, level, and optionally a tag length, find a matching prefix. */
 private PrefixMatch findPrefixMatch(
     String input, TagLengthList tagLength, LevelTypeList level_type) {
   List<PrefixMatch> match_list = new ArrayList<PrefixMatch>();
   PrefixTree<PrefixMatch> tree = prefix_tree_map.get(level_type);
   assert tree != null;
   List<PrefixMatch> list = tree.search(input);
   if (!list.isEmpty()) {
     if (tagLength == null) match_list.addAll(list);
     else {
       for (PrefixMatch match : list)
         if (match.getScheme().getTagLength() == tagLength) match_list.add(match);
     }
   }
   if (match_list.isEmpty())
     throw new TDTException("No schemes or levels matched the input value");
   else if (match_list.size() > 1)
     throw new TDTException("More than one scheme/level matched the input value");
   else return match_list.get(0);
 }
Exemplo n.º 6
0
  static {
    allLucky.add(4);
    allLucky.add(7);
    for (int i = 0; i < allLucky.size(); i++) {
      int j = allLucky.get(i);
      {
        long e = j * 10L + 4;
        if (e < Integer.MAX_VALUE) {
          allLucky.add((int) e);
        }
      }

      {
        long e = j * 10L + 7;
        if (e < Integer.MAX_VALUE) {
          allLucky.add((int) e);
        }
      }
    }
  }
 private MetaProperty getMetaProperty(int i) {
   return (MetaProperty) metaProperties.get(i);
 }