@Override public void endElement(String uri, String localName, String qName) { if (qName.equals("target")) { // End 'target': Save the preceding raw text (if any). Then create a SoyMsg object from the // collected message data and add it to msgs list. if (currRawTextPart != null) { currMsgParts.add(new SoyMsgRawTextPart(currRawTextPart)); currRawTextPart = null; } isInMsg = false; if (currMsgParts.size() > 0) { msgs.add(new SoyMsg( currMsgId, targetLocaleString, null, null, false, null, null, currMsgParts)); } } }
currMsgParts.add(new SoyMsgRawTextPart(currRawTextPart)); currRawTextPart = null;
/** * Builds the list of SoyMsgParts for all the children of a given parent node. * @param parent Can be MsgNode, MsgPluralCaseNode, MsgPluralDefaultNode, * MsgSelectCaseNode, or MsgSelectDefaultNode. * @param msgNode The MsgNode containing 'parent'. */ private static List<SoyMsgPart> buildMsgPartsForChildren( BlockNode parent, MsgNode msgNode) { List<SoyMsgPart> msgParts = Lists.newArrayList(); for (StandaloneNode child : parent.getChildren()) { if (child instanceof RawTextNode) { String rawText = ((RawTextNode) child).getRawText(); msgParts.add(new SoyMsgRawTextPart(rawText)); } else if (child instanceof MsgPlaceholderNode) { String placeholderName = msgNode.getPlaceholderName((MsgPlaceholderNode) child); msgParts.add(new SoyMsgPlaceholderPart(placeholderName)); } else if (child instanceof MsgPluralRemainderNode) { msgParts.add(new SoyMsgPluralRemainderPart( msgNode.getPluralVarName(child.getNearestAncestor(MsgPluralNode.class)))); } else if (child instanceof MsgPluralNode) { msgParts.add(buildMsgPartForPlural((MsgPluralNode) child, msgNode)); } else if (child instanceof MsgSelectNode) { msgParts.add(buildMsgPartForSelect((MsgSelectNode) child, msgNode)); } } return msgParts; }