public void writeInstruction(String value) { if (this.finished) { return; } // don't carelessly add empty tags if (value.length() == 0) { return; } TextUnit unit; if (this.currentUnit() instanceof TextUnit) { unit = (TextUnit) this.currentUnit(); } else { unit = new TextUnit(this.alias, this.nextTagId()); this.startUnit(unit); } unit.writeInstruction(value); }
public void popNamespace(String ns) { this.namespaceManager.popNamespace(ns); if (this.currentUnit() instanceof NamespaceUnit) { this.finishUnit(); } }
public void startCDATA() throws SAXException { if (this.inDocument) { if (!unit.getWebConfiguration().getFaceletsConfiguration().isConsumeCDATA(alias)) { this.unit.writeInstruction("<![CDATA["); } } }
String[] qname = this.determineQName(t); t = this.trimAttributes(t); if (isTrimmed(qname[0], qname[1])) { if (log.isLoggable(Level.FINE)) { log.fine("Composition Found, Popping Parent Tags"); CompilationUnit viewRootUnit = getViewRootUnitFromStack(units); this.units.clear(); NamespaceUnit nsUnit = this.namespaceManager if (viewRootUnit != null) { viewRootUnit.removeChildren(); this.currentUnit().addChild(viewRootUnit); this.startUnit(new TrimmedTagUnit(this.tagLibrary, qname[0], qname[1], t, this .nextTagId())); if (log.isLoggable(Level.FINE)) { log.fine("New Namespace and [Trimmed] TagUnit pushed"); } else if (isImplementation(qname[0], qname[1])) { if (log.isLoggable(Level.FINE)) { log.fine("Composite Component Implementation Found, Popping Parent Tags"); InterfaceUnit iface = getInterfaceUnit(); if (null == iface) { throw new TagException(orig, "Unable to find interface for implementation."); .toNamespaceUnit(this.tagLibrary);
protected FaceletHandler doCompile(CompilationManager mngr, CompilationHandler handler, URL src, String alias) throws IOException { String encoding = getEncoding(); try (InputStream is = new BufferedInputStream(src.openStream(), 1024);) { writeXmlDecl(is, encoding, mngr); SAXParser parser = this.createSAXParser(handler); parser.parse(is, handler); } catch (SAXException e) { throw new FaceletException("Error Parsing " + alias + ": " + e.getMessage(), e.getCause()); } catch (ParserConfigurationException e) { throw new FaceletException("Error Configuring Parser " + alias + ": " + e.getMessage(), e.getCause()); } catch (FaceletException e) { throw e; } FaceletHandler result = new EncodingHandler(mngr.createFaceletHandler(), encoding, mngr.getCompilationMessageHolder()); mngr.setCompilationMessageHolder(null); return result; }
@Override protected void startNotify(CompilationManager manager) { if (this.name.equals("composition") && (this.namespace.equals(RIConstants.FACELET_NAMESPACE) || this.namespace.equals(RIConstants.FACELET_NAMESPACE))) { CompilerPackageCompilationMessageHolder messageHolder = (CompilerPackageCompilationMessageHolder) manager.getCompilationMessageHolder(); CompilationManager compositeComponentCompilationManager = messageHolder. getCurrentCompositeComponentCompilationManager(); if (manager.equals(compositeComponentCompilationManager)) { // PENDING I18N String messageStr = "Because the definition of ui:composition causes any " + "parent content to be ignored, it is invalid to use " + "ui:composition directly inside of a composite component. " + "Consider ui:decorate instead."; throw new FaceletException(messageStr); } } }
public void comment(char[] ch, int start, int length) throws SAXException { if (this.inDocument) { if (!unit.getWebConfiguration().getFaceletsConfiguration().isConsumeComments(alias)) { this.unit.writeComment(new String(ch, start, length)); } } }
public void pushNamespace(String prefix, String uri) { if (log.isLoggable(Level.FINE)) { log.fine("Namespace Pushed " + prefix + ": " + uri); } boolean alreadyPresent = this.namespaceManager.getNamespace(prefix) != null; this.namespaceManager.pushNamespace(prefix, uri); NamespaceUnit unit; if (this.currentUnit() instanceof NamespaceUnit && !alreadyPresent) { unit = (NamespaceUnit) this.currentUnit(); } else { unit = new NamespaceUnit(this.tagLibrary); this.startUnit(unit); } unit.setNamespace(prefix, uri); }
protected static void writeXmlDecl(InputStream is, String encoding, CompilationManager mngr) throws IOException { is.mark(128); try { byte[] b = new byte[128]; if (is.read(b) > 0) { String r = new String(b, encoding); Matcher m = XmlDeclaration.matcher(r); if (m.find()) { WebConfiguration config = mngr.getWebConfiguration(); FaceletsConfiguration faceletsConfig = config.getFaceletsConfiguration(); boolean currentModeIsXhtml = faceletsConfig.isProcessCurrentDocumentAsFaceletsXhtml(mngr.getAlias()); // We want to write the XML declaration if and only if // the file extension for the current file has a mapping // with the value of XHTML if (currentModeIsXhtml) { Util.saveXMLDECLToFacesContextAttributes(m.group(0) + "\n"); } } } } finally { is.reset(); } }
protected boolean isDisallowDoctypeDecl() { return unit.getWebConfiguration().isOptionEnabled(DisallowDoctypeDecl); } }
public FaceletHandler doCompile(URL src, String alias) throws IOException { CompilationManager mgr = new CompilationManager(alias, this); CompilationHandler handler = new CompilationHandler(mgr, alias); return doCompile(mgr, handler, src, alias); }
private void startUnit(CompilationUnit unit) { if (log.isLoggable(Level.FINE)) { log.fine("Starting Unit: " + unit + " and adding it to parent: " + this.currentUnit()); } this.currentUnit().addChild(unit); this.units.push(unit); unit.startNotify(this); }
String[] qname = this.determineQName(t); t = this.trimAttributes(t); if (isTrimmed(qname[0], qname[1])) { if (log.isLoggable(Level.FINE)) { log.fine("Composition Found, Popping Parent Tags"); CompilationUnit viewRootUnit = getViewRootUnitFromStack(units); this.units.clear(); NamespaceUnit nsUnit = this.namespaceManager this.units.push(nsUnit); if (viewRootUnit != null) { this.currentUnit().addChild(viewRootUnit); this.startUnit(new TrimmedTagUnit(this.tagLibrary, qname[0], qname[1], t, this .nextTagId())); if (log.isLoggable(Level.FINE)) { log.fine("New Namespace and [Trimmed] TagUnit pushed"); } else if (isImplementation(qname[0], qname[1])) { if (log.isLoggable(Level.FINE)) { log.fine("Composite Component Implementation Found, Popping Parent Tags"); InterfaceUnit iface = getInterfaceUnit(); if (null == iface) { throw new TagException(orig, "Unable to find interface for implementation."); .toNamespaceUnit(this.tagLibrary);
FaceletHandler result = new EncodingHandler(mngr.createFaceletHandler(), encoding, mngr.getCompilationMessageHolder()); mngr.setCompilationMessageHolder(null);
@Override protected void startNotify(CompilationManager manager) { if (this.name.equals("composition") && (this.namespace.equals(RIConstants.FACELET_NAMESPACE) || this.namespace.equals(RIConstants.FACELET_NAMESPACE))) { CompilerPackageCompilationMessageHolder messageHolder = (CompilerPackageCompilationMessageHolder) manager.getCompilationMessageHolder(); CompilationManager compositeComponentCompilationManager = messageHolder. getCurrentCompositeComponentCompilationManager(); if (manager.equals(compositeComponentCompilationManager)) { // PENDING I18N String messageStr = "Because the definition of ui:composition causes any " + "parent content to be ignored, it is invalid to use " + "ui:composition directly inside of a composite component. " + "Consider ui:decorate instead."; throw new FaceletException(messageStr); } } }
@Override public void comment(char[] ch, int start, int length) throws SAXException { if (this.inDocument) { if (!unit.getWebConfiguration().getFaceletsConfiguration().isConsumeComments(alias)) { this.unit.writeComment(new String(ch, start, length)); } } }
public void pushNamespace(String prefix, String uri) { if (log.isLoggable(Level.FINE)) { log.fine("Namespace Pushed " + prefix + ": " + uri); } boolean alreadyPresent = this.namespaceManager.getNamespace(prefix) != null; this.namespaceManager.pushNamespace(prefix, uri); NamespaceUnit unit; if (this.currentUnit() instanceof NamespaceUnit && !alreadyPresent) { unit = (NamespaceUnit) this.currentUnit(); } else { unit = new NamespaceUnit(this.tagLibrary); this.startUnit(unit); } unit.setNamespace(prefix, uri); }
protected static void writeXmlDecl(InputStream is, String encoding, CompilationManager mngr) throws IOException { is.mark(128); try { byte[] b = new byte[128]; if (is.read(b) > 0) { String r = new String(b, encoding); Matcher m = XmlDeclaration.matcher(r); if (m.find()) { WebConfiguration config = mngr.getWebConfiguration(); FaceletsConfiguration faceletsConfig = config.getFaceletsConfiguration(); boolean currentModeIsXhtml = faceletsConfig.isProcessCurrentDocumentAsFaceletsXhtml(mngr.getAlias()); // We want to write the XML declaration if and only if // the file extension for the current file has a mapping // with the value of XHTML if (currentModeIsXhtml) { Util.saveXMLDECLToFacesContextAttributes(m.group(0) + "\n"); } } } } finally { is.reset(); } }
protected boolean isDisallowDoctypeDecl() { return unit.getWebConfiguration().isOptionEnabled(DisallowDoctypeDecl); } }
public FaceletHandler doMetadataCompile(URL src, String alias) throws IOException { CompilationManager mgr = new CompilationManager("metadata/" + alias, this); CompilationHandler handler = new MetadataCompilationHandler(mgr, alias); return doCompile(mgr, handler, src, alias); }