Top Description Inners Fields Constructors Methods
com.sun.tools.jxc

public final Class ConfigReader

extends Object
Class Inheritance
Imports
java.io.File, .IOException, java.util.Collection, .HashMap, .HashSet, .List, .Map, .Set, java.util.regex.Matcher, .Pattern, javax.annotation.processing.ProcessingEnvironment, javax.lang.model.element.TypeElement, javax.xml.parsers.ParserConfigurationException, .SAXParserFactory, javax.xml.transform.Result, javax.xml.transform.stream.StreamResult, javax.xml.validation.ValidatorHandler, jakarta.xml.bind.SchemaOutputResolver, org.glassfish.jaxb.core.v2.util.XmlFactory, com.sun.tools.jxc.ap.Options, com.sun.tools.jxc.api.Reference, com.sun.tools.jxc.gen.config.Config, .Schema, com.sun.tools.xjc.SchemaCache, com.sun.tools.xjc.util.ForkContentHandler, org.xml.sax.ErrorHandler, .InputSource, .SAXException, .XMLReader

This reads the config files passed by the user to annotation processing and obtains a list of classes that need to be included for a particular config from the set of classes passed by the user to annotation processing.
Author
Bhakti Mehta ([email protected])

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class
ConfigReader.SchemaOutputResolverImpl

Controls where the JAXB RI puts the generates schema files.

Field Summary

Modifier and TypeField and Description
private final Set<Reference>
classesToBeIncluded

The set of classes to be passed to XJC

private static SchemaCache
configSchema

Lazily parsed schema for the binding file.

private final ProcessingEnvironment
private final SchemaOutputResolver
schemaOutputResolver

The SchemaOutputResolver used to generate the schemas

Constructor Summary

AccessConstructor and Description
public
ConfigReader(ProcessingEnvironment
The ProcessingEnvironment
env
,
Collection<? extends TypeElement>
The set of classes passed to the AnnotationProcessor
classes
,
File
The configuration file.
xmlFile
,
ErrorHandler
The error handler
errorHandler
)

Method Summary

Modifier and TypeMethod and Description
private void
checkAllClasses(Config config, Collection<? extends TypeElement> rootClasses)

This creates a regular expression for the user pattern , matches the input classes passed by the user and returns the final list of classes that need to be included for a config file after applying those patterns

private boolean
checkPatternMatch(String
The qualified name of the TypeDeclaration
qualifiedName
,
Pattern
The pattern obtained from the users input
pattern
)

This will check if the qualified name matches the pattern

private SchemaOutputResolver
public Collection<Reference>

Returns:

to be included classes.
getClassesToBeIncluded
()

Return collection of classes to be included based on the configuration.

public SchemaOutputResolver

Returns:

schema output resolver
getSchemaOutputResolver
()

This returns the SchemaOutputResolver to generate the schemas

private Config

Returns:

A non null Config object
parseAndGetConfig
(File
The xml config file which is passed by the user to annotation processing
xmlFile
,
ErrorHandler errorHandler, boolean disableSecureProcessing)

Parses an xml config file and returns a Config object.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

classesToBeIncludedback to summary
private final Set<Reference> classesToBeIncluded

The set of classes to be passed to XJC

configSchemaback to summary
private static SchemaCache configSchema

Lazily parsed schema for the binding file.

envback to summary
private final ProcessingEnvironment env
schemaOutputResolverback to summary
private final SchemaOutputResolver schemaOutputResolver

The SchemaOutputResolver used to generate the schemas

Constructor Detail

ConfigReaderback to summary
public ConfigReader(ProcessingEnvironment env, Collection<? extends TypeElement> classes, File xmlFile, ErrorHandler errorHandler) throws SAXException, IOException
Parameters
env:ProcessingEnvironment

The ProcessingEnvironment

classes:Collection<? extends TypeElement>

The set of classes passed to the AnnotationProcessor

xmlFile:File

The configuration file.

errorHandler:ErrorHandler

The error handler

Exceptions
SAXException:
If this is thrown, the error has already been reported.
IOException:
If any IO errors occur.

Method Detail

checkAllClassesback to summary
private void checkAllClasses(Config config, Collection<? extends TypeElement> rootClasses)

This creates a regular expression for the user pattern , matches the input classes passed by the user and returns the final list of classes that need to be included for a config file after applying those patterns

checkPatternMatchback to summary
private boolean checkPatternMatch(String qualifiedName, Pattern pattern)

This will check if the qualified name matches the pattern

Parameters
qualifiedName:String

The qualified name of the TypeDeclaration

pattern:Pattern

The pattern obtained from the users input

createSchemaOutputResolverback to summary
private SchemaOutputResolver createSchemaOutputResolver(Config config, String xmlpath)
getClassesToBeIncludedback to summary
public Collection<Reference> getClassesToBeIncluded()

Return collection of classes to be included based on the configuration.

Returns:Collection<Reference>

to be included classes.

getSchemaOutputResolverback to summary
public SchemaOutputResolver getSchemaOutputResolver()

This returns the SchemaOutputResolver to generate the schemas

Returns:SchemaOutputResolver

schema output resolver

parseAndGetConfigback to summary
private Config parseAndGetConfig(File xmlFile, ErrorHandler errorHandler, boolean disableSecureProcessing) throws SAXException, IOException

Parses an xml config file and returns a Config object.

Parameters
xmlFile:File

The xml config file which is passed by the user to annotation processing

Returns:Config

A non null Config object

com.sun.tools.jxc back to summary

private final Class ConfigReader.SchemaOutputResolverImpl

extends SchemaOutputResolver
Class Inheritance

Controls where the JAXB RI puts the generates schema files.
Author
Bhakti Mehta ([email protected])

Field Summary

Modifier and TypeField and Description
private final File
baseDir

Directory to which we put the rest of the files.

private final Map<String, File>
schemas

Namespace URI to the location of the schema.

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public void
addSchemaInfo(String namespaceUri, File location)

public Result
createOutput(String namespaceUri, String suggestedFileName)

Implements abstract jakarta.xml.bind.SchemaOutputResolver.createOutput.

Decides where the schema file (of the given namespace URI) will be written, and return it as a Result object.

Field Detail

baseDirback to summary
private final File baseDir

Directory to which we put the rest of the files. Never be null.

schemasback to summary
private final Map<String, File> schemas

Namespace URI to the location of the schema. This captures what the user specifies.

Constructor Detail

SchemaOutputResolverImplback to summary
public SchemaOutputResolverImpl(File baseDir)

Method Detail

addSchemaInfoback to summary
public void addSchemaInfo(String namespaceUri, File location)
createOutputback to summary
public Result createOutput(String namespaceUri, String suggestedFileName)

Implements abstract jakarta.xml.bind.SchemaOutputResolver.createOutput.

Decides where the schema file (of the given namespace URI) will be written, and return it as a Result object.

Annotations
@Override