es.ucm.fdi.hysteria.game.parser
Class XMLParser

java.lang.Object
  extended by org.xml.sax.helpers.DefaultHandler
      extended by es.ucm.fdi.hysteria.game.parser.XMLParser
All Implemented Interfaces:
org.xml.sax.ContentHandler, org.xml.sax.DTDHandler, org.xml.sax.EntityResolver, org.xml.sax.ErrorHandler

public class XMLParser
extends org.xml.sax.helpers.DefaultHandler


Field Summary
protected  java.lang.String _actualId
           
protected  java.util.Hashtable<java.lang.String,java.util.Hashtable<java.lang.String,java.lang.String>> _allExits
           
protected  java.util.Hashtable<java.lang.String,Item> _allItems
           
protected  java.util.Hashtable<java.lang.String,Location> _allLocs
           
protected  java.util.Hashtable<java.lang.String,Obstacle> _allObstacles
           
protected  java.util.Hashtable<java.lang.String,java.util.Hashtable<java.lang.String,java.util.LinkedHashSet<java.lang.String>>> _allReactionsDisables
           
protected  java.util.Hashtable<java.lang.String,java.util.Hashtable<java.lang.String,java.util.LinkedHashSet<java.lang.String>>> _allReactionsEnables
           
protected  java.util.Hashtable<java.lang.String,java.util.Hashtable<java.lang.String,java.lang.String>> _allReactionsExtinguish
           
protected  java.util.Hashtable<java.lang.String,java.util.LinkedHashSet<java.lang.String>> _allReactionsItems
           
protected  java.util.Hashtable<java.lang.String,java.util.Hashtable<java.lang.String,java.lang.String>> _allReactionsMessages
           
protected  java.util.Hashtable<java.lang.String,java.util.LinkedHashSet<java.lang.String>> _allRelated
           
protected  java.util.Hashtable<java.lang.String,Scene> _allScenes
           
protected  java.util.Hashtable<java.lang.String,Topic> _allTopics
           
protected  int _amount
           
protected  boolean _atLeastOne
           
protected  java.lang.String _author
           
protected  java.lang.String _auxDesc
           
protected  java.lang.String _auxName
           
protected  boolean _bconnection
           
protected  boolean _bdescription
           
protected  boolean _bego
           
protected  boolean _bexitmessage
           
protected  boolean _bgame
           
protected  boolean _bitem
           
protected  boolean _blocation
           
protected  boolean _blocinfo
           
protected  boolean _bmusic
           
protected  boolean _bobstacle
           
protected  boolean _breaction
           
protected  boolean _bscene
           
protected  boolean _bthreshold
           
protected  boolean _btopic
           
protected  java.util.LinkedList<java.lang.Boolean> _bused
           
protected  java.util.LinkedList<java.lang.Boolean> _busedWith
           
protected  Location _currentLocation
           
protected  Scene _currentScene
           
protected  Topic _currentTopic
           
protected  java.lang.String _desc
           
protected  java.lang.String _exitMessage
           
protected  java.util.LinkedList<java.lang.Boolean> _extinguishWhenUsed
           
protected  java.util.LinkedList<java.lang.Boolean> _extinguishWhenUsedWith
           
protected  java.lang.String _gamePath
           
protected  java.lang.String _id
           
protected  java.lang.String _image
           
protected  java.io.InputStream _in
           
protected  java.lang.String _initialId
           
protected  ItemRepository _initialInventory
           
protected  Location _initialLocation
           
protected  java.lang.String _intro
           
protected  java.util.LinkedList<java.lang.String> _itemIdQueue
           
protected  java.util.LinkedList<java.lang.String> _itemIdUseWithQueue
           
protected  java.util.LinkedList<Item> _itemQueue
           
protected  java.util.LinkedList<UsedWithInfo> _itemUses
           
protected  Game.Direction _lastDir
           
protected  int _lightLevel
           
protected  boolean _lightsOn
           
protected  java.util.Hashtable<java.lang.String,java.lang.String> _locationItemRel
           
protected  java.lang.String _name
           
protected  boolean _obstacleActive
           
protected  java.util.Hashtable<java.lang.String,java.util.LinkedHashSet<java.lang.String>> _obstacleItemRel
           
protected  boolean _parsed
           
protected  java.lang.String _reactionExtinguish
           
protected  java.lang.String _reactionId
           
protected  java.util.Hashtable<java.lang.String,java.util.LinkedHashSet<java.lang.String>> _relativeScenesDisable
           
protected  java.util.Hashtable<java.lang.String,java.util.LinkedHashSet<java.lang.String>> _relativeScenesEnable
           
protected  java.util.Hashtable<java.lang.String,java.util.LinkedHashSet<java.lang.String>> _relativeTopicsDisable
           
protected  java.util.Hashtable<java.lang.String,java.util.LinkedHashSet<java.lang.String>> _relativeTopicsEnable
           
protected  boolean _sceneActive
           
protected  java.lang.String _sceneId
           
protected  java.lang.String _sceneImage
           
protected  java.lang.String _target
           
protected  int _threshold
           
protected  java.lang.String _title
           
protected  boolean _topicActive
           
protected  boolean _topicIsFinal
           
protected  int _totalLocations
           
protected  boolean _unassignedInitialLocation
           
protected  int _value
           
protected  float _weight
           
protected  java.lang.StringBuffer buffer
           
protected  java.lang.String desc
           
protected  java.lang.String exit
           
protected  java.lang.String id
           
protected  java.lang.String name
           
protected  java.io.StreamTokenizer st
           
protected  java.lang.String topicId
           
 
Constructor Summary
XMLParser(java.lang.String path)
           
 
Method Summary
 void characters(char[] ch, int start, int length)
           
 void endDocument()
           
 void endElement(java.lang.String uri, java.lang.String name, java.lang.String qName)
           
 java.lang.String getAuthor()
          Returns the game author
 java.lang.String getDesc()
          Returns the game description
 ItemRepository getInitialInventory()
          Returns the initial inventory
 Location getInitialLocation()
          Returns the initial location
 java.lang.String getTitle()
          Returns the game title
 int getTotalLocations()
           
 void parse(java.io.InputStream in)
          Asks for a SAXParser, and parses the file denoted by the input stream
 boolean parsed()
          Was the game successfully parsed?
 void startElement(java.lang.String uri, java.lang.String name, java.lang.String qName, org.xml.sax.Attributes atrs)
           
 
Methods inherited from class org.xml.sax.helpers.DefaultHandler
endPrefixMapping, error, fatalError, ignorableWhitespace, notationDecl, processingInstruction, resolveEntity, setDocumentLocator, skippedEntity, startDocument, startPrefixMapping, unparsedEntityDecl, warning
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_bego

protected boolean _bego

_bgame

protected boolean _bgame

_blocation

protected boolean _blocation

_bitem

protected boolean _bitem

_bobstacle

protected boolean _bobstacle

_bconnection

protected boolean _bconnection

_bdescription

protected boolean _bdescription

_bmusic

protected boolean _bmusic

_blocinfo

protected boolean _blocinfo

_bthreshold

protected boolean _bthreshold

_bexitmessage

protected boolean _bexitmessage

_bscene

protected boolean _bscene

_btopic

protected boolean _btopic

_breaction

protected boolean _breaction

_parsed

protected boolean _parsed

id

protected java.lang.String id

name

protected java.lang.String name

desc

protected java.lang.String desc

exit

protected java.lang.String exit

_sceneId

protected java.lang.String _sceneId

topicId

protected java.lang.String topicId

_sceneImage

protected java.lang.String _sceneImage

_reactionExtinguish

protected java.lang.String _reactionExtinguish

buffer

protected java.lang.StringBuffer buffer

_in

protected java.io.InputStream _in

_lastDir

protected Game.Direction _lastDir

_unassignedInitialLocation

protected boolean _unassignedInitialLocation

_atLeastOne

protected boolean _atLeastOne

_obstacleActive

protected boolean _obstacleActive

_sceneActive

protected boolean _sceneActive

_topicActive

protected boolean _topicActive

_topicIsFinal

protected boolean _topicIsFinal

_lightsOn

protected boolean _lightsOn

_initialLocation

protected Location _initialLocation

_currentLocation

protected Location _currentLocation

_currentScene

protected Scene _currentScene

_currentTopic

protected Topic _currentTopic

_initialId

protected java.lang.String _initialId

_actualId

protected java.lang.String _actualId

_name

protected java.lang.String _name

_author

protected java.lang.String _author

_desc

protected java.lang.String _desc

_id

protected java.lang.String _id

_target

protected java.lang.String _target

_image

protected java.lang.String _image

_intro

protected java.lang.String _intro

_auxName

protected java.lang.String _auxName

_auxDesc

protected java.lang.String _auxDesc

_exitMessage

protected java.lang.String _exitMessage

_title

protected java.lang.String _title

_reactionId

protected java.lang.String _reactionId

_value

protected int _value

_threshold

protected int _threshold

_amount

protected int _amount

_totalLocations

protected int _totalLocations

_lightLevel

protected int _lightLevel

_weight

protected float _weight

_allLocs

protected java.util.Hashtable<java.lang.String,Location> _allLocs

_allExits

protected java.util.Hashtable<java.lang.String,java.util.Hashtable<java.lang.String,java.lang.String>> _allExits

_allReactionsMessages

protected java.util.Hashtable<java.lang.String,java.util.Hashtable<java.lang.String,java.lang.String>> _allReactionsMessages

_allReactionsExtinguish

protected java.util.Hashtable<java.lang.String,java.util.Hashtable<java.lang.String,java.lang.String>> _allReactionsExtinguish

_allReactionsEnables

protected java.util.Hashtable<java.lang.String,java.util.Hashtable<java.lang.String,java.util.LinkedHashSet<java.lang.String>>> _allReactionsEnables

_allReactionsDisables

protected java.util.Hashtable<java.lang.String,java.util.Hashtable<java.lang.String,java.util.LinkedHashSet<java.lang.String>>> _allReactionsDisables

_allObstacles

protected java.util.Hashtable<java.lang.String,Obstacle> _allObstacles

_obstacleItemRel

protected java.util.Hashtable<java.lang.String,java.util.LinkedHashSet<java.lang.String>> _obstacleItemRel

_allRelated

protected java.util.Hashtable<java.lang.String,java.util.LinkedHashSet<java.lang.String>> _allRelated

_relativeTopicsEnable

protected java.util.Hashtable<java.lang.String,java.util.LinkedHashSet<java.lang.String>> _relativeTopicsEnable

_relativeScenesEnable

protected java.util.Hashtable<java.lang.String,java.util.LinkedHashSet<java.lang.String>> _relativeScenesEnable

_relativeTopicsDisable

protected java.util.Hashtable<java.lang.String,java.util.LinkedHashSet<java.lang.String>> _relativeTopicsDisable

_relativeScenesDisable

protected java.util.Hashtable<java.lang.String,java.util.LinkedHashSet<java.lang.String>> _relativeScenesDisable

_allReactionsItems

protected java.util.Hashtable<java.lang.String,java.util.LinkedHashSet<java.lang.String>> _allReactionsItems

_allItems

protected java.util.Hashtable<java.lang.String,Item> _allItems

_locationItemRel

protected java.util.Hashtable<java.lang.String,java.lang.String> _locationItemRel

_allScenes

protected java.util.Hashtable<java.lang.String,Scene> _allScenes

_allTopics

protected java.util.Hashtable<java.lang.String,Topic> _allTopics

_itemQueue

protected java.util.LinkedList<Item> _itemQueue

_itemIdQueue

protected java.util.LinkedList<java.lang.String> _itemIdQueue

_itemIdUseWithQueue

protected java.util.LinkedList<java.lang.String> _itemIdUseWithQueue

_extinguishWhenUsed

protected java.util.LinkedList<java.lang.Boolean> _extinguishWhenUsed

_extinguishWhenUsedWith

protected java.util.LinkedList<java.lang.Boolean> _extinguishWhenUsedWith

_bused

protected java.util.LinkedList<java.lang.Boolean> _bused

_busedWith

protected java.util.LinkedList<java.lang.Boolean> _busedWith

_itemUses

protected java.util.LinkedList<UsedWithInfo> _itemUses

_initialInventory

protected ItemRepository _initialInventory

st

protected java.io.StreamTokenizer st

_gamePath

protected java.lang.String _gamePath
Constructor Detail

XMLParser

public XMLParser(java.lang.String path)
Method Detail

parsed

public boolean parsed()
Was the game successfully parsed?

Returns:
True if it was successfully parsed

parse

public void parse(java.io.InputStream in)
           throws java.io.IOException,
                  org.xml.sax.SAXException
Asks for a SAXParser, and parses the file denoted by the input stream

Parameters:
in - The input stream
Throws:
java.io.IOException
org.xml.sax.SAXException

getInitialLocation

public Location getInitialLocation()
                            throws UnparsedGameDefinitionException,
                                   InvalidGameDefinitionException
Returns the initial location

Throws:
UnparsedGameDefinitionException
InvalidGameDefinitionException

getInitialInventory

public ItemRepository getInitialInventory()
                                   throws UnparsedGameDefinitionException,
                                          InvalidGameDefinitionException
Returns the initial inventory

Throws:
UnparsedGameDefinitionException
InvalidGameDefinitionException

getTitle

public java.lang.String getTitle()
                          throws UnparsedGameDefinitionException,
                                 InvalidGameDefinitionException
Returns the game title

Throws:
UnparsedGameDefinitionException
InvalidGameDefinitionException

getAuthor

public java.lang.String getAuthor()
                           throws UnparsedGameDefinitionException,
                                  InvalidGameDefinitionException
Returns the game author

Throws:
UnparsedGameDefinitionException
InvalidGameDefinitionException

getDesc

public java.lang.String getDesc()
                         throws UnparsedGameDefinitionException,
                                InvalidGameDefinitionException
Returns the game description

Throws:
UnparsedGameDefinitionException
InvalidGameDefinitionException

getTotalLocations

public int getTotalLocations()
                      throws UnparsedGameDefinitionException
Throws:
UnparsedGameDefinitionException

endDocument

public void endDocument()
Specified by:
endDocument in interface org.xml.sax.ContentHandler
Overrides:
endDocument in class org.xml.sax.helpers.DefaultHandler

startElement

public void startElement(java.lang.String uri,
                         java.lang.String name,
                         java.lang.String qName,
                         org.xml.sax.Attributes atrs)
                  throws org.xml.sax.SAXException
Specified by:
startElement in interface org.xml.sax.ContentHandler
Overrides:
startElement in class org.xml.sax.helpers.DefaultHandler
Throws:
org.xml.sax.SAXException

endElement

public void endElement(java.lang.String uri,
                       java.lang.String name,
                       java.lang.String qName)
                throws org.xml.sax.SAXException
Specified by:
endElement in interface org.xml.sax.ContentHandler
Overrides:
endElement in class org.xml.sax.helpers.DefaultHandler
Throws:
org.xml.sax.SAXException

characters

public void characters(char[] ch,
                       int start,
                       int length)
                throws org.xml.sax.SAXException
Specified by:
characters in interface org.xml.sax.ContentHandler
Overrides:
characters in class org.xml.sax.helpers.DefaultHandler
Throws:
org.xml.sax.SAXException