Skip to content

Commit

Permalink
Merge pull request #196 from volosied/195-tlddoc
Browse files Browse the repository at this point in the history
Port TLDDoc Source Code
  • Loading branch information
volosied authored Feb 3, 2022
2 parents c96cb46 + 53bac9f commit 3336fc8
Show file tree
Hide file tree
Showing 43 changed files with 10,133 additions and 3 deletions.
6 changes: 3 additions & 3 deletions impl/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -459,9 +459,9 @@ Copyright © 2019, ${current.year} Eclipse Foundation. All rights reserved.
</executions>
<dependencies>
<dependency>
<groupId>taglibrarydoc</groupId>
<artifactId>tlddoc</artifactId>
<version>1.3</version>
<groupId>org.glassfish.web</groupId>
<artifactId>tagsdoc</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
</dependencies>
</plugin>
Expand Down
1 change: 1 addition & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@
</mailingLists>

<modules>
<module>tagsdoc</module>
<module>api</module>
<module>impl</module>
<module>spec</module>
Expand Down
41 changes: 41 additions & 0 deletions tagsdoc/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.glassfish.web</groupId>
<artifactId>tagsdoc</artifactId>
<version>1.0-SNAPSHOT</version>
<licenses>
<license>
<name>New BSD License</name>
<url>http://opensource.org/licenses/BSD-3-Clause</url>
</license>
</licenses>

<description>
Jakarta Tags EE10+ Specific Tag Library Documentation Generator. This was branched off TLDDoc, version 1.3.
</description>


<build>
<plugins>
<!-- Uncomment if this component should NOT be published -->
<!-- <plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-deploy-plugin</artifactId>
<version>3.0.0-M2</version>
<configuration>
<skip>true</skip>
</configuration>
</plugin> -->
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<release>11</release>
<compilerArgument>-Xlint:unchecked</compilerArgument>
</configuration>
</plugin>
</plugins>
</build>

</project>
61 changes: 61 additions & 0 deletions tagsdoc/src/main/java/com/sun/tlddoc/Constants.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
/*
* <license>
* Copyright (c) 2003-2004, Sun Microsystems, Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of Sun Microsystems, Inc. nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* ROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
* </license>
*/

package com.sun.tlddoc;

/**
* Various constants used by TLDDoc
*
* @author mroth
*/
public final class Constants {

/** Private constructor as this is a utility class. */
private Constants() {
}

public static final String VERSION = "1.3";

public static final String DEFAULT_WINDOW_TITLE =
"Tag Library Documentation Generator - Generated Documentation";

public static final String DEFAULT_DOC_TITLE =
"Tag Library Documentation Generator - Generated Documentation";

/** Namespace for Java EE */
public static final String NS_JAVAEE = "http://java.sun.com/xml/ns/javaee";

/** Namespace for J2EE */
public static final String NS_J2EE = "http://java.sun.com/xml/ns/j2ee";

/** If true, outputs the input to the transform before generation */
public static final boolean DEBUG_INPUT_DOCUMENT = false;
}
58 changes: 58 additions & 0 deletions tagsdoc/src/main/java/com/sun/tlddoc/GeneratorException.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
/*
* <license>
* Copyright (c) 2003-2004, Sun Microsystems, Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of Sun Microsystems, Inc. nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* ROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
* </license>
*/

package com.sun.tlddoc;

/**
*
* @author mroth
*/
public class GeneratorException extends java.lang.Exception {

/**
* Creates a new instance of <code>GeneratorException</code> without detail message.
*/
public GeneratorException() {
}


/**
* Constructs an instance of <code>GeneratorException</code> with the specified detail message.
* @param msg the detail message.
*/
public GeneratorException(String msg) {
super(msg);
}

public GeneratorException( Throwable cause ) {
super( cause );
}
}
123 changes: 123 additions & 0 deletions tagsdoc/src/main/java/com/sun/tlddoc/JARTLDFileTagLibrary.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
/*
* <license>
* Copyright (c) 2003-2004, Sun Microsystems, Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of Sun Microsystems, Inc. nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* ROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
* </license>
*/

package com.sun.tlddoc;

import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.jar.JarEntry;
import java.util.jar.JarFile;
import java.util.jar.JarInputStream;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.ParserConfigurationException;
import javax.xml.transform.TransformerConfigurationException;
import javax.xml.transform.TransformerException;
import org.w3c.dom.Document;
import org.xml.sax.InputSource;
import org.xml.sax.SAXException;

/**
* Tag library that gets its information from a TLD file in a JAR.
*
* @author mroth
*/
public class JARTLDFileTagLibrary extends TagLibrary {

/** The JAR containing the TLD file */
private File jar;

/** The name of the JarEntry containing the TLD file */
private String tldPath;

/** Creates a new instance of JARTLDFileTagLibrary */
public JARTLDFileTagLibrary( File jar, String tldPath ) {
this.jar = jar;
this.tldPath = tldPath;
}

/**
* Returns a String that the user would recognize as a location for this
* tag library.
*/
public String getPathDescription() {
return jar.getAbsolutePath() + "!" + tldPath;
}

/**
* Returns an input stream for the given resource, or null if the
* resource could not be found.
*/
public InputStream getResource(String path)
throws IOException
{
InputStream result = null;
if( path.startsWith( "/" ) ) path = path.substring( 1 );
JarFile jarFile = new JarFile( this.jar );
JarEntry jarEntry = jarFile.getJarEntry( path );
if( jarEntry != null ) {
result = jarFile.getInputStream( jarEntry );
}

// XXX - JAR File is left unclosed.

return result;
}

/**
* Returns a Document of the effective tag library descriptor for this
* tag library. This might come from a file or be implicitly generated.
*/
public Document getTLDDocument(DocumentBuilder documentBuilder)
throws IOException, SAXException, ParserConfigurationException,
TransformerConfigurationException, TransformerException,
GeneratorException
{
Document result = null;
JarFile jarFile = new JarFile( this.jar );
JarEntry jarEntry = jarFile.getJarEntry( this.tldPath );
if( jarEntry != null ) {
InputStream in = jarFile.getInputStream( jarEntry );
InputSource source;
try {
source = new InputSource( in );
result = documentBuilder.parse( source );
}
finally {
in.close();
}
}
jarFile.close();
return result;
}

}
Loading

0 comments on commit 3336fc8

Please sign in to comment.