Package org.apache.cocoon.xml.sax

Examples of org.apache.cocoon.xml.sax.AttributesImpl


            throw new ProcessingException("Failed to generate exception document.", e);
        }
    }

    private void toSAX(Throwable throwable, ContentHandler handler) throws SAXException {
        AttributesImpl attr = new AttributesImpl();
        // handler.startPrefixMapping("ex", EXCEPTION_NS);
        attr.addCDATAAttribute("class", throwable.getClass().getName());
        attr.addCDATAAttribute("timestamp", this.dateFormat.format(new Date()));
        handler.startElement(EXCEPTION_NS, "exception-report", "exception-report", attr);
        // handler.startElement(EXCEPTION_NS, "exception-report", "ex:exception-report", attr);

        // exception message
        attr.clear();
        simpleElement("message", attr, throwable.getMessage(), handler);

        // exception stacktrace
        attr.clear();
        StringWriter sw = new StringWriter();
        PrintWriter pw = new PrintWriter(sw, true);
        throwable.printStackTrace(pw);
        simpleElement("stacktrace", attr, sw.getBuffer().toString(), handler);
View Full Code Here


    public void execute() {
        this.consumer = this.getSAXConsumer();
        try {
            this.consumer.startDocument();

            AttributesImpl attr = new AttributesImpl();
            this.addStringAttribute(attr, "id", this.id);

            this.startElement("cocoon-profiling", attr);
            ComponentTreeElement root = this.buildComponentTree(this.profilingData);
            this.handleTreeElement(root);
View Full Code Here

        if (element == null) {
            throw new RuntimeException("ProfilingGenerator can't create element for " + target.getName());
        }

        if (this.showElement(treeElement)) {
            AttributesImpl attr = new AttributesImpl();
            this.addStringAttribute(attr, "name", treeElement.getDisplayName());
            this.addStringAttribute(attr, "executionTime", this.milliString(treeElement.getExecutionMillis()));

            this.startElement(element, attr);

            AttributesImpl attr2 = new AttributesImpl();
            this.addStringAttribute(attr2, "class", treeElement.getProfiler());
            this.addSimple("profiler", attr2);

            this.startElement("invocations");
            for (ProfilingData data : treeElement.getInvocations()) {
View Full Code Here

    private String milliString(double executionTime) {
        return String.format(Locale.US, "%.3fms", executionTime);
    }

    private void handleInvocation(ProfilingData data) throws SAXException {
        AttributesImpl attr = new AttributesImpl();
        this.addStringAttribute(attr, "method", data.getMethod());
        this.addStringAttribute(attr, "executionTime", this.milliString(data.getExecutionMillis()));

        this.startElement("invocation", attr);

        this.startElement("properties");
        for (Entry<String, String> entry : data.getData().entrySet()) {
            AttributesImpl attr2 = new AttributesImpl();
            this.addStringAttribute(attr2, "id", entry.getKey());

            this.startElement("property", attr2);
            this.addData(entry.getValue());
            this.endElement();
        }
        this.endElement();

        this.startElement("arguments");
        for (InstanceRepresentation arg : data.getArguments()) {
            this.addArgument(arg);
        }
        this.endElement();

        this.startElement("result");
        if (data.getException() != null) {
            AttributesImpl attr2 = new AttributesImpl();
            this.addStringAttribute(attr2, "class", data.getException().getClass().getName());
            this.addStringAttribute(attr2, "message", data.getException().getMessage());
            this.addSimple("exception", attr2);
        } else {
            String classname;

            if (data.getReturnValue().getRepresentedClass() == null) {
                classname = "";
            } else {
                classname = data.getReturnValue().getRepresentedClass().getName();
            }

            AttributesImpl attr3 = new AttributesImpl();
            this.addStringAttribute(attr3, "class", classname);
            this.startElement("return-value", attr3);
            this.addSimple("value", data.getReturnValue().getStringRepresentation());
            this.endElement();
        }
View Full Code Here

        this.startElement(name, attr);
        this.endElement();
    }

    private void addArgument(InstanceRepresentation data) throws SAXException {
        AttributesImpl attr = new AttributesImpl();

        Class<?> clazz = data.getRepresentedClass();
        String value = data.getStringRepresentation();

        this.addStringAttribute(attr, "class", clazz == null ? "null" : clazz.getName());
View Full Code Here

TOP

Related Classes of org.apache.cocoon.xml.sax.AttributesImpl

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.