/** * {@inheritDoc} */ public TagCreationResult<T> create(Class<? extends T> impl, IParserContext context) { T tag = constructObject(impl, context); tag.setTagName(context.getElement().getLocalName()); tag.setLineNumber(context.getElement().getLineNumber()); tag.setResource(context.getResource()); tag.setEntity(context.getEntity()); tag.setParent(context.getParentTag()); context.getParentTag().addChild(tag); if (tag instanceof AbstractTag) { ((AbstractTag) tag).setFactory(this); ((AbstractTag) tag).setXmlElement(context.getElement()); } final boolean childrenParsed = populate(tag, context); return new TagCreationResult<T>(tag, childrenParsed); }
/** * Get target entity from context. * * @param tag * the tag * @param context * the context * @return target entity, never null */ protected IEntity getTargetEntity(FileInvokerTag tag, IParserContext context) { IEntity target = context.getLocator().getParser().parse(context.getResource(), false, context); if (target == null) { throw new PaxmlRuntimeException("Unknown target resource: " + context.getResource()); } return target; }
private IEntity detectCircle(LinkedList<IParserContext> stack, PaxmlResource resource) { for (IParserContext c : stack) { if (resource.equals(c.getResource())) { return c.getEntity(); } } return null; }
/** * Get target resource from context. * * @param tag * the tag * @param context * the context * @return the resource, null if not found. */ protected PaxmlResource getTargetResource(FileInvokerTag tag, IParserContext context) { return context.getLocator().getResource(context.getElement().getLocalName()); }
/** * Process the tag attributes and children. * @param tag the tag * @param context the parse context * @param filter the attribute filter */ public static void processElement(ITag tag, IParserContext context, IAttributeFilter filter) { final OMElement ele = context.getElement(); String text = ele.getText(); if (StringUtils.isBlank(text)) { text = null; } pushAttributeToSubConst(ele, filter); } /**
} catch (Exception e) { IParserContext deepest = contextImpl.getParserStack().getFirst(); OMElement ele = deepest.getElement(); throw new PaxmlParseException("Cannot parse tag <" + ele.getLocalName() + "> at line: " + ele.getLineNumber() + ", resource: " + deepest.getResource() + "\r\nBecause: " + Paxml.getCause(e), e);
final OMElement ele = context.getElement(); final ITag parent = context.getParentTag();
private List<IParserContext> findCircle(LinkedList<IParserContext> stack, PaxmlResource resource) { List<IParserContext> list = null; for (IParserContext context : stack) { PaxmlResource res = context.getResource(); if (list == null && res.equals(resource)) { list = new ArrayList<IParserContext>(2); } if (list != null) { list.add(context); } } return list; }
/** * {@inheritDoc} */ @Override protected boolean populate(final FileInvokerTag tag, IParserContext context) { super.populate(tag, context); PaxmlResource targetResource = getTargetResource(tag, context); tag.setTargetResource(targetResource); // make sure the target file is parsed and cached, so that at execution // time, the parser context can simply be passed as null. if (targetResource != null) { IParserContext newContext = AbstractPaxmlEntityFactory.createTargetParserContext(context, targetResource); getTargetEntity(tag, newContext); newContext.discard(); } else { throw new PaxmlRuntimeException("Target resource not found"); } return false; }
IEntity entity = null; if (context != null) { entity = detectCircle(context.getParserStack(), resource); if (entity != null) { return entity;
/** * Process the tag attributes and children. * @param tag the tag * @param context the parse context * @param filter the attribute filter */ public static void processElement(ITag tag, IParserContext context, IAttributeFilter filter) { final OMElement ele = context.getElement(); String text = ele.getText(); if (StringUtils.isBlank(text)) { text = null; } pushAttributeToSubConst(ele, filter); } /**
/** * Get target resource from context. * * @param tag * the tag * @param context * the context * @return the resource, null if not found. */ protected PaxmlResource getTargetResource(FileInvokerTag tag, IParserContext context) { return context.getLocator().getResource(context.getElement().getLocalName()); }
private IEntity detectCircle(LinkedList<IParserContext> stack, PaxmlResource resource) { for (IParserContext c : stack) { if (resource.equals(c.getResource())) { return c.getEntity(); } } return null; }
} catch (Exception e) { IParserContext deepest = contextImpl.getParserStack().getFirst(); OMElement ele = deepest.getElement(); throw new PaxmlParseException( "Cannot parse tag <" + ele.getLocalName() + "> at line: " + ele.getLineNumber() + ", resource: " + deepest.getResource() + "\r\nBecause: " + Paxml.getCause(e), e);
final OMElement ele = context.getElement(); final ITag parent = context.getParentTag();
private List<IParserContext> findCircle(LinkedList<IParserContext> stack, PaxmlResource resource) { List<IParserContext> list = null; for (IParserContext context : stack) { PaxmlResource res = context.getResource(); if (list == null && res.equals(resource)) { list = new ArrayList<IParserContext>(2); } if (list != null) { list.add(context); } } return list; }
/** * {@inheritDoc} */ @Override protected boolean populate(final FileInvokerTag tag, IParserContext context) { super.populate(tag, context); PaxmlResource targetResource = getTargetResource(tag, context); tag.setTargetResource(targetResource); // make sure the target file is parsed and cached, so that at execution // time, the parser context can simply be passed as null. if (targetResource != null) { IParserContext newContext = AbstractPaxmlEntityFactory.createTargetParserContext(context, targetResource); getTargetEntity(tag, newContext); newContext.discard(); } else { throw new PaxmlRuntimeException("Target resource not found"); } return false; }
IEntity entity = null; if (context != null) { entity = detectCircle(context.getParserStack(), resource); if (entity != null) { return entity;
/** * {@inheritDoc} */ public TagCreationResult<T> create(Class<? extends T> impl, IParserContext context) { T tag = constructObject(impl, context); tag.setTagName(context.getElement().getLocalName()); tag.setLineNumber(context.getElement().getLineNumber()); tag.setResource(context.getResource()); tag.setEntity(context.getEntity()); tag.setParent(context.getParentTag()); context.getParentTag().addChild(tag); if (tag instanceof AbstractTag) { ((AbstractTag) tag).setFactory(this); ((AbstractTag) tag).setXmlElement(context.getElement()); } final boolean childrenParsed = populate(tag, context); return new TagCreationResult<T>(tag, childrenParsed); }
/** * {@inheritDoc} */ @Override protected boolean populate(final IfTag tag, IParserContext context) { super.populate(tag, context); final OMElement ele = context.getElement(); assertExactAttributes(ele, IfTag.TEST_ATTR); return false; } }