Example #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;
  }
Example #2
0
 /**
  * Set the list of StringNodes which are part of the file
  *
  * @param stringNodes the list of StringNodes which are part of the file
  */
 public void setStringNodes(List<StringNode> stringNodes) {
   for (StringNode stringNode : stringNodes) {
     this.stringNodesMap.put(stringNode.getKey(), stringNode);
     stringNode.setLocalizationFile(this);
   }
   this.stringNodes.addAll(stringNodes);
 }
Example #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());
       }
     }
   }
 }
Example #4
0
 /**
  * Set the list of StringArrays which are part of the file
  *
  * @param stringArrays the list of StringArrays which are part of the file
  */
 public void setStringArrays(List<StringArray> stringArrays) {
   if (stringArrays != null) {
     for (StringArray stringArray : stringArrays) {
       List<StringNode> stringNodes = stringArray.getValues();
       for (StringNode stringNode : stringNodes) {
         this.stringNodesMap.put(stringNode.getKey(), stringNode);
         stringNode.setLocalizationFile(this);
         stringNode.setArray(true);
       }
       this.stringNodes.addAll(stringNodes);
     }
     this.stringArrays.addAll(stringArrays);
   }
 }