本文整理汇总了Java中org.jdom2.util.IteratorIterable类的典型用法代码示例。如果您正苦于以下问题:Java IteratorIterable类的具体用法?Java IteratorIterable怎么用?Java IteratorIterable使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IteratorIterable类属于org.jdom2.util包,在下文中一共展示了IteratorIterable类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: listTemplates
import org.jdom2.util.IteratorIterable; //导入依赖的package包/类
private void listTemplates() {
List<Element> list = xsl.getChildren("template", MCRConstants.XSL_NAMESPACE);
IteratorIterable<Element> callTemplateElements = xsl
.getDescendants(Filters.element("call-template", MCRConstants.XSL_NAMESPACE));
LinkedList<Element> templates = new LinkedList<>(list);
HashSet<String> callNames = new HashSet<>();
for (Element callTemplate : callTemplateElements) {
String name = callTemplate.getAttributeValue("name");
if (callNames.add(name)) {
templates.add(callTemplate);
}
}
for (Element template : templates) {
Element copy = template.clone();
copy.removeContent();
this.templates.add(copy);
}
}
示例2: process
import org.jdom2.util.IteratorIterable; //导入依赖的package包/类
@Override
public Document process(final Map<String, Object> context, final Document document, final Slide slide,
final Resources resources, final Configuration configuration) {
final IteratorIterable<Element> apElements = document.getDescendants(Filters.element(PPTXDocument.P_ELEMENT,
getNamespace()));
final List<Element> apElementsList = new ArrayList<>();
while (apElements.hasNext()) {
apElementsList.add(apElements.next());
}
for (Element ap : apElementsList) {
final List<Element> apChildrenList = ap.getChildren();
if (apChildrenList.size() != 0) {
final List<Element> arabrElementsListResult = processArAndABrElements(apChildrenList, configuration
.getParserFactory().createParser());
int firstArElementIndex = ap.indexOf(ap.getChild(PPTXDocument.R_ELEMENT, getNamespace()));
if (firstArElementIndex < 0) {
firstArElementIndex = 0;
}
ap.removeChildren(PPTXDocument.R_ELEMENT, getNamespace());
ap.removeChildren(PPTXDocument.BR_ELEMENT, getNamespace());
ap.addContent(firstArElementIndex, arabrElementsListResult);
}
}
return document;
}
示例3: process
import org.jdom2.util.IteratorIterable; //导入依赖的package包/类
@Override
public Document process(final Map<String, Object> context, final Document document, final Slide slide,
final Resources resources, final Configuration configuration) throws JODTemplateException {
final IteratorIterable<Element> atElements = document.getDescendants(Filters.element(PPTXDocument.T_ELEMENT,
getNamespace()));
final List<Element> atElementsList = new ArrayList<>();
while (atElements.hasNext()) {
atElementsList.add(atElements.next());
}
for (Element at : atElementsList) {
if (at.getContentSize() != 0) {
final Content content = at.getContent(0);
if (content instanceof Comment) {
final Comment comment = (Comment) content;
processComment(comment, at, slide, configuration);
}
}
}
return document;
}
示例4: getChildren
import org.jdom2.util.IteratorIterable; //导入依赖的package包/类
private List<Element> getChildren(Element parentElement, String tagName) {
IteratorIterable<Content> iter = parentElement.getDescendants();
List<Element> children = new ArrayList<Element>();
while (iter.hasNext()) {
Element elem;
try {
elem = (Element) iter.next();
} catch (ClassCastException e) {
continue;
}
if (tagName.equalsIgnoreCase(elem.getName())) {
children.add(elem);
}
}
return children;
}
示例5: getTypeFromParentType
import org.jdom2.util.IteratorIterable; //导入依赖的package包/类
@Override
public RecordMeta getTypeFromParentType(String type, String eventName) {
Element parentElement = getComplexElement(type);
while (parentElement != null && eventName != null) {
for (Element e : parentElement.getDescendants(Filters.element(ELEMENT, XS_NAMESPACE))) {
if (e.getAttributeValue(NAME).equals(eventName)) {
return new RecordMetaImpl(eventName, e.getAttributeValue(TYPE), shouldBeList(e, parentElement));
}
}
IteratorIterable<Element> extensions = parentElement.getDescendants(Filters.element(EXTENSION, XS_NAMESPACE));
if (extensions.hasNext()) {
parentElement = extensions.next();
} else {
parentElement = null;
}
}
return null;
}
示例6: process
import org.jdom2.util.IteratorIterable; //导入依赖的package包/类
@Override
public Document process(final Map<String, Object> context, final Document document, final Slide slide,
final Resources resources, final Configuration configuration) throws JODTemplateException {
final IteratorIterable<Element> parentElements = document.getDescendants(
Filters.element(parentElement, getNamespace()));
final List<Element> parentElementsList = new ArrayList<>();
while (parentElements.hasNext()) {
parentElementsList.add(parentElements.next());
}
for (final Element parent : parentElementsList) {
final IteratorIterable<Element> atElements = parent.getDescendants(
Filters.element(PPTXDocument.T_ELEMENT, getNamespace()));
final List<Element> atElementsList = new ArrayList<>();
while (atElements.hasNext()) {
atElementsList.add(atElements.next());
}
final ExpressionHandler expressionHandler = configuration.getExpressionHandler();
boolean isLoop = false;
InlineListExpression expression = null;
for (final Element at : atElementsList) {
final String text = at.getText();
if (configuration.getExpressionHandler().isInlineList(text)) {
expression = expressionHandler.createInlineListExpression(text);
at.setText(expressionHandler.createVariable(expression.getVariable()));
isLoop = true;
}
}
if (isLoop) {
int apIndex = parent.getParent().indexOf(parent);
final String beginList = expressionHandler.createBeginList(expression.getWhat(), expression.getAs());
final String endList = expressionHandler.createEndList();
parent.getParent().addContent(apIndex, new Comment(beginList));
apIndex++;
parent.getParent().addContent(apIndex + 1, new Comment(endList));
}
}
return document;
}
示例7: process
import org.jdom2.util.IteratorIterable; //导入依赖的package包/类
public Document process(final Map<String, Object> context, final Document document, final Slide slide,
final Resources resources, final Configuration configuration) throws JODTemplateException {
final ExpressionHandler expressionHandler = configuration.getExpressionHandler();
final IteratorIterable<Element> picElements = document.getDescendants(Filters.element(PPTXDocument.PIC_ELEMENT,
getPresentationmlNamespace()));
final List<Element> picElementsList = new ArrayList<>();
while (picElements.hasNext()) {
picElementsList.add(picElements.next());
}
for (Element pic : picElementsList) {
final Attribute descr = pic.getChild(PPTXDocument.NVPICPR_ELEMENT, getPresentationmlNamespace())
.getChild(PPTXDocument.CNVPR_ELEMENT, getPresentationmlNamespace())
.getAttribute(PPTXDocument.DESCR_ATTR);
if (descr != null && expressionHandler.isExpression(descr.getValue())) {
final VariableExpression expression = expressionHandler.createVariableExpression(descr.getValue());
Object value;
try {
value = PropertyUtils.getNestedProperty(context, expression.getVariable());
} catch (IllegalAccessException | InvocationTargetException | NoSuchMethodException e) {
throw new JODTemplateException("Unable to get value: " + expression.getVariable());
}
if (value instanceof ImageField) {
final ImageField imageField = (ImageField) value;
imageService.insertImage(imageField, slide, resources, pic);
} else {
throw new JODTemplateException("Field " + expression.getVariable() + " should contain image.");
}
}
}
return document;
}
示例8: prepareUserInputdata
import org.jdom2.util.IteratorIterable; //导入依赖的package包/类
/**
* Prepares the user input by replacing the variables in the xml (masked
* values).
*/
public void prepareUserInputdata() {
IteratorIterable<Element> cIterator = xmlMetaDataDoc
.getDescendants(new ElementFilter());
String lineValue;
String inputRegEx = INPUT_REG_EX;
if (cIterator != null) {
while (cIterator.hasNext()) {
lineValue = cIterator.next().getValue();
if (lineValue.matches(inputRegEx)) {
addKeyValueToHashMap(lineValue);
}
}
}
}
示例9: getTypeFromParentType
import org.jdom2.util.IteratorIterable; //导入依赖的package包/类
@Override
public RecordMeta getTypeFromParentType(RecordMeta parentMeta, String eventName) {
Element parentElement = getComplexElement( parentMeta.getType());
while (parentElement != null && eventName != null) {
IteratorIterable<Element> res = parentElement.getDescendants(Filters.element(ELEMENT, XS_NAMESPACE));
for (Element e : res) {
if (e.getAttributeValue(NAME).equals(eventName)) {
String elementType = e.getAttributeValue(TYPE);
if (elementType == null) {
Element simple = e.getChild(SIMPLETYPE, XS_NAMESPACE);
elementType = getSimpleTypeRestrictionBase(simple);
}
return new RecordMetaImpl(eventName, elementType, shouldBeList(e, parentElement), parentMeta.getAction());
}
}
IteratorIterable<Element> extensions = parentElement.getDescendants(Filters
.element(EXTENSION, XS_NAMESPACE));
if (extensions.hasNext()) {
parentElement = getComplexElement(extensions.next().getAttributeValue(BASE));
} else {
parentElement = null;
}
}
return null;
}
示例10: renameResource
import org.jdom2.util.IteratorIterable; //导入依赖的package包/类
public void renameResource(Resource resource, String oldValue, String newValue)
{
resources.remove(oldValue); //unter altem namen löschen
resources.add(resource); //unter neuem wieder hinzufügen
if (MediaType.CSS.equals(resource.getMediaType()))
{
//css umbenannt, erstmal alle XHTMLs durchsuchen
List<Resource> xhtmlResources = resources.getResourcesByMediaType(MediaType.XHTML);
Path resourcePath = resource.getHrefAsPath();
int index = StringUtils.lastIndexOf(oldValue, "/");
String oldFileName = oldValue;
if (index > -1)
{
oldFileName = oldValue.substring(index + 1);
}
index = StringUtils.lastIndexOf(newValue, "/");
String newFileName = newValue;
if (index > -1)
{
newFileName = newValue.substring(index + 1);
}
for (Resource xhtmlResource : xhtmlResources)
{
Document document = ((XHTMLResource)xhtmlResource).asNativeFormat();
Path relativePath = xhtmlResource.getHrefAsPath().relativize(resourcePath);
AtrributeElementFilter hrefFilter = new AtrributeElementFilter("href", relativePath + "/" + oldFileName);
IteratorIterable<Element> descendants = document.getDescendants(hrefFilter);
for (Element descendant : descendants)
{
logger.info("found element with attribut href in resource " + xhtmlResource);
descendant.setAttribute("href", relativePath + "/" + newFileName);
}
//nach noch mehr Elementen suchen
//zB src-Attribut
xhtmlResource.setData(XHTMLUtils.outputXHTMLDocument(document));
}
//weiter nach import etc. in anderen css dateien suchen
}
else if(MediaType.XHTML.equals(resource.getMediaType()))
{
//nach href
}
else if(resource.getMediaType().isBitmapImage())
{
//nach href und src
}
refreshOpfResource();
}