|
From: G?nther B. <br...@us...> - 2002-03-18 06:45:58
|
Update of /cvsroot/xpg-xml/edu/iicm/xpg/statemachine
In directory usw-pr-cvs1:/tmp/cvs-serv3862/statemachine
Modified Files:
DataObject.java XMLHandler.java
Added Files:
XMLElement.java
Log Message:
another example 2LATEX added
--- NEW FILE: XMLElement.java ---
/***********************************************************************
*
* Copyright (c) 2001 IICM, Graz University of Technology
* Schiesstattgasse 4a, A-8010 Graz, Austria.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License (LGPL)
* as published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY 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 along with this program; if not, write to the
* Free Software Foundation, Inc.,
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
***********************************************************************/
package edu.iicm.xpg.statemachine;
import org.xml.sax.Attributes;
import org.xml.sax.helpers.AttributesImpl;
import java.util.HashMap;
import java.util.Stack;
import java.util.EmptyStackException;
//----------------------------------------------------------------------
/**
* @author Günther Brand
* @version $revision$
*/
public class XMLElement
{
protected String name_;
protected String value_;
protected Attributes attributes_;
//----------------------------------------------------------------------
/**
* @param name the name that should be set
*/
protected void setName(String name)
{
if ( name != null)
name_ = name;
else ;
// FIXXME: send warning!
}
//----------------------------------------------------------------------
/**
* @return the name
*/
public String getName()
{
return name_;
}
//----------------------------------------------------------------------
/**
* @param value the value that should be set
*/
protected void setValue(String value)
{
value_ = value;
}
//----------------------------------------------------------------------
/**
* @return the value
*/
public String getValue()
{
return value_;
}
//----------------------------------------------------------------------
/**
* @param attributes the attributes that should be set
*/
protected void setAttributes(Attributes attributes)
{
attributes_ = new AttributesImpl(attributes);
}
//----------------------------------------------------------------------
/**
* @return the attributes
*/
public Attributes getAttributes()
{
return attributes_;
}
}
Index: DataObject.java
===================================================================
RCS file: /cvsroot/xpg-xml/edu/iicm/xpg/statemachine/DataObject.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** DataObject.java 28 Feb 2002 06:40:19 -0000 1.4
--- DataObject.java 18 Mar 2002 06:45:54 -0000 1.5
***************
*** 37,48 ****
public class DataObject
{
! private Stack element_stack_;
!
! private HashMap data_map_;
public DataObject()
{
element_stack_ = new Stack();
! data_map_= new HashMap();
}
--- 37,47 ----
public class DataObject
{
! protected Stack element_stack_;
! protected HashMap data_map_;
public DataObject()
{
element_stack_ = new Stack();
! data_map_ = new HashMap();
}
***************
*** 51,55 ****
* @param element_object the elementobject that should be pushed on the stack
*/
! protected void pushElementObject(ElementObject element_object)
{
element_stack_.push(element_object);
--- 50,54 ----
* @param element_object the elementobject that should be pushed on the stack
*/
! protected void pushXMLElement(XMLElement element_object)
{
element_stack_.push(element_object);
***************
*** 60,68 ****
* @return the top element object
*/
! public ElementObject topElementObject()
{
try
{
! return (ElementObject)element_stack_.peek();
}
catch (EmptyStackException exc)
--- 59,67 ----
* @return the top element object
*/
! public XMLElement topXMLElement()
{
try
{
! return (XMLElement)element_stack_.peek();
}
catch (EmptyStackException exc)
***************
*** 78,86 ****
* @return the top element object and removes it
*/
! protected ElementObject popElementObject()
{
try
{
! return (ElementObject)element_stack_.pop();
}
catch (EmptyStackException exc)
--- 77,85 ----
* @return the top element object and removes it
*/
! protected XMLElement popXMLElement()
{
try
{
! return (XMLElement)element_stack_.pop();
}
catch (EmptyStackException exc)
Index: XMLHandler.java
===================================================================
RCS file: /cvsroot/xpg-xml/edu/iicm/xpg/statemachine/XMLHandler.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** XMLHandler.java 8 Mar 2002 19:04:38 -0000 1.4
--- XMLHandler.java 18 Mar 2002 06:45:54 -0000 1.5
***************
*** 104,108 ****
try
{
! data_.topElementObject().setElementValue(new String(chars, start, length));
state_machine_.input(new XMLInput(Const.XML_CHARS,chars,start,length));
}
--- 104,108 ----
try
{
! data_.topXMLElement().setValue(new String(chars, start, length));
state_machine_.input(new XMLInput(Const.XML_CHARS,chars,start,length));
}
***************
*** 128,135 ****
try
{
! ElementObject element_object = new ElementObject();
! element_object.setElementName(name);
element_object.setAttributes(attributes);
! data_.pushElementObject(element_object);
state_machine_.input(new XMLInput(Const.XML_START_TAG,name));
--- 128,135 ----
try
{
! XMLElement element_object = new XMLElement();
! element_object.setName(name);
element_object.setAttributes(attributes);
! data_.pushXMLElement(element_object);
state_machine_.input(new XMLInput(Const.XML_START_TAG,name));
***************
*** 155,159 ****
{
state_machine_.input(new XMLInput(Const.XML_END_TAG,name));
! data_.popElementObject();
}
catch(Exception exc)
--- 155,159 ----
{
state_machine_.input(new XMLInput(Const.XML_END_TAG,name));
! data_.popXMLElement();
}
catch(Exception exc)
|