org.apache.xmlbeans.impl.jam.internal.JamServiceContextImpl Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of commons-xmlbeans Show documentation
Show all versions of commons-xmlbeans Show documentation
The Apache Commons Codec package contains simple encoder and decoders for
various formats such as Base64 and Hexadecimal. In addition to these
widely used encoders and decoders, the codec package also maintains a
collection of phonetic encoding utilities.
The newest version!
/* Copyright 2004 The Apache Software Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.xmlbeans.impl.jam.internal;
import org.apache.xmlbeans.impl.jam.JamClassLoader;
import org.apache.xmlbeans.impl.jam.JamServiceParams;
import org.apache.xmlbeans.impl.jam.annotation.AnnotationProxy;
import org.apache.xmlbeans.impl.jam.annotation.DefaultAnnotationProxy;
import org.apache.xmlbeans.impl.jam.annotation.JavadocTagParser;
import org.apache.xmlbeans.impl.jam.annotation.WhitespaceDelimitedTagParser;
import org.apache.xmlbeans.impl.jam.internal.elements.ElementContext;
import org.apache.xmlbeans.impl.jam.provider.CompositeJamClassBuilder;
import org.apache.xmlbeans.impl.jam.provider.JamClassBuilder;
import org.apache.xmlbeans.impl.jam.provider.JamLogger;
import org.apache.xmlbeans.impl.jam.provider.JamServiceContext;
import org.apache.xmlbeans.impl.jam.provider.ResourcePath;
import org.apache.xmlbeans.impl.jam.visitor.CompositeMVisitor;
import org.apache.xmlbeans.impl.jam.visitor.MVisitor;
import org.apache.xmlbeans.impl.jam.visitor.PropertyInitializer;
import java.io.File;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Properties;
import java.util.Set;
/**
* Takes settings from the user (through JamServiceParams) and exposes
* them to the implementation (through JamServiceContext).
*
* @author Patrick Calahan <email: pcal-at-bea-dot-com>
*/
public class JamServiceContextImpl extends JamLoggerImpl implements JamServiceContext,
JamServiceParams, ElementContext
{
// ========================================================================
// Constants
private static final char INNER_CLASS_SEPARATOR = '$';
// ========================================================================
// Variables
private boolean m14WarningsEnabled = false;
private Properties mProperties = null;
private Map mSourceRoot2Scanner = null;
private Map mClassRoot2Scanner = null;
private List mClasspath = null;
private List mSourcepath = null;
private List mToolClasspath = null;
private List mIncludeClasses = null;
private List mExcludeClasses = null;
private boolean mUseSystemClasspath = true;
private JavadocTagParser mTagParser = null;
private MVisitor mCommentInitializer = null;
private MVisitor mPropertyInitializer = new PropertyInitializer();
private List mOtherInitializers = null;
private List mUnstructuredSourceFiles = null;
private List mClassLoaders = null;
private List mBaseBuilders = null;
private JamClassLoader mLoader = null;
// ========================================================================
// REVIEW
public void setClassLoader(JamClassLoader loader) {
mLoader = loader;
}
public JamClassBuilder getBaseBuilder() {
if (mBaseBuilders == null || mBaseBuilders.size() == 0) {
return null;
}
if (mBaseBuilders.size() == 1) {
return (JamClassBuilder)mBaseBuilders.get(0);
}
JamClassBuilder[] comp = new JamClassBuilder[mBaseBuilders.size()];
mBaseBuilders.toArray(comp);
return new CompositeJamClassBuilder(comp);
}
public JavadocTagParser getTagParser() {
if (mTagParser == null) {
mTagParser = new WhitespaceDelimitedTagParser();
mTagParser.init(this);
}
return mTagParser;
}
// ========================================================================
// Constructors
public JamServiceContextImpl() {}
// ========================================================================
// Public methods - used by BaseJProvider
/**
* Returns an array containing the qualified names of the classes which
* are in the Service class set.
*/
public String[] getAllClassnames() throws IOException {
Set all = new HashSet();
if (mIncludeClasses != null) all.addAll(mIncludeClasses);
for(Iterator i = getAllDirectoryScanners(); i.hasNext(); ) {
DirectoryScanner ds = (DirectoryScanner)i.next();
String[] files = ds.getIncludedFiles();
for(int j=0; j