Android Open Source - android-core Siminov S A X Default Handler






From Project

Back to project page android-core.

License

The source code is released under:

Apache License

If you think the Android project android-core listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

/** 
 * [SIMINOV FRAMEWORK]/*from w w w.j  av a 2 s.  co  m*/
 * Copyright [2015] [Siminov Software Solution LLP|support@siminov.com]
 *
 * 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 siminov.core.reader;

import java.io.IOException;
import java.io.InputStream;

import javax.xml.parsers.FactoryConfigurationError;
import javax.xml.parsers.ParserConfigurationException;
import javax.xml.parsers.SAXParser;
import javax.xml.parsers.SAXParserFactory;

import org.xml.sax.SAXException;
import org.xml.sax.helpers.DefaultHandler;

import siminov.core.exception.PrematureEndOfParseException;
import siminov.core.exception.SiminovException;
import siminov.core.log.Log;


/**
 * Exposes common methods which are required by every SIMINOV parsers. 
 */
public class SiminovSAXDefaultHandler extends DefaultHandler {

  /**
   * Call this method to parse input stream.
   * @param inputStream Input Stream.
   * @throws SiminovException If any exception occur while parsing input stream.
   */
  public void parseMessage(final InputStream inputStream) throws SiminovException {
    if(inputStream == null) {
      Log.error(getClass().getName(), "parseMessage", "Invalid InputStream Found.");
      throw new SiminovException(getClass().getName(), "parseMessage", "Invalid InputStream Found.");
    }
    
    SAXParserFactory saxParserFactory = null;
    
    try {
      saxParserFactory = SAXParserFactory.newInstance();      
    } catch(FactoryConfigurationError factoryConfigurationError) {
      Log.debug(getClass().getName(), "parseMessage", "FactoryConfigurationError caught while creating new instance of sax parser factory.");
      throw new SiminovException(getClass().getName(), "parseMessage", "FactoryConfigurationError caught while creating new instance of sax parser factory, " + factoryConfigurationError.getMessage());
    }

    SAXParser saxParser = null;
    
    try {
      saxParser = saxParserFactory.newSAXParser();
    } catch(ParserConfigurationException parserConfigurationException) {
      Log.error(getClass().getName(), "parseMessage", "ParserConfigurationException caught while creating new instance of sax parser.");
      throw new SiminovException(getClass().getName(), "parseMessage", "ParserConfigurationException caught while creating new instance of sax parser, " + parserConfigurationException.getMessage());
    } catch(SAXException saxException) {
      Log.error(getClass().getName(), "parseMessage", "SAXException caught while creating new instance of sax parser.");
      throw new SiminovException(getClass().getName(), "parseMessage", "SAXException caught while creating new instance of sax parser, " + saxException.getMessage());
    }
    
    try {
      saxParser.parse(inputStream, this);      
    } catch(IllegalArgumentException illegalArgumentException) {
      Log.error(getClass().getName(), "parserMessage", "IllegalArgumentException caught while parsing input stream, " + illegalArgumentException.getMessage());
      throw new SiminovException(getClass().getName(), "parseMessage", "IllegalArgumentException caught while parsing input stream, " + illegalArgumentException.getMessage());
    } catch(IOException ioException) {
      Log.error(getClass().getName(), "parserMessage", "IOException caught while parsing input stream, " + ioException.getMessage());
      throw new SiminovException(getClass().getName(), "parseMessage", "IOException caught while parsing input stream, " + ioException.getMessage());
    } catch(PrematureEndOfParseException prematureEndOfParseException) {
      Log.important(getClass().getName(), "parserMessage", "PrematureEndOfParseException caught while parsing input stream, " + prematureEndOfParseException.getMessage());
    } catch(SAXException saxException) {
      Log.error(getClass().getName(), "parserMessage", "SAXException caught while parsing input stream, " + saxException.getMessage());
      throw new SiminovException(getClass().getName(), "parserMessage", "SAXException caught while parsing input stream, " + saxException.getMessage());
    } catch(Exception exception) {
      Log.error(getClass().getName(), "parserMessage", "Exception caught while parsing input stream, " + exception.getMessage());
      throw new SiminovException(getClass().getName(), "parserMessage", "Exception caught while parsing input stream, " + exception.getMessage());
    }
  }

}




Java Source Code List

siminov.core.Constants.java
siminov.core.IInitializer.java
siminov.core.Initializer.java
siminov.core.Siminov.java
siminov.core.database.Clause.java
siminov.core.database.DatabaseBundle.java
siminov.core.database.DatabaseFactory.java
siminov.core.database.DatabaseHelper.java
siminov.core.database.DatabaseUtils.java
siminov.core.database.Database.java
siminov.core.database.Where.java
siminov.core.database.design.IAverageClause.java
siminov.core.database.design.IAverage.java
siminov.core.database.design.ICountClause.java
siminov.core.database.design.ICount.java
siminov.core.database.design.IDataTypeHandler.java
siminov.core.database.design.IDatabaseImpl.java
siminov.core.database.design.IDatabase.java
siminov.core.database.design.IDeleteClause.java
siminov.core.database.design.IDelete.java
siminov.core.database.design.IGroupConcatClause.java
siminov.core.database.design.IGroupConcat.java
siminov.core.database.design.IMaxClause.java
siminov.core.database.design.IMax.java
siminov.core.database.design.IMinClause.java
siminov.core.database.design.IMin.java
siminov.core.database.design.IQueryBuilder.java
siminov.core.database.design.ISelectClause.java
siminov.core.database.design.ISelect.java
siminov.core.database.design.ISumClause.java
siminov.core.database.design.ISum.java
siminov.core.database.design.ITotalClause.java
siminov.core.database.design.ITotal.java
siminov.core.database.sqlite.DataTypeHandler.java
siminov.core.database.sqlite.DatabaseImpl.java
siminov.core.database.sqlite.QueryBuilder.java
siminov.core.events.EventHandler.java
siminov.core.events.IDatabaseEvents.java
siminov.core.events.ISiminovEvents.java
siminov.core.exception.DatabaseException.java
siminov.core.exception.DeploymentException.java
siminov.core.exception.IException.java
siminov.core.exception.PrematureEndOfParseException.java
siminov.core.exception.SiminovCriticalException.java
siminov.core.exception.SiminovException.java
siminov.core.log.Log.java
siminov.core.model.ApplicationDescriptor.java
siminov.core.model.DatabaseDescriptor.java
siminov.core.model.DatabaseMappingDescriptor.java
siminov.core.model.IDescriptor.java
siminov.core.model.LibraryDescriptor.java
siminov.core.reader.ApplicationDescriptorReader.java
siminov.core.reader.DatabaseDescriptorReader.java
siminov.core.reader.DatabaseMappingDescriptorReader.java
siminov.core.reader.LibraryDescriptorReader.java
siminov.core.reader.QuickDatabaseMappingDescriptorReader.java
siminov.core.reader.SiminovSAXDefaultHandler.java
siminov.core.resource.ResourceManager.java
siminov.core.utils.ClassUtils.java
siminov.core.utils.EmptyIterator.java
siminov.core.utils.Utils.java