/** * 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); }
/** * Get only the modified StringNodes in this localization file * * @return the modified StringNodes in this localization file */ public List<StringNode> getModifiedStringNodes() { List<StringNode> modifiedStringNodes = new ArrayList<StringNode>(); for (StringNode stringNode : stringNodes) { if (stringNode.isDirty()) { modifiedStringNodes.add(stringNode); } } return modifiedStringNodes; }
/** * Retrieves the values contained in this array as a list of Strings * * @return */ public List<String> getStringValues() { LinkedList<String> result = new LinkedList<String>(); for (StringNode node : this.values) { result.add(node.getValue()); } return result; }
/** * 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; }
/** * 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; }
/** 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()); } } } }
/** 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; }
/** * 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); } }
/* * (non-Javadoc) * * @see * org.eclipse.sequoyah.localization.tools.datamodel.node.Node#setKey(java * .lang.String) */ @Override public void setKey(String key) { super.setKey(key); for (StringArrayItemNode node : values) { node.setKey(key); } }
public XMLElement serialize() { XMLElement element = new XMLElement(); element.setName("svnrelease"); element.addChild(releaseUrl.serialize()); return element; }
public void deserialize(XMLElement element) { if (element.getName().equalsIgnoreCase("svnrelease")) { releaseUrl = new StringNode(); releaseUrl.deserialize(findChild(element, "releaseurl")); } }
public String getReleaseUrl() { return releaseUrl.getValue(); }
@Override protected Integer visitStringNode(StringNode node) { return node.getValue().hashCode(); }
@Override protected Boolean visitStringNode(StringNode node) { return node.getValue().equals(((StringNode) other).getValue()); }