bloritsch    02/01/09 13:30:11

  Modified:    src/java/org/apache/cocoon/environment
                        AbstractEnvironment.java
               src/java/org/apache/cocoon/environment/commandline
                        LinkSamplingEnvironment.java
               src/java/org/apache/cocoon/xml/xlink XLinkPipe.java
  Log:
  Fix whitespace on XLink classes (what a mess), optimize logging on 
CommandLineEnvironment
  
  Revision  Changes    Path
  1.2       +37 -21    
xml-cocoon2/src/java/org/apache/cocoon/environment/AbstractEnvironment.java
  
  Index: AbstractEnvironment.java
  ===================================================================
  RCS file: 
/home/cvs/xml-cocoon2/src/java/org/apache/cocoon/environment/AbstractEnvironment.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- AbstractEnvironment.java  3 Jan 2002 12:31:15 -0000       1.1
  +++ AbstractEnvironment.java  9 Jan 2002 21:30:10 -0000       1.2
  @@ -26,7 +26,7 @@
    *
    * @author <a href="mailto:[EMAIL PROTECTED]";>Giacomo Pati</a>
    * @author <a href="mailto:[EMAIL PROTECTED]";>Carsten Ziegeler</a>
  - * @version CVS $Revision: 1.1 $ $Date: 2002/01/03 12:31:15 $
  + * @version CVS $Revision: 1.2 $ $Date: 2002/01/09 21:30:10 $
    */
   public abstract class AbstractEnvironment extends AbstractLoggable implements 
Environment {
   
  @@ -150,7 +150,9 @@
        * Set the prefix of the URI in progress
        */
       protected void setURIPrefix(String prefix) {
  -        getLogger().debug("Set the URI Prefix (OLD=" + this.prefix.toString() + ", 
NEW=" +  prefix + ")");
  +        if (getLogger().isDebugEnabled()) {
  +            getLogger().debug("Set the URI Prefix (OLD=" + getURIPrefix() + ", 
NEW=" +  prefix + ")");
  +        }
           this.prefix = new StringBuffer(prefix);
       }
   
  @@ -169,7 +171,9 @@
           this.setContext(getRootContext());
           this.setURIPrefix(prefix == null ? "" : prefix);
           this.uris = uri;
  -        getLogger().debug("Reset context to " + this.context);
  +        if (getLogger().isDebugEnabled()) {
  +            getLogger().debug("Reset context to " + this.context);
  +        }
       }
   
       /**
  @@ -177,18 +181,22 @@
        */
       public void changeContext(String prefix, String newContext)
       throws MalformedURLException {
  -        getLogger().debug("Changing Cocoon context(" + newContext + ") to prefix(" 
+ prefix + ")");
  -        getLogger().debug("\tfrom context(" + this.context.toExternalForm() + ") 
and prefix(" + this.prefix + ")");
  -        getLogger().debug("\tat URI " + this.uris);
  +        if (getLogger().isDebugEnabled())
  +        {
  +            getLogger().debug("Changing Cocoon context(" + newContext + ") to 
prefix(" + prefix + ")");
  +            getLogger().debug("\tfrom context(" + this.context.toExternalForm() + 
") and prefix(" + this.prefix + ")");
  +            getLogger().debug("\tat URI " + this.uris);
  +        }
           if (prefix.length() >= 1 && this.uris.startsWith(prefix) == false) {
  -            this.getLogger().error("The current URI ("
  -                    + this.uris + ") doesn't start with given prefix ("
  -                    + prefix + ")"
  -            );
  -            throw new RuntimeException("The current URI ("
  -                    + this.uris + ") doesn't start with given prefix ("
  -                    + prefix + ")"
  -            );
  +            if (getLogger().isErrorEnabled())
  +            {
  +                this.getLogger().error("The current URI ("
  +                        + this.uris + ") doesn't start with given prefix ("
  +                        + prefix + ")"
  +                );
  +            }
  +
  +            throw new RuntimeException("The current URI doesn't start with given 
prefix");
           }
           if (prefix.length() >= 1) {
               this.prefix.append(prefix);
  @@ -221,7 +229,10 @@
                   this.context = f.toURL();
               }
           }
  -        getLogger().debug("New context is " + this.context.toExternalForm());
  +        
  +        if (getLogger().isDebugEnabled()) {
  +            getLogger().debug("New context is " + this.context.toExternalForm());
  +        }
       }
   
       /**
  @@ -270,7 +281,9 @@
        */
       public Source resolve(String systemId)
       throws ProcessingException, SAXException, IOException {
  -        this.getLogger().debug("Resolving '"+systemId+"' in context '" + 
this.context + "'");
  +        if (getLogger().isDebugEnabled()) {
  +            this.getLogger().debug("Resolving '"+systemId+"' in context '" + 
this.context + "'");
  +        }
           if (systemId == null) throw new SAXException("Invalid System ID");
   
           Source source;
  @@ -279,16 +292,19 @@
           } else if (systemId.indexOf(":") > 1) {
               source = this.sourceHandler.getSource(this, systemId);
           } else if (systemId.charAt(0) == '/') {
  -            source = this.sourceHandler.getSource(this, new 
StringBuffer(this.context.getProtocol())
  -                                                  
.append(":").append(systemId).toString());
  +            source = this.sourceHandler.getSource(this, this.context.getProtocol() +
  +                                                  ":" + systemId);
           // windows: absolute paths can start with drive letter
           } else if (systemId.length() > 1 && systemId.charAt(1) == ':') {
  -            source = this.sourceHandler.getSource(this, new 
StringBuffer(this.context.getProtocol())
  -                                                  
.append(":/").append(systemId).toString());
  +            source = this.sourceHandler.getSource(this, this.context.getProtocol() +
  +                                                  ":/" + systemId);
           } else {
               source = this.sourceHandler.getSource(this, this.context, systemId);
           }
  -        this.getLogger().debug("Resolved to '"+source.getSystemId()+"'");
  +        
  +        if (getLogger().isDebugEnabled()) {
  +            this.getLogger().debug("Resolved to '"+source.getSystemId()+"'");
  +        }
           return source;
       }
   
  
  
  
  1.2       +41 -31    
xml-cocoon2/src/java/org/apache/cocoon/environment/commandline/LinkSamplingEnvironment.java
  
  Index: LinkSamplingEnvironment.java
  ===================================================================
  RCS file: 
/home/cvs/xml-cocoon2/src/java/org/apache/cocoon/environment/commandline/LinkSamplingEnvironment.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- LinkSamplingEnvironment.java      3 Jan 2002 12:31:16 -0000       1.1
  +++ LinkSamplingEnvironment.java      9 Jan 2002 21:30:10 -0000       1.2
  @@ -1,10 +1,10 @@
   /*****************************************************************************
  - * Copyright (C) The Apache Software Foundation. All rights reserved.        *
  - * ------------------------------------------------------------------------- *
  - * This software is published under the terms of the Apache Software License *
  - * version 1.1, a copy of which has been included  with this distribution in *
  - * the LICENSE file.                                                         *
  - *****************************************************************************/
  +* Copyright (C) The Apache Software Foundation. All rights reserved.        *
  +* ------------------------------------------------------------------------- *
  +* This software is published under the terms of the Apache Software License *
  +* version 1.1, a copy of which has been included  with this distribution in *
  +* the LICENSE file.                                                         *
  +*****************************************************************************/
   package org.apache.cocoon.environment.commandline;
   
   import org.apache.cocoon.Constants;
  @@ -20,30 +20,36 @@
    * This environment is sample the links of the resource.
    *
    * @author <a href="mailto:[EMAIL PROTECTED]";>Stefano Mazzocchi</a>
  - * @version CVS $Revision: 1.1 $ $Date: 2002/01/03 12:31:16 $
  + * @version CVS $Revision: 1.2 $ $Date: 2002/01/09 21:30:10 $
    */
   
  -public class LinkSamplingEnvironment extends AbstractCommandLineEnvironment {
  +public class LinkSamplingEnvironment extends AbstractCommandLineEnvironment
  +{
   
       private boolean skip = false;
   
  -    public LinkSamplingEnvironment(String uri,
  -                                   File contextFile,
  -                                   Map attributes,
  -                                   Map parameters,
  -                                   Logger log)
  -    throws MalformedURLException, IOException {
  -        super(uri, Constants.LINK_VIEW, contextFile, new ByteArrayOutputStream(), 
log);
  -        this.getLogger().debug("LinkSamplingEnvironment: uri = " + uri);
  -        this.objectModel.put(Constants.REQUEST_OBJECT, new CommandLineRequest(this, 
null, uri, null, attributes, parameters));
  -        this.objectModel.put(Constants.RESPONSE_OBJECT, new CommandLineResponse());
  +    public LinkSamplingEnvironment( String uri,
  +                                    File contextFile,
  +                                    Map attributes,
  +                                    Map parameters,
  +                                    Logger log )
  +    throws MalformedURLException, IOException
  +    {
  +        super( uri, Constants.LINK_VIEW, contextFile, new ByteArrayOutputStream(), 
log );
  +        if (getLogger().isDebugEnabled()) {
  +            this.getLogger().debug( "LinkSamplingEnvironment: uri = " + uri );
  +        }
  +        this.objectModel.put( Constants.REQUEST_OBJECT, new CommandLineRequest( 
this, null, uri, null, attributes, parameters ) );
  +        this.objectModel.put( Constants.RESPONSE_OBJECT, new CommandLineResponse() 
);
       }
   
       /**
        * Set the ContentType
        */
  -    public void setContentType(String contentType) {
  -        if (Constants.LINK_CONTENT_TYPE.equals(contentType) == false) {
  +    public void setContentType( String contentType )
  +    {
  +        if ( Constants.LINK_CONTENT_TYPE.equals( contentType ) == false )
  +        {
               this.skip = true;
           }
       }
  @@ -51,20 +57,24 @@
       /**
        * Indicates if other links are present.
        */
  -    public Collection getLinks() throws IOException {
  +    public Collection getLinks() throws IOException
  +    {
           ArrayList list = new ArrayList();
  -        if (!skip) {
  +        if ( !skip )
  +        {
               BufferedReader buffer = new BufferedReader(
  -                new InputStreamReader(
  -                    new ByteArrayInputStream(
  -                        ((ByteArrayOutputStream) super.stream).toByteArray()
  -                    )
  -                )
  -            );
  -            while (true) {
  +                                        new InputStreamReader(
  +                                            new ByteArrayInputStream(
  +                                                ( ( ByteArrayOutputStream ) 
super.stream ).toByteArray()
  +                                            )
  +                                        )
  +                                    );
  +            while ( true )
  +            {
                   String line = buffer.readLine();
  -                if (line == null) break;
  -                list.add(line);
  +                if ( line == null )
  +                    break;
  +                list.add( line );
               }
           }
           return list;
  
  
  
  1.2       +281 -203  xml-cocoon2/src/java/org/apache/cocoon/xml/xlink/XLinkPipe.java
  
  Index: XLinkPipe.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/xml/xlink/XLinkPipe.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- XLinkPipe.java    3 Jan 2002 12:31:23 -0000       1.1
  +++ XLinkPipe.java    9 Jan 2002 21:30:10 -0000       1.2
  @@ -1,10 +1,10 @@
   /*****************************************************************************
  - * Copyright (C) The Apache Software Foundation. All rights reserved.        *
  - * ------------------------------------------------------------------------- *
  - * This software is published under the terms of the Apache Software License *
  - * version 1.1, a copy of which has been included  with this distribution in *
  - * the LICENSE file.                                                         *
  - *****************************************************************************/
  +* Copyright (C) The Apache Software Foundation. All rights reserved.        *
  +* ------------------------------------------------------------------------- *
  +* This software is published under the terms of the Apache Software License *
  +* version 1.1, a copy of which has been included  with this distribution in *
  +* the LICENSE file.                                                         *
  +*****************************************************************************/
   
   package org.apache.cocoon.xml.xlink;
   
  @@ -23,28 +23,29 @@
    * NOTE: this is based on XLink W3C Candidate Recommendation 3 July 2000
    *
    * @author <a href="mailto:[EMAIL PROTECTED]";>Stefano Mazzocchi</a>
  - * @version CVS $Revision: 1.1 $ $Date: 2002/01/03 12:31:23 $
  + * @version CVS $Revision: 1.2 $ $Date: 2002/01/09 21:30:10 $
    */
   
  -public abstract class XLinkPipe extends AbstractXMLPipe implements XLinkHandler {
  +public abstract class XLinkPipe extends AbstractXMLPipe implements XLinkHandler
  +{
   
  -        public static final String XLINK_NAMESPACE_URI = 
"http://www.w3.org/1999/xlink";;
  -        public static final String XLINK_TYPE          = "type";
  -        public static final String XLINK_HREF          = "href";
  -        public static final String XLINK_ROLE          = "role";
  -        public static final String XLINK_ARCROLE       = "arcrole";
  -        public static final String XLINK_TITLE         = "title";
  -        public static final String XLINK_SHOW          = "show";
  -        public static final String XLINK_ACTUATE       = "actuate";
  -        public static final String XLINK_LABEL         = "label";
  -        public static final String XLINK_FROM          = "from";
  -        public static final String XLINK_TO            = "to";
  -        public static final String XLINK_TYPE_SIMPLE   = "simple";
  -        public static final String XLINK_TYPE_EXTENDED = "extended";
  -        public static final String XLINK_TYPE_LOCATOR  = "locator";
  -        public static final String XLINK_TYPE_ARC      = "arc";
  -        public static final String XLINK_TYPE_RESOURCE = "resource";
  -        public static final String XLINK_TYPE_TITLE    = "title";
  +    public static final String XLINK_NAMESPACE_URI = "http://www.w3.org/1999/xlink";;
  +    public static final String XLINK_TYPE = "type";
  +    public static final String XLINK_HREF = "href";
  +    public static final String XLINK_ROLE = "role";
  +    public static final String XLINK_ARCROLE = "arcrole";
  +    public static final String XLINK_TITLE = "title";
  +    public static final String XLINK_SHOW = "show";
  +    public static final String XLINK_ACTUATE = "actuate";
  +    public static final String XLINK_LABEL = "label";
  +    public static final String XLINK_FROM = "from";
  +    public static final String XLINK_TO = "to";
  +    public static final String XLINK_TYPE_SIMPLE = "simple";
  +    public static final String XLINK_TYPE_EXTENDED = "extended";
  +    public static final String XLINK_TYPE_LOCATOR = "locator";
  +    public static final String XLINK_TYPE_ARC = "arc";
  +    public static final String XLINK_TYPE_RESOURCE = "resource";
  +    public static final String XLINK_TYPE_TITLE = "title";
   
       private String extendedLinkElementName = null;
       private String extendedLinkElementURI = null;
  @@ -53,193 +54,270 @@
       private String linkArcElementName = null;
       private String linkArcElementURI = null;
   
  -        public void startElement(String uri, String name, String raw, Attributes 
attr) throws SAXException {
  -                String type = attr.getValue(XLINK_NAMESPACE_URI, XLINK_TYPE);
  -                if (type != null) {
  -                    if (type.equals(XLINK_TYPE_SIMPLE)) {
  -                        if (this.extendedLinkElementName != null) {
  -                            throw new SAXException("An XLink simple link cannot be 
included into an 'extended' element");
  -                        } else if (this.linkLocatorElementName != null) {
  -                            throw new SAXException("An XLink simple link cannot be 
included into a 'locator' element");
  -                        } else if (this.linkArcElementName != null) {
  -                            throw new SAXException("An XLink simple link cannot be 
included into an 'arc' element");
  -                        }
  -                        String href    = attr.getValue(XLINK_NAMESPACE_URI, 
XLINK_HREF);
  -                        String role    = attr.getValue(XLINK_NAMESPACE_URI, 
XLINK_ROLE);
  -                        String arcrole = attr.getValue(XLINK_NAMESPACE_URI, 
XLINK_ARCROLE);
  -                        String title   = attr.getValue(XLINK_NAMESPACE_URI, 
XLINK_TITLE);
  -                        String show    = attr.getValue(XLINK_NAMESPACE_URI, 
XLINK_SHOW);
  -                        String actuate = attr.getValue(XLINK_NAMESPACE_URI, 
XLINK_ACTUATE);
  -                        simpleLink(href, role, arcrole, title, show, actuate, uri, 
name, raw, attr);
  -                    } else if (type.equals(XLINK_TYPE_EXTENDED)) {
  -                        if (this.extendedLinkElementName != null) {
  -                            throw new SAXException("An XLink extended link cannot 
include another 'extended' element");
  -                        } else if (this.linkLocatorElementName != null) {
  -                            throw new SAXException("An XLink extended link cannot 
be included into a 'locator' element");
  -                        } else if (this.linkArcElementName != null) {
  -                            throw new SAXException("An XLink extended link cannot 
be included into an 'arc' element");
  -                        }
  -                        String role    = attr.getValue(XLINK_NAMESPACE_URI, 
XLINK_ROLE);
  -                        String title   = attr.getValue(XLINK_NAMESPACE_URI, 
XLINK_TITLE);
  -                        this.extendedLinkElementName = name;
  -                        this.extendedLinkElementURI = uri;
  -                        startExtendedLink(role, title, uri, name, raw, attr);
  -                    } else if (type.equals(XLINK_TYPE_LOCATOR)) {
  -                if (this.extendedLinkElementName == null) {
  -                            throw new SAXException("An XLink locator must be 
included into an 'extended' element");
  -                } else if (this.linkLocatorElementName != null) {
  -                            throw new SAXException("An XLink locator  cannot be 
included into another 'locator' element");
  -                        } else if (this.linkArcElementName != null) {
  -                            throw new SAXException("An XLink locator cannot be 
included into an 'arc' element");
  -                        }
  -                        String href    = attr.getValue(XLINK_NAMESPACE_URI, 
XLINK_HREF);
  -                        String role    = attr.getValue(XLINK_NAMESPACE_URI, 
XLINK_ROLE);
  -                        String title   = attr.getValue(XLINK_NAMESPACE_URI, 
XLINK_TITLE);
  -                        String label   = attr.getValue(XLINK_NAMESPACE_URI, 
XLINK_LABEL);
  -                        this.linkLocatorElementName = name;
  -                        this.linkLocatorElementURI = uri;
  -                        startLocator(href, role, title, label, uri, name, raw, 
attr);
  -                    } else if (type.equals(XLINK_TYPE_ARC)) {
  -                if (this.extendedLinkElementName == null) {
  -                            throw new SAXException("An XLink arc must be included 
into an 'extended' element");
  -                } else if (this.linkLocatorElementName != null) {
  -                            throw new SAXException("An XLink arc cannot be included 
into a 'locator' element");
  -                        } else if (this.linkArcElementName != null) {
  -                            throw new SAXException("An XLink arc cannot be included 
into another 'arc' element");
  -                        }
  -                        String arcrole = attr.getValue(XLINK_NAMESPACE_URI, 
XLINK_ARCROLE);
  -                        String title   = attr.getValue(XLINK_NAMESPACE_URI, 
XLINK_TITLE);
  -                        String show    = attr.getValue(XLINK_NAMESPACE_URI, 
XLINK_SHOW);
  -                        String actuate = attr.getValue(XLINK_NAMESPACE_URI, 
XLINK_ACTUATE);
  -                        String from    = attr.getValue(XLINK_NAMESPACE_URI, 
XLINK_FROM);
  -                        String to      = attr.getValue(XLINK_NAMESPACE_URI, 
XLINK_TO);
  -                        this.linkArcElementName = name;
  -                        this.linkArcElementURI = uri;
  -                        startArc(arcrole, title, show, actuate, from, to, uri, 
name, raw, attr);
  -                    } else if (type.equals(XLINK_TYPE_RESOURCE)) {
  -                if (this.extendedLinkElementName == null) {
  -                            throw new SAXException("An XLink resource must be 
included into an 'extended' element");
  -                        }
  -                        String role    = attr.getValue(XLINK_NAMESPACE_URI, 
XLINK_ROLE);
  -                        String title   = attr.getValue(XLINK_NAMESPACE_URI, 
XLINK_TITLE);
  -                        String label   = attr.getValue(XLINK_NAMESPACE_URI, 
XLINK_LABEL);
  -                        linkResource(role, title, label, uri, name, raw, attr);
  -                    } else if (type.equals(XLINK_TYPE_TITLE)) {
  -                if ((this.extendedLinkElementName == null)
  -                  && (this.linkLocatorElementName == null)
  -                  && (this.linkArcElementName == null)) {
  -                            throw new SAXException("An XLink title must be included 
into an 'extended', 'locator' or 'arc' element");
  -                        }
  -                        linkTitle(uri, name, raw, attr);
  -                    } else {
  -                super.startElement(uri, name, raw, attr);
  -            }
  -                } else {
  -            super.startElement(uri, name, raw, attr);
  -        }
  -        }
  -
  -        public void endElement(String uri, String name, String raw) throws 
SAXException {
  -            if ((name.equals(this.extendedLinkElementName)) && 
(uri.equals(this.extendedLinkElementURI))) {
  -                this.extendedLinkElementName = null;
  -                this.extendedLinkElementURI = null;
  -                this.endExtendedLink(uri, name, raw);
  -            } else if ((name.equals(this.linkLocatorElementName)) && 
(uri.equals(this.linkLocatorElementURI))) {
  -                this.linkLocatorElementName = null;
  -                this.linkLocatorElementURI = null;
  -                this.endLocator(uri, name, raw);
  -            } else if ((name.equals(this.linkArcElementName)) && 
(uri.equals(this.linkArcElementURI))) {
  -                this.linkArcElementName = null;
  -                this.linkArcElementURI = null;
  -                this.endArc(uri, name, raw);
  -            } else {
  -                super.endElement(uri, name, raw);
  +    public void startElement( String uri, String name, String raw, Attributes attr 
) throws SAXException
  +    {
  +        String type = attr.getValue( XLINK_NAMESPACE_URI, XLINK_TYPE );
  +        if ( type != null )
  +        {
  +            if ( type.equals( XLINK_TYPE_SIMPLE ) )
  +            {
  +                if ( this.extendedLinkElementName != null )
  +                {
  +                    throw new SAXException( "An XLink simple link cannot be 
included into an 'extended' element" );
  +                }
  +                else if ( this.linkLocatorElementName != null )
  +                {
  +                    throw new SAXException( "An XLink simple link cannot be 
included into a 'locator' element" );
  +                }
  +                else if ( this.linkArcElementName != null )
  +                {
  +                    throw new SAXException( "An XLink simple link cannot be 
included into an 'arc' element" );
  +                }
  +                String href = attr.getValue( XLINK_NAMESPACE_URI, XLINK_HREF );
  +                String role = attr.getValue( XLINK_NAMESPACE_URI, XLINK_ROLE );
  +                String arcrole = attr.getValue( XLINK_NAMESPACE_URI, XLINK_ARCROLE 
);
  +                String title = attr.getValue( XLINK_NAMESPACE_URI, XLINK_TITLE );
  +                String show = attr.getValue( XLINK_NAMESPACE_URI, XLINK_SHOW );
  +                String actuate = attr.getValue( XLINK_NAMESPACE_URI, XLINK_ACTUATE 
);
  +                simpleLink( href, role, arcrole, title, show, actuate, uri, name, 
raw, attr );
               }
  +            else if ( type.equals( XLINK_TYPE_EXTENDED ) )
  +            {
  +                if ( this.extendedLinkElementName != null )
  +                {
  +                    throw new SAXException( "An XLink extended link cannot include 
another 'extended' element" );
  +                }
  +                else if ( this.linkLocatorElementName != null )
  +                {
  +                    throw new SAXException( "An XLink extended link cannot be 
included into a 'locator' element" );
  +                }
  +                else if ( this.linkArcElementName != null )
  +                {
  +                    throw new SAXException( "An XLink extended link cannot be 
included into an 'arc' element" );
  +                }
  +                String role = attr.getValue( XLINK_NAMESPACE_URI, XLINK_ROLE );
  +                String title = attr.getValue( XLINK_NAMESPACE_URI, XLINK_TITLE );
  +                this.extendedLinkElementName = name;
  +                this.extendedLinkElementURI = uri;
  +                startExtendedLink( role, title, uri, name, raw, attr );
  +            }
  +            else if ( type.equals( XLINK_TYPE_LOCATOR ) )
  +            {
  +                if ( this.extendedLinkElementName == null )
  +                {
  +                    throw new SAXException( "An XLink locator must be included into 
an 'extended' element" );
  +                }
  +                else if ( this.linkLocatorElementName != null )
  +                {
  +                    throw new SAXException( "An XLink locator  cannot be included 
into another 'locator' element" );
  +                }
  +                else if ( this.linkArcElementName != null )
  +                {
  +                    throw new SAXException( "An XLink locator cannot be included 
into an 'arc' element" );
  +                }
  +                String href = attr.getValue( XLINK_NAMESPACE_URI, XLINK_HREF );
  +                String role = attr.getValue( XLINK_NAMESPACE_URI, XLINK_ROLE );
  +                String title = attr.getValue( XLINK_NAMESPACE_URI, XLINK_TITLE );
  +                String label = attr.getValue( XLINK_NAMESPACE_URI, XLINK_LABEL );
  +                this.linkLocatorElementName = name;
  +                this.linkLocatorElementURI = uri;
  +                startLocator( href, role, title, label, uri, name, raw, attr );
  +            }
  +            else if ( type.equals( XLINK_TYPE_ARC ) )
  +            {
  +                if ( this.extendedLinkElementName == null )
  +                {
  +                    throw new SAXException( "An XLink arc must be included into an 
'extended' element" );
  +                }
  +                else if ( this.linkLocatorElementName != null )
  +                {
  +                    throw new SAXException( "An XLink arc cannot be included into a 
'locator' element" );
  +                }
  +                else if ( this.linkArcElementName != null )
  +                {
  +                    throw new SAXException( "An XLink arc cannot be included into 
another 'arc' element" );
  +                }
  +                String arcrole = attr.getValue( XLINK_NAMESPACE_URI, XLINK_ARCROLE 
);
  +                String title = attr.getValue( XLINK_NAMESPACE_URI, XLINK_TITLE );
  +                String show = attr.getValue( XLINK_NAMESPACE_URI, XLINK_SHOW );
  +                String actuate = attr.getValue( XLINK_NAMESPACE_URI, XLINK_ACTUATE 
);
  +                String from = attr.getValue( XLINK_NAMESPACE_URI, XLINK_FROM );
  +                String to = attr.getValue( XLINK_NAMESPACE_URI, XLINK_TO );
  +                this.linkArcElementName = name;
  +                this.linkArcElementURI = uri;
  +                startArc( arcrole, title, show, actuate, from, to, uri, name, raw, 
attr );
  +            }
  +            else if ( type.equals( XLINK_TYPE_RESOURCE ) )
  +            {
  +                if ( this.extendedLinkElementName == null )
  +                {
  +                    throw new SAXException( "An XLink resource must be included 
into an 'extended' element" );
  +                }
  +                String role = attr.getValue( XLINK_NAMESPACE_URI, XLINK_ROLE );
  +                String title = attr.getValue( XLINK_NAMESPACE_URI, XLINK_TITLE );
  +                String label = attr.getValue( XLINK_NAMESPACE_URI, XLINK_LABEL );
  +                linkResource( role, title, label, uri, name, raw, attr );
  +            }
  +            else if ( type.equals( XLINK_TYPE_TITLE ) )
  +            {
  +                if ( ( this.extendedLinkElementName == null )
  +                        && ( this.linkLocatorElementName == null )
  +                        && ( this.linkArcElementName == null ) )
  +                {
  +                    throw new SAXException( "An XLink title must be included into 
an 'extended', 'locator' or 'arc' element" );
  +                }
  +                linkTitle( uri, name, raw, attr );
  +            }
  +            else
  +            {
  +                super.startElement( uri, name, raw, attr );
  +            }
  +        }
  +        else
  +        {
  +            super.startElement( uri, name, raw, attr );
  +        }
  +    }
  +
  +    public void endElement( String uri, String name, String raw ) throws 
SAXException
  +    {
  +        if ( ( name.equals( this.extendedLinkElementName ) ) && ( uri.equals( 
this.extendedLinkElementURI ) ) )
  +        {
  +            this.extendedLinkElementName = null;
  +            this.extendedLinkElementURI = null;
  +            this.endExtendedLink( uri, name, raw );
  +        }
  +        else if ( ( name.equals( this.linkLocatorElementName ) ) && ( uri.equals( 
this.linkLocatorElementURI ) ) )
  +        {
  +            this.linkLocatorElementName = null;
  +            this.linkLocatorElementURI = null;
  +            this.endLocator( uri, name, raw );
  +        }
  +        else if ( ( name.equals( this.linkArcElementName ) ) && ( uri.equals( 
this.linkArcElementURI ) ) )
  +        {
  +            this.linkArcElementName = null;
  +            this.linkArcElementURI = null;
  +            this.endArc( uri, name, raw );
  +        }
  +        else
  +        {
  +            super.endElement( uri, name, raw );
           }
  +    }
   
       // Default XLinkHandler implementation (defaults to copy over)
   
  -    public void simpleLink(String href, String role, String arcrole, String title, 
String show, String actuate, String uri, String name, String raw, Attributes attr) 
throws SAXException {
  -        AttributesImpl newattr = new AttributesImpl(attr);
  -        int hrefIndex = attr.getIndex(XLINK_NAMESPACE_URI, XLINK_HREF);
  -        int roleIndex = attr.getIndex(XLINK_NAMESPACE_URI, XLINK_ROLE);
  -        int arcroleIndex = attr.getIndex(XLINK_NAMESPACE_URI, XLINK_ARCROLE);
  -        int titleIndex = attr.getIndex(XLINK_NAMESPACE_URI, XLINK_TITLE);
  -        int showIndex = attr.getIndex(XLINK_NAMESPACE_URI, XLINK_SHOW);
  -        int actuateIndex = attr.getIndex(XLINK_NAMESPACE_URI, XLINK_ACTUATE);
  -        if (hrefIndex > -1) newattr.setValue(hrefIndex, href);
  -        if (roleIndex > -1) newattr.setValue(roleIndex, role);
  -        if (arcroleIndex > -1) newattr.setValue(arcroleIndex, arcrole);
  -        if (titleIndex > -1) newattr.setValue(titleIndex, title);
  -        if (showIndex > -1) newattr.setValue(showIndex, show);
  -        if (actuateIndex > -1) newattr.setValue(actuateIndex, actuate);
  -        super.startElement(uri, name, raw, newattr);
  -    }
  -
  -    public void startExtendedLink(String role, String title, String uri, String 
name, String raw, Attributes attr) throws SAXException {
  -        AttributesImpl newattr = new AttributesImpl(attr);
  -        int roleIndex = attr.getIndex(XLINK_NAMESPACE_URI, XLINK_ROLE);
  -        int titleIndex = attr.getIndex(XLINK_NAMESPACE_URI, XLINK_TITLE);
  -        if (roleIndex > -1) newattr.setValue(roleIndex, role);
  -        if (titleIndex > -1) newattr.setValue(titleIndex, title);
  -        super.startElement(uri, name, raw, newattr);
  -    }
  -
  -    public void startLocator(String href, String role, String title, String label, 
String uri, String name, String raw, Attributes attr) throws SAXException {
  -        AttributesImpl newattr = new AttributesImpl(attr);
  -        int hrefIndex = attr.getIndex(XLINK_NAMESPACE_URI, XLINK_HREF);
  -        int roleIndex = attr.getIndex(XLINK_NAMESPACE_URI, XLINK_ROLE);
  -        int titleIndex = attr.getIndex(XLINK_NAMESPACE_URI, XLINK_TITLE);
  -        int labelIndex = attr.getIndex(XLINK_NAMESPACE_URI, XLINK_LABEL);
  -        if (hrefIndex > -1) newattr.setValue(hrefIndex, href);
  -        if (roleIndex > -1) newattr.setValue(roleIndex, role);
  -        if (titleIndex > -1) newattr.setValue(titleIndex, title);
  -        if (labelIndex > -1) newattr.setValue(labelIndex, label);
  -        super.startElement(uri, name, raw, newattr);
  -    }
  -
  -    public void startArc(String arcrole, String title, String show, String actuate, 
String from, String to, String uri, String name, String raw, Attributes attr) throws 
SAXException {
  -        AttributesImpl newattr = new AttributesImpl(attr);
  -        int arcroleIndex = attr.getIndex(XLINK_NAMESPACE_URI, XLINK_ARCROLE);
  -        int titleIndex = attr.getIndex(XLINK_NAMESPACE_URI, XLINK_TITLE);
  -        int showIndex = attr.getIndex(XLINK_NAMESPACE_URI, XLINK_SHOW);
  -        int actuateIndex = attr.getIndex(XLINK_NAMESPACE_URI, XLINK_ACTUATE);
  -        int fromIndex = attr.getIndex(XLINK_NAMESPACE_URI, XLINK_FROM);
  -        int toIndex = attr.getIndex(XLINK_NAMESPACE_URI, XLINK_TO);
  -        if (arcroleIndex > -1) newattr.setValue(arcroleIndex, arcrole);
  -        if (titleIndex > -1) newattr.setValue(titleIndex, title);
  -        if (showIndex > -1) newattr.setValue(showIndex, show);
  -        if (actuateIndex > -1) newattr.setValue(actuateIndex, actuate);
  -        if (fromIndex > -1) newattr.setValue(actuateIndex, from);
  -        if (toIndex > -1) newattr.setValue(actuateIndex, to);
  -        super.startElement(uri, name, raw, newattr);
  -    }
  -
  -    public void linkResource(String role, String title, String label, String uri, 
String name, String raw, Attributes attr) throws SAXException {
  -        AttributesImpl newattr = new AttributesImpl(attr);
  -        int roleIndex = attr.getIndex(XLINK_NAMESPACE_URI, XLINK_ROLE);
  -        int titleIndex = attr.getIndex(XLINK_NAMESPACE_URI, XLINK_TITLE);
  -        int labelIndex = attr.getIndex(XLINK_NAMESPACE_URI, XLINK_LABEL);
  -        if (roleIndex > -1) newattr.setValue(roleIndex, role);
  -        if (titleIndex > -1) newattr.setValue(titleIndex, title);
  -        if (labelIndex > -1) newattr.setValue(labelIndex, label);
  -        super.startElement(uri, name, raw, newattr);
  -    }
  -
  -    public void linkTitle(String uri, String name, String raw, Attributes attr) 
throws SAXException {
  -        super.startElement(uri, name, raw, attr);
  -    }
  -
  -    public void endExtendedLink(String uri, String name, String raw) throws 
SAXException {
  -        super.endElement(uri, name, raw);
  +    public void simpleLink( String href, String role, String arcrole, String title, 
String show, String actuate, String uri, String name, String raw, Attributes attr ) 
throws SAXException
  +    {
  +        AttributesImpl newattr = new AttributesImpl( attr );
  +        int hrefIndex = attr.getIndex( XLINK_NAMESPACE_URI, XLINK_HREF );
  +        int roleIndex = attr.getIndex( XLINK_NAMESPACE_URI, XLINK_ROLE );
  +        int arcroleIndex = attr.getIndex( XLINK_NAMESPACE_URI, XLINK_ARCROLE );
  +        int titleIndex = attr.getIndex( XLINK_NAMESPACE_URI, XLINK_TITLE );
  +        int showIndex = attr.getIndex( XLINK_NAMESPACE_URI, XLINK_SHOW );
  +        int actuateIndex = attr.getIndex( XLINK_NAMESPACE_URI, XLINK_ACTUATE );
  +        if ( hrefIndex > -1 )
  +            newattr.setValue( hrefIndex, href );
  +        if ( roleIndex > -1 )
  +            newattr.setValue( roleIndex, role );
  +        if ( arcroleIndex > -1 )
  +            newattr.setValue( arcroleIndex, arcrole );
  +        if ( titleIndex > -1 )
  +            newattr.setValue( titleIndex, title );
  +        if ( showIndex > -1 )
  +            newattr.setValue( showIndex, show );
  +        if ( actuateIndex > -1 )
  +            newattr.setValue( actuateIndex, actuate );
  +        super.startElement( uri, name, raw, newattr );
  +    }
  +
  +    public void startExtendedLink( String role, String title, String uri, String 
name, String raw, Attributes attr ) throws SAXException
  +    {
  +        AttributesImpl newattr = new AttributesImpl( attr );
  +        int roleIndex = attr.getIndex( XLINK_NAMESPACE_URI, XLINK_ROLE );
  +        int titleIndex = attr.getIndex( XLINK_NAMESPACE_URI, XLINK_TITLE );
  +        if ( roleIndex > -1 )
  +            newattr.setValue( roleIndex, role );
  +        if ( titleIndex > -1 )
  +            newattr.setValue( titleIndex, title );
  +        super.startElement( uri, name, raw, newattr );
  +    }
  +
  +    public void startLocator( String href, String role, String title, String label, 
String uri, String name, String raw, Attributes attr ) throws SAXException
  +    {
  +        AttributesImpl newattr = new AttributesImpl( attr );
  +        int hrefIndex = attr.getIndex( XLINK_NAMESPACE_URI, XLINK_HREF );
  +        int roleIndex = attr.getIndex( XLINK_NAMESPACE_URI, XLINK_ROLE );
  +        int titleIndex = attr.getIndex( XLINK_NAMESPACE_URI, XLINK_TITLE );
  +        int labelIndex = attr.getIndex( XLINK_NAMESPACE_URI, XLINK_LABEL );
  +        if ( hrefIndex > -1 )
  +            newattr.setValue( hrefIndex, href );
  +        if ( roleIndex > -1 )
  +            newattr.setValue( roleIndex, role );
  +        if ( titleIndex > -1 )
  +            newattr.setValue( titleIndex, title );
  +        if ( labelIndex > -1 )
  +            newattr.setValue( labelIndex, label );
  +        super.startElement( uri, name, raw, newattr );
  +    }
  +
  +    public void startArc( String arcrole, String title, String show, String 
actuate, String from, String to, String uri, String name, String raw, Attributes attr 
) throws SAXException
  +    {
  +        AttributesImpl newattr = new AttributesImpl( attr );
  +        int arcroleIndex = attr.getIndex( XLINK_NAMESPACE_URI, XLINK_ARCROLE );
  +        int titleIndex = attr.getIndex( XLINK_NAMESPACE_URI, XLINK_TITLE );
  +        int showIndex = attr.getIndex( XLINK_NAMESPACE_URI, XLINK_SHOW );
  +        int actuateIndex = attr.getIndex( XLINK_NAMESPACE_URI, XLINK_ACTUATE );
  +        int fromIndex = attr.getIndex( XLINK_NAMESPACE_URI, XLINK_FROM );
  +        int toIndex = attr.getIndex( XLINK_NAMESPACE_URI, XLINK_TO );
  +        if ( arcroleIndex > -1 )
  +            newattr.setValue( arcroleIndex, arcrole );
  +        if ( titleIndex > -1 )
  +            newattr.setValue( titleIndex, title );
  +        if ( showIndex > -1 )
  +            newattr.setValue( showIndex, show );
  +        if ( actuateIndex > -1 )
  +            newattr.setValue( actuateIndex, actuate );
  +        if ( fromIndex > -1 )
  +            newattr.setValue( actuateIndex, from );
  +        if ( toIndex > -1 )
  +            newattr.setValue( actuateIndex, to );
  +        super.startElement( uri, name, raw, newattr );
  +    }
  +
  +    public void linkResource( String role, String title, String label, String uri, 
String name, String raw, Attributes attr ) throws SAXException
  +    {
  +        AttributesImpl newattr = new AttributesImpl( attr );
  +        int roleIndex = attr.getIndex( XLINK_NAMESPACE_URI, XLINK_ROLE );
  +        int titleIndex = attr.getIndex( XLINK_NAMESPACE_URI, XLINK_TITLE );
  +        int labelIndex = attr.getIndex( XLINK_NAMESPACE_URI, XLINK_LABEL );
  +        if ( roleIndex > -1 )
  +            newattr.setValue( roleIndex, role );
  +        if ( titleIndex > -1 )
  +            newattr.setValue( titleIndex, title );
  +        if ( labelIndex > -1 )
  +            newattr.setValue( labelIndex, label );
  +        super.startElement( uri, name, raw, newattr );
  +    }
  +
  +    public void linkTitle( String uri, String name, String raw, Attributes attr ) 
throws SAXException
  +    {
  +        super.startElement( uri, name, raw, attr );
  +    }
  +
  +    public void endExtendedLink( String uri, String name, String raw ) throws 
SAXException
  +    {
  +        super.endElement( uri, name, raw );
       }
   
  -    public void endLocator(String uri, String name, String raw) throws SAXException 
{
  -        super.endElement(uri, name, raw);
  +    public void endLocator( String uri, String name, String raw ) throws 
SAXException
  +    {
  +        super.endElement( uri, name, raw );
       }
   
  -    public void endArc(String uri, String name, String raw) throws SAXException {
  -        super.endElement(uri, name, raw);
  +    public void endArc( String uri, String name, String raw ) throws SAXException
  +    {
  +        super.endElement( uri, name, raw );
       }
   }
   
  
  
  

----------------------------------------------------------------------
In case of troubles, e-mail:     [EMAIL PROTECTED]
To unsubscribe, e-mail:          [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to