예제 #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;
  }
예제 #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);
 }
예제 #3
0
 /**
  * Get the StringNodes which represents a specific key. If there is no node for this key, a new
  * node is created and returned
  *
  * @param key the StringNode key attribute
  * @param isArray if it's an array or not
  * @return the StringNode which represents the key passed as a parameter
  */
 public StringNode getStringNodeByKey(String key, boolean isArray) {
   StringNode result = stringNodesMap.get(key);
   if (result == null) {
     StringNode newNode = new StringNode(key, "");
     newNode.setLocalizationFile(this);
     newNode.setArray(isArray);
     result = this.addStringNode(newNode);
   }
   return result;
 }
예제 #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);
   }
 }