/** * @return an array of the {@link TemplateElement}s containing the given column and line numbers. * @deprecated Should only be used internally, and might will be removed later. */ @Deprecated public TreePath containingElements(int column, int line) { final ArrayList elements = new ArrayList(); TemplateElement element = rootElement; mainloop: while (element.contains(column, line)) { elements.add(element); for (Enumeration enumeration = element.children(); enumeration.hasMoreElements(); ) { TemplateElement elem = (TemplateElement) enumeration.nextElement(); if (elem.contains(column, line)) { element = elem; continue mainloop; } } break; } if (elements.isEmpty()) { return null; } return new TreePath(elements.toArray()); }
for (Enumeration children = te.children(); children.hasMoreElements(); ) { TemplateElement child = (TemplateElement) children.nextElement(); TemplateElement childmatch = findTemplateElement(child, line);
final Enumeration<TemplateElement> children = templateElement.children(); while (children.hasMoreElements()) { final TemplateElement nextElement = children.nextElement();
public Enumeration children() { final Enumeration e = element.children(); return new Enumeration() { public boolean hasMoreElements() { return e.hasMoreElements(); } public Object nextElement() { return getNode((TemplateElement) e.nextElement()); } }; }
public Enumeration children() { if (nestedBlock instanceof MixedContent) { return nestedBlock.children(); } if (nestedBlock != null) { return Collections.enumeration(Collections12.singletonList(nestedBlock)); } else if (nestedElements != null) { return Collections.enumeration(nestedElements); } return Collections.enumeration(Collections.EMPTY_LIST); }
private void extractVariables(TemplateElement templateElement, FieldsExtractor extractor) throws TemplateModelException { if (DOLLAR_VARIABLE.equals(templateElement.getClass().getSimpleName())) { String fieldName = templateElement.getCanonicalForm(); fieldName = fieldName.substring(2, fieldName.length() - 1); extractor.addFieldName(fieldName); } Enumeration<TemplateElement> enums = templateElement.children(); while (enums.hasMoreElements()) { TemplateElement element = (TemplateElement) enums.nextElement(); extractVariables(element, extractor); } }
private void extractVariables( TemplateElement templateElement, FieldsExtractor extractor ) throws TemplateModelException { if ( DOLLAR_VARIABLE.equals( templateElement.getClass().getSimpleName() ) ) { String fieldName = templateElement.getCanonicalForm(); fieldName = fieldName.substring( 2, fieldName.length() - 1 ); extractor.addFieldName( fieldName, false ); } Enumeration<TemplateElement> enums = templateElement.children(); while ( enums.hasMoreElements() ) { TemplateElement element = (TemplateElement) enums.nextElement(); extractVariables( element, extractor ); } }
/** * @return an array of the {@link TemplateElement}s containing the given column and line numbers. * @deprecated Should only be used internally, and might will be removed later. */ @Deprecated public List containingElements(int column, int line) { final ArrayList elements = new ArrayList(); TemplateElement element = rootElement; mainloop: while (element.contains(column, line)) { elements.add(element); for (Enumeration enumeration = element.children(); enumeration.hasMoreElements(); ) { TemplateElement elem = (TemplateElement) enumeration.nextElement(); if (elem.contains(column, line)) { element = elem; continue mainloop; } } break; } return elements.isEmpty() ? null : elements; }
/** * @return an array of the {@link TemplateElement}s containing the given column and line numbers. * @deprecated Should only be used internally, and might will be removed later. */ @Deprecated public TreePath containingElements(int column, int line) { final ArrayList elements = new ArrayList(); TemplateElement element = rootElement; mainloop: while (element.contains(column, line)) { elements.add(element); for (Enumeration enumeration = element.children(); enumeration.hasMoreElements(); ) { TemplateElement elem = (TemplateElement) enumeration.nextElement(); if (elem.contains(column, line)) { element = elem; continue mainloop; } } break; } if (elements.isEmpty()) { return null; } return new TreePath(elements.toArray()); }
/** * @return an array of the elements containing the given column and line numbers. * @param column the column * @param line the line */ public TreePath containingElements(int column, int line) { ArrayList elements = new ArrayList(); TemplateElement element = rootElement; mainloop: while (element.contains(column, line)) { elements.add(element); for (Enumeration enumeration = element.children(); enumeration.hasMoreElements();) { TemplateElement elem = (TemplateElement) enumeration.nextElement(); if (elem.contains(column, line)) { element = elem; continue mainloop; } } break; } if (elements == null || elements.isEmpty()) { return null; } return new TreePath(elements.toArray()); }
private static TemplateElement findTemplateElement(TemplateElement te, int line) { if(te.getBeginLine() > line || te.getEndLine() < line) { return null; } // Find the narrowest match for(Enumeration children = te.children(); children.hasMoreElements();) { TemplateElement child = (TemplateElement)children.nextElement(); TemplateElement childmatch = findTemplateElement(child, line); if(childmatch != null) { return childmatch; } } // If no child provides narrower match, return this return te; }
final Enumeration<TemplateElement> children = templateElement.children(); while (children.hasMoreElements()) { final TemplateElement nextElement = children.nextElement();
@SuppressWarnings("unchecked") public static Map<String, String> extractMetaData(Template template) { Enumeration children = template.getRootTreeNode().children(); for (TemplateElement child : new EnumerationIterator<TemplateElement>(children)) { if (child instanceof Comment) { Comment c = (Comment) child; return extractTags(c.getText()); } } return null; }
for (Enumeration children = te.children(); children.hasMoreElements(); ) { TemplateElement child = (TemplateElement) children.nextElement(); TemplateElement childmatch = findTemplateElement(child, line);
for (Enumeration children = te.children(); children.hasMoreElements(); ) { TemplateElement child = (TemplateElement) children.nextElement(); TemplateElement childmatch = findTemplateElement(child, line);