FileDocCategorySizeDatePackage
PersistenceContentHandler.javaAPI DocGlassfish v2 API8840Tue May 22 16:54:30 BST 2007oracle.toplink.essentials.internal.ejb.cmp3.xml.parser

PersistenceContentHandler

public class PersistenceContentHandler extends Object implements ContentHandler

Fields Summary
private static final String
NAMESPACE_URI
private static final String
ELEMENT_PERSISTENCE_UNIT
private static final String
ELEMENT_PROVIDER
private static final String
ELEMENT_JTA_DATA_SOURCE
private static final String
ELEMENT_NON_JTA_DATA_SOURCE
private static final String
ELEMENT_MAPPING_FILE
private static final String
ELEMENT_JAR_FILE
private static final String
ELEMENT_CLASS
private static final String
ELEMENT_EXCLUDE_UNLISTED_CLASSES
private static final String
ELEMENT_PROPERTY
private static final String
ATTRIBUTE_NAME
private static final String
ATTRIBUTE_VALUE
private static final String
ATTRIBUTE_TRANSACTION_TYPE
private SEPersistenceUnitInfo
persistenceUnitInfo
private Vector
persistenceUnits
private StringBuffer
stringBuffer
private boolean
readCharacters
Constructors Summary
public PersistenceContentHandler()


      
        super();
        stringBuffer = new StringBuffer();
        persistenceUnits = new Vector();
    
Methods Summary
public voidcharacters(char[] ch, int start, int length)

        if (readCharacters) {
            stringBuffer.append(ch, start, length);
        }
    
public voidendDocument()

    
public voidendElement(java.lang.String namespaceURI, java.lang.String localName, java.lang.String qName)

        String string = stringBuffer.toString().trim();
        stringBuffer.delete(0, stringBuffer.length());
        readCharacters = false;

        if (NAMESPACE_URI.equals(namespaceURI)) {
            if (ELEMENT_PROVIDER.equals(localName)) {
                persistenceUnitInfo.setPersistenceProviderClassName(string);
                return;
            } else if (ELEMENT_JTA_DATA_SOURCE.equals(localName)) {
                persistenceUnitInfo.setJtaDataSource(
                    // Create a dummy DataSource that will 
                    // throw an exception on access
                    new DataSourceImpl(string, null, null, null));
                return;
            } else if (ELEMENT_NON_JTA_DATA_SOURCE.equals(localName)) {
                persistenceUnitInfo.setNonJtaDataSource(
                    // Create a dummy DataSource that will 
                    // throw an exception on access
                    new DataSourceImpl(string, null, null, null));
                return;
            } else if (ELEMENT_MAPPING_FILE.equals(localName)) {
                persistenceUnitInfo.getMappingFileNames().add(string);
                return;
            } else if (ELEMENT_JAR_FILE.equals(localName)) {
                persistenceUnitInfo.getJarFiles().add(string);
                return;
            } else if (ELEMENT_CLASS.equals(localName)) {
                persistenceUnitInfo.getManagedClassNames().add(string);
                return;
            } else if (ELEMENT_EXCLUDE_UNLISTED_CLASSES.equals(localName)) {
                if (string.equals("true") || string.equals("1")){
                    persistenceUnitInfo.setExcludeUnlistedClasses(true);
                } else {
                    persistenceUnitInfo.setExcludeUnlistedClasses(false);
                }
                return;
            } else if (ELEMENT_PERSISTENCE_UNIT.equals(localName)) {
                if (persistenceUnitInfo != null){
                    persistenceUnits.add(persistenceUnitInfo);
                    persistenceUnitInfo = null;
                }
            } 
        }
    
public voidendPrefixMapping(java.lang.String prefix)

    
public java.util.VectorgetPersistenceUnits()

        return persistenceUnits;
    
public voidignorableWhitespace(char[] ch, int start, int length)

    
public voidprocessingInstruction(java.lang.String target, java.lang.String data)

    
public voidsetDocumentLocator(org.xml.sax.Locator locator)

    
public voidskippedEntity(java.lang.String name)

    
public voidstartDocument()

    
public voidstartElement(java.lang.String namespaceURI, java.lang.String localName, java.lang.String qName, org.xml.sax.Attributes atts)

        if (NAMESPACE_URI.equals(namespaceURI)) {
            if (ELEMENT_PERSISTENCE_UNIT.equals(localName)) {
                persistenceUnitInfo = new SEPersistenceUnitInfo();
                persistenceUnitInfo.setPersistenceUnitName(atts.getValue(ATTRIBUTE_NAME));
                String transactionType = atts.getValue(ATTRIBUTE_TRANSACTION_TYPE);
                if(transactionType != null) {
                    persistenceUnitInfo.setTransactionType(PersistenceUnitTransactionType.valueOf(transactionType));
                }
                return;
            } else if (ELEMENT_PROPERTY.equals(localName)) {
                String name = atts.getValue(ATTRIBUTE_NAME);
                String value = atts.getValue(ATTRIBUTE_VALUE);
                persistenceUnitInfo.getProperties().setProperty(name, value);
            } else if (ELEMENT_PROVIDER.equals(localName)) {
                readCharacters = true;
                return;
            } else if (ELEMENT_JTA_DATA_SOURCE.equals(localName)) {
                readCharacters = true;
                return;
            } else if (ELEMENT_NON_JTA_DATA_SOURCE.equals(localName)) {
                readCharacters = true;
                return;
            } else if (ELEMENT_MAPPING_FILE.equals(localName)) {
                readCharacters = true;
                return;
            } else if (ELEMENT_JAR_FILE.equals(localName)) {
                readCharacters = true;
                return;
            } else if (ELEMENT_EXCLUDE_UNLISTED_CLASSES.equals(localName)) {
                readCharacters = true;
                return;
            } else if (ELEMENT_CLASS.equals(localName)) {
                readCharacters = true;
                return;
            }
        }
    
public voidstartPrefixMapping(java.lang.String prefix, java.lang.String uri)