List of usage examples for javax.xml.stream XMLStreamReader hasNext
public boolean hasNext() throws XMLStreamException;
From source file:org.jwebsocket.config.xml.JWebSocketConfigHandler.java
/** * private method to handle the user config. * * @param aStreamReader/*www . jav a 2 s . co m*/ * the stream reader object * @return the list of user config * @throws XMLStreamException * if there's any exception reading configuration */ private List<UserConfig> handleUsers(XMLStreamReader aStreamReader) throws XMLStreamException { List<UserConfig> lUsers = new FastList<UserConfig>(); while (aStreamReader.hasNext()) { aStreamReader.next(); if (aStreamReader.isStartElement()) { String lElementName = aStreamReader.getLocalName(); if (lElementName.equals(ELEMENT_USER)) { UserConfig lUser = (UserConfig) handlerContext.get(lElementName).processConfig(aStreamReader); lUsers.add(lUser); } } if (aStreamReader.isEndElement()) { String lElementName = aStreamReader.getLocalName(); if (lElementName.equals(ELEMENT_USERS)) { break; } } } return lUsers; }
From source file:org.jwebsocket.config.xml.JWebSocketConfigHandler.java
/** * method that reads the roles configuration * * @param aStreamReader/* w w w . j a v a 2 s.c o m*/ * the stream reader object * @return the list of roles config * @throws XMLStreamException * if there's any exception reading configuration */ private List<RoleConfig> handleRoles(XMLStreamReader aStreamReader) throws XMLStreamException { List<RoleConfig> lRoles = new FastList<RoleConfig>(); while (aStreamReader.hasNext()) { aStreamReader.next(); if (aStreamReader.isStartElement()) { String lElementName = aStreamReader.getLocalName(); if (lElementName.equals(ELEMENT_ROLE)) { RoleConfig lRole = (RoleConfig) handlerContext.get(lElementName).processConfig(aStreamReader); lRoles.add(lRole); } } if (aStreamReader.isEndElement()) { String lElementName = aStreamReader.getLocalName(); if (lElementName.equals(ELEMENT_ROLES)) { break; } } } return lRoles; }
From source file:org.jwebsocket.config.xml.JWebSocketConfigHandler.java
/** * private method to read the list of rights configuration * * @param aStreamReader//w w w. j a v a2 s .c o m * the stream reader object * @return the list of rights configuration * @throws XMLStreamException * if there's any exception reading configuration */ private List<RightConfig> handleRights(XMLStreamReader aStreamReader) throws XMLStreamException { List<RightConfig> lRights = new FastList<RightConfig>(); while (aStreamReader.hasNext()) { aStreamReader.next(); if (aStreamReader.isStartElement()) { String lElementName = aStreamReader.getLocalName(); if (lElementName.equals(ELEMENT_RIGHT)) { RightConfig lRight = (RightConfig) handlerContext.get(lElementName) .processConfig(aStreamReader); lRights.add(lRight); } } if (aStreamReader.isEndElement()) { String lElementName = aStreamReader.getLocalName(); if (lElementName.equals(ELEMENT_RIGHTS)) { break; } } } return lRights; }
From source file:org.jwebsocket.config.xml.JWebSocketConfigHandler.java
/** * private method that reads the config for plugins * * @param aStreamReader//from w w w . j a v a2 s . c o m * the stream reader object * @return the list of plugin configs * @throws XMLStreamException * if exception occurs while reading */ protected List<PluginConfig> handlePlugins(XMLStreamReader aStreamReader) throws XMLStreamException { List<PluginConfig> lPlugins = new FastList<PluginConfig>(); while (aStreamReader.hasNext()) { aStreamReader.next(); if (aStreamReader.isStartElement()) { String lElementName = aStreamReader.getLocalName(); if (lElementName.equals(ELEMENT_PLUGIN)) { PluginConfig lPlugin = (PluginConfig) handlerContext.get(lElementName) .processConfig(aStreamReader); lPlugins.add(lPlugin); } } if (aStreamReader.isEndElement()) { String lElementName = aStreamReader.getLocalName(); if (lElementName.equals(ELEMENT_PLUGINS)) { break; } } } return lPlugins; }
From source file:org.jwebsocket.config.xml.JWebSocketConfigHandler.java
/** * private method that reads the config for filters * * @param aStreamReader//from w ww .j av a 2 s . co m * the stream reader object * @return the list of filter configs * @throws XMLStreamException * if exception occurs while reading */ protected List<FilterConfig> handleFilters(XMLStreamReader aStreamReader) throws XMLStreamException { List<FilterConfig> lFilters = new FastList<FilterConfig>(); while (aStreamReader.hasNext()) { aStreamReader.next(); if (aStreamReader.isStartElement()) { String lElementName = aStreamReader.getLocalName(); if (lElementName.equals(ELEMENT_FILTER)) { FilterConfig lFilter = (FilterConfig) handlerContext.get(lElementName) .processConfig(aStreamReader); lFilters.add(lFilter); } } if (aStreamReader.isEndElement()) { String lElementName = aStreamReader.getLocalName(); if (lElementName.equals(ELEMENT_FILTERS)) { break; } } } return lFilters; }
From source file:org.jwebsocket.config.xml.JWebSocketConfigHandler.java
/** * private method that reads the config for logging * * @param aStreamReader// w ww . j av a2 s . com * the stream reader object * @return the list of logging configs * @throws XMLStreamException * if exception occurs while reading */ private List<LoggingConfig> handleLoggingConfigs(XMLStreamReader aStreamReader) throws XMLStreamException { List<LoggingConfig> loggingConfigs = new FastList<LoggingConfig>(); while (aStreamReader.hasNext()) { aStreamReader.next(); if (aStreamReader.isStartElement()) { String lElementName = aStreamReader.getLocalName(); if (lElementName.equals(ELEMENT_LOG4J)) { LoggingConfig loggingConfig = (LoggingConfig) handlerContext.get(lElementName) .processConfig(aStreamReader); loggingConfigs.add(loggingConfig); } } if (aStreamReader.isEndElement()) { String lElementName = aStreamReader.getLocalName(); if (lElementName.equals(ELEMENT_LOGGING)) { break; } } } return loggingConfigs; }
From source file:org.jwebsocket.config.xml.JWebSocketConfigHandler.java
/** * private method that reads the list of server configs * * @param aStreamReader// ww w . j a v a 2 s . co m * the stream reader object * @return the list of server configs * @throws XMLStreamException * if exception occurs reading xml */ private List<ServerConfig> handleServers(XMLStreamReader aStreamReader) throws XMLStreamException { List<ServerConfig> lServers = new FastList<ServerConfig>(); while (aStreamReader.hasNext()) { aStreamReader.next(); if (aStreamReader.isStartElement()) { String lElementName = aStreamReader.getLocalName(); if (lElementName.equals(ELEMENT_SERVER)) { ServerConfig lServer = (ServerConfig) handlerContext.get(lElementName) .processConfig(aStreamReader); lServers.add(lServer); } } if (aStreamReader.isEndElement()) { String lElementName = aStreamReader.getLocalName(); if (lElementName.equals(ELEMENT_SERVERS)) { break; } } } return lServers; }
From source file:org.jwebsocket.config.xml.JWebSocketConfigHandler.java
/** * private method that reads the list of engines config from the xml file * * @param aStreamReader// w ww .j a v a2 s .c om * the stream reader object * @return the list of engine configs * @throws XMLStreamException * if exception occurs while reading */ private List<LibraryConfig> handleLibraries(XMLStreamReader aStreamReader) throws XMLStreamException { List<LibraryConfig> lLibraries = new FastList<LibraryConfig>(); while (aStreamReader.hasNext()) { aStreamReader.next(); if (aStreamReader.isStartElement()) { String lElementName = aStreamReader.getLocalName(); if (lElementName.equals(ELEMENT_LIBRARY)) { LibraryConfig lLibrary = (LibraryConfig) handlerContext.get(lElementName) .processConfig(aStreamReader); lLibraries.add(lLibrary); } } if (aStreamReader.isEndElement()) { String lElementName = aStreamReader.getLocalName(); if (lElementName.equals(ELEMENT_LIBRARIES)) { break; } } } return lLibraries; }
From source file:org.jwebsocket.config.xml.JWebSocketConfigHandler.java
/** * private method that reads the list of engines config from the xml file * * @param aStreamReader//from w ww . ja va 2 s . c om * the stream reader object * @return the list of engine configs * @throws XMLStreamException * if exception occurs while reading */ private List<EngineConfig> handleEngines(XMLStreamReader aStreamReader) throws XMLStreamException { List<EngineConfig> lEngines = new FastList<EngineConfig>(); while (aStreamReader.hasNext()) { aStreamReader.next(); if (aStreamReader.isStartElement()) { String lElementName = aStreamReader.getLocalName(); if (lElementName.equals(ELEMENT_ENGINE)) { EngineConfig lEngine = (EngineConfig) handlerContext.get(lElementName) .processConfig(aStreamReader); lEngines.add(lEngine); } } if (aStreamReader.isEndElement()) { String lElementName = aStreamReader.getLocalName(); if (lElementName.equals(ELEMENT_ENGINES)) { break; } } } return lEngines; }
From source file:org.jwebsocket.config.xml.JWebSocketConfigHandler.java
/** * Read the map of plug-in specific settings * @param aStreamReader/* ww w .j a v a 2 s . c o m*/ * the stream reader object * @return the list of domains for the engine * @throws XMLStreamException * in case of stream exception */ public static Map<String, Object> getSettings(XMLStreamReader aStreamReader) throws XMLStreamException { Map<String, Object> lSettings = new FastMap<String, Object>(); while (aStreamReader.hasNext()) { aStreamReader.next(); if (aStreamReader.isStartElement()) { String lElementName = aStreamReader.getLocalName(); if (lElementName.equals(SETTING)) { String lKey = aStreamReader.getAttributeValue(null, "key"); String lType = aStreamReader.getAttributeValue(null, "type"); aStreamReader.next(); String lValue = aStreamReader.getText(); if (lKey != null && lValue != null) { if ("json".equalsIgnoreCase(lType)) { JSONObject lJSON = null; try { lJSON = new JSONObject(lValue); } catch (JSONException lEx) { // TODO: handle invalid JSON code in settings properly! } lSettings.put(lKey, lJSON); } else { lSettings.put(lKey, lValue); } } } } if (aStreamReader.isEndElement()) { String lElementName = aStreamReader.getLocalName(); if (lElementName.equals(SETTINGS)) { break; } } } return lSettings; }