/** * Ask whether this is a hidden component derived from an abstract component with no * implementation * @return true if this component is hidden, and its base component is abstract */ public boolean isHiddenAbstractComponent() { return visibility == Visibility.HIDDEN && baseComponent != null && baseComponent.getVisibility() == Visibility.ABSTRACT; }
/** * Ask whether this is a hidden component derived from an abstract component with no * implementation * @return true if this component is hidden, and its base component is abstract */ public boolean isHiddenAbstractComponent() { return visibility == Visibility.HIDDEN && baseComponent != null && baseComponent.getVisibility() == Visibility.ABSTRACT; }
public Component getFixedTarget() { Component c = getTarget(); Visibility v = c.getVisibility(); if (v == Visibility.PRIVATE || v == Visibility.FINAL) { return c; } else { return null; } }
public Component getFixedTarget() { Component c = getTarget(); Visibility v = c.getVisibility(); if (v == Visibility.PRIVATE || v == Visibility.FINAL) { return c; } else { return null; } }
public Component getFixedTarget() { Component c = getTarget(); Visibility v = c.getVisibility(); if (v == Visibility.PRIVATE || v == Visibility.FINAL) { return c; } else { return null; } }
public Component getFixedTarget() { Component c = getTarget(); Visibility v = c.getVisibility(); if (v == Visibility.PRIVATE || v == Visibility.FINAL) { return c; } else { return null; } }
public Component getFixedTarget() { Visibility v = function.getDeclaringComponent().getVisibility(); if (v == Visibility.PRIVATE || v == Visibility.FINAL) { return function.getDeclaringComponent(); } else { return null; } }
public Component getFixedTarget() { Visibility v = function.getDeclaringComponent().getVisibility(); if (v == Visibility.PRIVATE || v == Visibility.FINAL) { return function.getDeclaringComponent(); } else { return null; } }
/** * Add a component to the package * @param component the component to be added */ public void addComponent(Component component) { SymbolicName name = component.getActor().getSymbolicName(); componentIndex.put(name, component); if (component.getVisibility() == Visibility.ABSTRACT && component.getContainingPackage() == this) { abstractComponents.put(component.getActor().getSymbolicName(), component); } }
/** * Add a component to the package * @param component the component to be added */ public void addComponent(Component component) { SymbolicName name = component.getActor().getSymbolicName(); componentIndex.put(name, component); if (component.getVisibility() == Visibility.ABSTRACT && component.getContainingPackage() == this) { abstractComponents.put(component.getActor().getSymbolicName(), component); } }
private Component getFunctionComponent(QName function, XdmValue[] arguments) throws XPathException { SymbolicName fName = new SymbolicName.F(function.getStructuredQName(), arguments.length); PreparedStylesheet pss = (PreparedStylesheet) controller.getExecutable(); Component f = pss.getComponent(fName); if (f == null) { throw new XPathException("No public function with name " + function.getClarkName() + " and arity " + arguments.length + " has been declared in the stylesheet", "XTDE0041"); } else if (f.getVisibility() != Visibility.FINAL && f.getVisibility() != Visibility.PUBLIC) { throw new XPathException("Cannot invoke " + fName + " externally, because it is not public", "XTDE0041"); } return f; }
public void checkForAbstractComponents() throws XPathException { for (Map.Entry<SymbolicName, Component> entry : componentIndex.entrySet()) { if (entry.getValue().getVisibility() == Visibility.ABSTRACT && entry.getValue().getContainingPackage() == this) { abstractComponents.put(entry.getKey(), entry.getValue()); } } if (!abstractComponents.isEmpty()) { FastStringBuffer buff = new FastStringBuffer(256); int count = 0; for (SymbolicName name : abstractComponents.keySet()) { if (count++ > 0) { buff.append(", "); } buff.append(name.toString()); if (buff.length() > 300) { buff.append(" ..."); break; } } throw new XPathException( "The package is not executable, because it contains abstract components: " + buff.toString(), "XTSE3080"); } }
private Component getFunctionComponent(QName function, XdmValue[] arguments) throws XPathException { SymbolicName fName = new SymbolicName.F(function.getStructuredQName(), arguments.length); PreparedStylesheet pss = (PreparedStylesheet) controller.getExecutable(); Component f = pss.getComponent(fName); if (f == null) { throw new XPathException("No public function with name " + function.getClarkName() + " and arity " + arguments.length + " has been declared in the stylesheet", "XTDE0041"); } else if (f.getVisibility() != Visibility.FINAL && f.getVisibility() != Visibility.PUBLIC) { throw new XPathException("Cannot invoke " + fName + " externally, because it is not public", "XTDE0041"); } return f; }
public void checkForAbstractComponents() throws XPathException { for (Map.Entry<SymbolicName, Component> entry : componentIndex.entrySet()) { if (entry.getValue().getVisibility() == Visibility.ABSTRACT && entry.getValue().getContainingPackage() == this) { abstractComponents.put(entry.getKey(), entry.getValue()); } } if (!abstractComponents.isEmpty()) { FastStringBuffer buff = new FastStringBuffer(256); int count = 0; for (SymbolicName name : abstractComponents.keySet()) { if (count++ > 0) { buff.append(", "); } buff.append(name.toString()); if (buff.length() > 300) { buff.append(" ..."); break; } } throw new XPathException( "The package is not executable, because it contains abstract components: " + buff, "XTSE3080"); } }
public void export(ExpressionPresenter out, Map<Component, Integer> componentIdMap, Map<StylesheetPackage, Integer> packageIdMap) throws XPathException { out.startElement("co"); int id = obtainComponentId(this, componentIdMap); out.emitAttribute("id", ""+id); if (getVisibility() != null && getVisibility() != Visibility.PRIVATE) { out.emitAttribute("vis", getVisibility().toString()); } String refs = listComponentReferences(componentIdMap); out.emitAttribute("binds", refs); if (baseComponent != null && getActor() == baseComponent.getActor()) { int baseId = obtainComponentId(baseComponent, componentIdMap); out.emitAttribute("base", ""+baseId); out.emitAttribute("dpack", packageIdMap.get(declaringPackage)+""); } else { actor.export(out); } out.endElement(); }
public void export(ExpressionPresenter out, Map<Component, Integer> componentIdMap, Map<StylesheetPackage, Integer> packageIdMap) throws XPathException { out.startElement("co"); int id = obtainComponentId(this, componentIdMap); out.emitAttribute("id", ""+id); if (getVisibility() != null && getVisibility() != Visibility.PRIVATE) { out.emitAttribute("vis", getVisibility().toString()); } String refs = listComponentReferences(componentIdMap); out.emitAttribute("binds", refs); if (baseComponent != null && getActor() == baseComponent.getActor()) { int baseId = obtainComponentId(baseComponent, componentIdMap); out.emitAttribute("base", ""+baseId); out.emitAttribute("dpack", packageIdMap.get(declaringPackage)+""); } else { actor.export(out); } out.endElement(); }
/** * Register a global variable declared within this package, allocating it a slot * number within the Bindery * @param c the component representing a global variable; it may also be another * kind of component, but in this case it is ignored * @param slotManager the SlotManager defining the allocation of variables to * slots in the Bindery */ private void registerGlobalVariable(Component c, SlotManager slotManager) { if (c.getActor() instanceof GlobalVariable) { GlobalVariable var = (GlobalVariable) c.getActor(); int slot = slotManager.allocateSlotNumber(var.getVariableQName()); var.setPackageData(this); var.setBinderySlotNumber(slot); if (c.getVisibility() != Visibility.HIDDEN) { addGlobalVariable(var); } } }
/** * Register a global variable declared within this package, allocating it a slot * number within the Bindery * @param c the component representing a global variable; it may also be another * kind of component, but in this case it is ignored * @param slotManager the SlotManager defining the allocation of variables to * slots in the Bindery */ private void registerGlobalVariable(Component c, SlotManager slotManager) { if (c.getActor() instanceof GlobalVariable) { GlobalVariable var = (GlobalVariable) c.getActor(); int slot = slotManager.allocateSlotNumber(var.getVariableQName()); var.setPackageData(this); var.setBinderySlotNumber(slot); if (c.getVisibility() != Visibility.HIDDEN) { addGlobalVariable(var); } } }
/** * Accept a component from a used package, modifying its visibility if necessary * * @param component the component to be accepted; as a side-effect of this method, the * visibility of the component may change * @throws XPathException if the requested visibility is incompatible with the declared * visibility */ public void acceptComponent(Component component) throws XPathException { for (ComponentTest test : getExplicitComponentTests()) { if (test.matches(component.getActor())) { // we have already checked that the visibility is compatible component.setVisibility(getVisibility(), false); return; } } for (ComponentTest test : getWildcardComponentTests()) { if (test.matches(component.getActor())) { if (isCompatible(component.getVisibility(), getVisibility())) { // set the visibility if it is compatible component.setVisibility(getVisibility(), false); return; } } } }
/** * Process the function call in push mode * * @param context the XPath dynamic context * @throws XPathException if a dynamic error occurs */ public void process(XPathContext context) throws XPathException { Sequence<?>[] actualArgs = evaluateArguments(context); if (isTailCall()) { requestTailCall(context, actualArgs); return; } if (bindingSlot >= 0) { Component target = getTargetComponent(context); UserFunction targetFunction = (UserFunction) target.getActor(); if (target.getVisibility() == Visibility.ABSTRACT) { throw new XPathException("Cannot call a function defined with visibility=abstract", "XTDE3052"); } XPathContextMajor c2 = targetFunction.makeNewContext(context, this); c2.setCurrentComponent(target); c2.setOrigin(this); targetFunction.process(actualArgs, c2); } else { XPathContextMajor c2 = function.makeNewContext(context, this); c2.setOrigin(this); function.process(actualArgs, c2); } }