Beispiel #1
0
  /** Add a new StringNode to the list */
  public StringNode addStringNode(StringNode stringNode) {
    StringNode newStringNode = stringNode;

    // check if it's is an array
    if (stringNode.isArray()) {
      StringArray stringArray = findStringArray(stringNode.getKey());
      int position = -1;
      // if (stringNode.getKey().contains("_"))
      if (StringArray.isArrayItem(stringNode.getKey())) {
        // position =
        // Integer.parseInt(stringNode.getKey().split("_")[1]);
        position = StringArray.findItemPosition(stringNode.getKey());
      }
      newStringNode =
          stringArray.addValue(stringNode.getValue(), ((position != -1) ? position : null));
    }

    newStringNode.setLocalizationFile(this);
    stringNodes.add(newStringNode);
    stringNodesMap.put(newStringNode.getKey(), newStringNode);

    this.setDirty(true);

    return newStringNode;
  }
Beispiel #2
0
  /**
   * Remove blank array items
   *
   * @param nodes all nodes
   * @return only non blank array items
   */
  private List<StringNode> removeBlankArrayItems(List<StringNode> nodes) {
    List<StringNode> noBlankArrayItems = new ArrayList<StringNode>();

    for (StringNode node : nodes) {
      if (node.isArray()) {
        if (!node.getValue().equals("")) {
          noBlankArrayItems.add(node);
        }
      } else {
        noBlankArrayItems.add(node);
      }
    }
    return noBlankArrayItems;
  }
Beispiel #3
0
 /** Remove a StringNode from the list */
 public void removeStringNode(StringNode stringNode) {
   if (stringNodes.contains(stringNode)) {
     stringNodes.remove(stringNode);
     stringNodesMap.remove(stringNode.getKey());
     this.setDirty(true);
     // check if it's is an array
     if (stringNode.isArray()) {
       stringNode.getStringArray().removeValue(stringNode);
       if (stringNode.getStringArray().getValues().size() == 0) {
         this.stringArrays.remove(stringNode.getStringArray());
       }
     }
   }
 }