All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.jboss.maven.plugins.jdocbook.revdiff.BaselineHandler Maven / Gradle / Ivy

/*
 * Copyright © 2007  Red Hat Middleware, LLC. All rights reserved.
 *
 * This copyrighted material is made available to anyone wishing to use, modify,
 * copy, or redistribute it subject to the terms and conditions of the GNU
 * Lesser General Public License, v. 2.1. This program is distributed in the
 * hope that it will be useful, but WITHOUT A WARRANTY; without even the implied
 * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 * Lesser General Public License for more details. You should have received a
 * copy of the GNU Lesser General Public License, v.2.1 along with this
 * distribution; if not, write to the Free Software Foundation, Inc.,
 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
 *
 * Red Hat Author(s): Christian Bauer, Steve Ebersole
 */
package org.jboss.maven.plugins.jdocbook.revdiff;

import java.util.Map;

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

/**
 * An XML parse handler used to create a catalog of baseline elements.
 * 

* Typically this would be used against the master translation to create * a baseline against which particular translations would be checked. * * @author Christian Bauer * @author Steve Ebersole */ public class BaselineHandler extends DefaultHandler { private final Map catalog; private Locator docLocator; public void setDocumentLocator(Locator locator) { this.docLocator = locator; } public BaselineHandler(Map catalog) { this.catalog = catalog; } public void startElement( String namespaceURI, String localName, String qualifiedName, Attributes atts) throws SAXException { // Only add ModuleElements that have an identifier String identifier = atts.getValue( "id" ); if ( identifier != null ) { // The default revision is 0 int revision = 0; if ( atts.getValue( "revision" ) != null ) { revision = Integer.parseInt( atts.getValue( "revision" ) ); } // Generate new ContentItem and new original state ContentItem contentItem = new ContentItem( identifier ); ContentItemDescriptor descriptor = new ContentItemDescriptor( docLocator.getSystemId(), qualifiedName, revision, docLocator.getLineNumber(), docLocator.getColumnNumber() ); contentItem.setMasterDescriptor( descriptor ); catalog.put( identifier, contentItem ); } } }





© 2015 - 2025 Weber Informatics LLC | Privacy Policy