protected StyleRule getParentRule() { if ( parentRules.isEmpty() == false ) { return (StyleRule) parentRules.peek(); } return null; }
/** * Adds an implied namespace to the document. Such a namespace is not explicitly declared, it is assumed that the * xml-parser knows the prefix by some other means. Using implied namespaces for standalone documents is almost always * a bad idea. * * @param uri the uri of the namespace. * @param prefix the defined prefix. */ public void addImpliedNamespace( final String uri, final String prefix ) { if ( openTags.isEmpty() == false ) { throw new IllegalStateException( "Cannot modify the implied namespaces in the middle of the processing" ); } if ( prefix == null ) { if ( impliedNamespaces == null ) { return; } impliedNamespaces.remove( uri ); } else { if ( impliedNamespaces == null ) { impliedNamespaces = new HashMap(); } impliedNamespaces.put( uri, prefix ); } }
/** * Copies all currently declared namespaces of the given XmlWriterSupport instance as new implied namespaces into this * instance. * * @param writerSupport the Xml-writer from where to copy the declared namespaces. */ public void copyNamespaces( final XmlWriterSupport writerSupport ) { if ( openTags.isEmpty() == false ) { throw new IllegalStateException( "Cannot modify the implied namespaces in the middle of the processing" ); } if ( impliedNamespaces == null ) { impliedNamespaces = new HashMap(); } if ( writerSupport.openTags.isEmpty() == false ) { final ElementLevel parent = (ElementLevel) writerSupport.openTags.peek(); impliedNamespaces.putAll( parent.getNamespaces().getNamespaces() ); } if ( writerSupport.impliedNamespaces != null ) { impliedNamespaces.putAll( writerSupport.impliedNamespaces ); } }
/** * Hand control back to the previous handler. * * @param tagName the tagname. * @param uri the namespace uri of the current tag. * @throws SAXException if there is a problem with the parser. */ public void unwind( final String uri, final String tagName ) throws SAXException { // remove current handler from stack .. this.currentHandlers.pop(); if ( this.currentHandlers.isEmpty() && !this.outerScopes.isEmpty() ) { // if empty, but "recurse" had been called, then restore the old handler stack .. // but do not end the recursed element .. this.currentHandlers = this.outerScopes.pop(); } else if ( !this.currentHandlers.isEmpty() ) { // if there are some handlers open, close them too (these handlers must be delegates).. getCurrentHandler().endElement( uri, tagName ); } }
/** * Returns all namespaces as properties-collection. This reflects the currently defined namespaces, therefore calls to * writeOpenTag(..) might cause this method to return different collections. * * @return the defined namespaces. */ public Properties getNamespaces() { final Properties namespaces = new Properties(); if ( openTags.isEmpty() ) { if ( impliedNamespaces != null ) { //noinspection UseOfPropertiesAsHashtable namespaces.putAll( impliedNamespaces ); } return namespaces; } final ElementLevel parent = (ElementLevel) openTags.peek(); //noinspection UseOfPropertiesAsHashtable namespaces.putAll( parent.getNamespaces().getNamespaces() ); return namespaces; }
/** * Clones the expression. The expression should be reinitialized after the cloning. * <P> * Expressions maintain no state, cloning is done at the beginning of the report processing to disconnect the * expression from any other object space. * * @return a clone of this expression. * @throws CloneNotSupportedException * this should never happen. */ public Object clone() throws CloneNotSupportedException { final CrosstabProcessorFunction cps = (CrosstabProcessorFunction) super.clone(); if ( processingStack == null || processingStack.isEmpty() ) { return cps; } cps.processingStack = processingStack.clone(); return cps; }
/** * Checks, whether the given namespace prefix is defined. * * @param prefix the namespace prefix. * @return true, if the prefix is defined, false otherwise. */ public boolean isNamespacePrefixDefined( final String prefix ) { if ( impliedNamespaces != null ) { if ( impliedNamespaces.containsValue( prefix ) ) { return true; } } if ( openTags.isEmpty() ) { return false; } final ElementLevel parent = (ElementLevel) openTags.peek(); return parent.getNamespaces().isPrefixDefined( prefix ); }
public BoxAlignContext closeContext() { final BoxAlignContext context = contexts.pop(); context.validate(); if ( contexts.isEmpty() ) { currentLine = null; } else { currentLine = contexts.peek(); } return context; } }
/** * Checks, whether the given URI is defined as valid namespace. * * @param uri the uri of the namespace. * @return true, if there's a namespace defined, false otherwise. */ public boolean isNamespaceDefined( final String uri ) { if ( impliedNamespaces != null ) { if ( impliedNamespaces.containsKey( uri ) ) { return true; } } if ( openTags.isEmpty() ) { return false; } final ElementLevel parent = (ElementLevel) openTags.peek(); return parent.getNamespaces().isNamespaceDefined( uri ); }
protected void inspectEndSection( final ReportElement box, final boolean inlineSection ) { formatBufferStack.pop(); if ( formatBufferStack.isEmpty() ) { return; } RichTextFormat rtf = formatBufferStack.peek(); final RichTextFormat lastRtf = formatBuffer.get( formatBuffer.size() - 1 ); if ( lastRtf.getFont().equals( rtf.getFont() ) == false ) { formatBuffer.add( new RichTextFormat( getTextLength(), rtf.getFont() ) ); } } }
protected void finishInlineBox( final InlineRenderBox box ) { formatBufferStack.pop(); if ( formatBufferStack.isEmpty() ) { return; } RichTextFormat rtf = formatBufferStack.peek(); final RichTextFormat lastRtf = formatBuffer.get( formatBuffer.size() - 1 ); if ( lastRtf.getFont().equals( rtf.getFont() ) == false ) { formatBuffer.add( new RichTextFormat( getTextLength(), rtf.getFont() ) ); } }
/** * Computes the current collection of defined namespaces. * * @return the namespaces declared at this writing position. */ protected DeclaredNamespaces computeNamespaces() { if ( openTags.isEmpty() ) { final DeclaredNamespaces namespaces = new DeclaredNamespaces(); if ( impliedNamespaces != null ) { return namespaces.add( impliedNamespaces ); } return namespaces; } final ElementLevel parent = (ElementLevel) openTags.peek(); return parent.getNamespaces(); }
/** * Indent the line. Called for proper indenting in various places. * * @param writer the writer which should receive the indentention. * @throws java.io.IOException if writing the stream failed. */ public void indentForClose( final Writer writer ) throws IOException { if ( openTags.isEmpty() ) { for ( int i = 0; i < additionalIndent; i++ ) { writer.write( indentString ); } return; } final ElementLevel level = (ElementLevel) openTags.peek(); if ( getTagDescription().hasCData( level.getNamespace(), level.getTagName() ) == false ) { doEndOfLine( writer ); for ( int i = 1; i < openTags.size(); i++ ) { writer.write( indentString ); } for ( int i = 0; i < additionalIndent; i++ ) { writer.write( indentString ); } } }
public int getGroupStartRow( final int group ) { if ( group < 0 || group >= groupStarts.size() ) { if ( groupStarts.isEmpty() ) { return 0; } final GroupStartRecord o = groupStarts.peek(); return o.getRow(); } final GroupStartRecord o = groupStarts.get( group ); return o.getRow(); } }
/** * Indent the line. Called for proper indenting in various places. * * @param writer the writer which should receive the indentention. * @throws java.io.IOException if writing the stream failed. */ public void indent( final Writer writer ) throws IOException { if ( openTags.isEmpty() ) { for ( int i = 0; i < additionalIndent; i++ ) { writer.write( indentString ); } return; } final ElementLevel level = (ElementLevel) openTags.peek(); if ( getTagDescription().hasCData( level.getNamespace(), level.getTagName() ) == false ) { doEndOfLine( writer ); for ( int i = 0; i < openTags.size(); i++ ) { writer.write( indentString ); } for ( int i = 0; i < additionalIndent; i++ ) { writer.write( indentString ); } } }
/** * Receives notification that a row of data is being processed. * * @param event * the event. */ public void itemsAdvanced( final ReportEvent event ) { if ( event.getLevel() == getDependencyLevel() ) { if ( processingStack == null || processingStack.isEmpty() ) { return; } final CrosstabSpecification state = processingStack.peek(); if ( state == null ) { return; } // this may throw an InvalidReportStateException that ends the report processing. state.add( getDataRow() ); } }
/** * Writes a comment into the generated xml file. * * @param writer the writer. * @param comment the comment text * @throws IOException if there is a problem writing to the character stream. */ public void writeComment( final Writer writer, final String comment ) throws IOException { if ( openTags.isEmpty() == false ) { final ElementLevel level = (ElementLevel) openTags.peek(); if ( getTagDescription().hasCData( level.getNamespace(), level.getTagName() ) == false ) { indent( writer ); } } setLineEmpty( false ); writer.write( "<!-- " ); writeTextNormalized( writer, comment, false ); writer.write( " -->" ); doEndOfLine( writer ); }
private void findNonAuto() { while ( result != null ) { if ( result.getNodeType() != LayoutNodeTypes.TYPE_BOX_AUTOLAYOUT ) { break; } final RenderBox box = (RenderBox) result; final RenderNode firstChild = box.getFirstChild(); if ( firstChild != null ) { if ( boxes == null ) { boxes = new FastStack<RenderBox>(); } boxes.push( box ); result = firstChild; } else { result = result.getNext(); if ( result == null && boxes != null ) { while ( boxes.isEmpty() == false ) { final RenderBox parent = boxes.pop(); result = parent.getNext(); if ( result != null ) { break; } } // at this point, result is only null if the stack is empty and we reached the end of the search. } } } }
/** * Conditionally writes an end-of-line character. The End-Of-Line is only written, if the tag description indicates * that the currently open element does not expect any CDATA inside. Writing a newline for CDATA-elements may have * sideeffects. * * @param w the writer. * @throws java.io.IOException if there is an I/O problem. */ private void doEndOfLine( final Writer w ) throws IOException { if ( openTags.isEmpty() ) { if ( isWriteFinalLinebreak() ) { writeNewLine( w ); } } else { final ElementLevel level = (ElementLevel) openTags.peek(); if ( getTagDescription().hasCData( level.getNamespace(), level.getTagName() ) == false ) { writeNewLine( w ); } } }
public void resolveParent( final ReportElement element, final ElementStyleSheet resolverTarget ) { if ( designTime == false ) { final Section parentSection = element.getParentSection(); if ( parentSection == null ) { return; } final SimpleStyleSheet computedStyle = parentSection.getComputedStyle(); resolverTarget.addInherited( computedStyle ); } final FastStack<Section> parentSections = new FastStack<Section>(); ReportElement e = element; while ( e.getParentSection() != null ) { final Section section = e.getParentSection(); parentSections.push( section ); e = section; } while ( parentSections.isEmpty() == false ) { final Section section = parentSections.pop(); resolverTarget.addInherited( section.getStyle() ); } }