public class DefaultResponseFactory extends java.lang.Object implements ResponseFactory
Modifier and Type | Class and Description |
---|---|
protected class |
DefaultResponseFactory.ClassRule
rule that uses the request for the selection of the suitable response
|
protected static class |
DefaultResponseFactory.KeyRule
rule that tests for the existence of certain keys
|
protected static class |
DefaultResponseFactory.ListRule
small class that describes a rule for choosing a specific subclass
|
Modifier and Type | Field and Description |
---|---|
private java.lang.Class<? extends Response> |
defaultClass
the default class
|
private java.util.SortedSet<DefaultResponseFactory.ListRule> |
rules
the set of rules
|
private static DefaultResponseFactory |
singleton
singleton instance with default settings
|
private java.util.Map<javax.xml.namespace.QName,java.lang.Class<? extends Response>> |
xmlMap
map from the name of the first element to the class
|
Modifier | Constructor and Description |
---|---|
protected |
DefaultResponseFactory()
constructor.
|
Modifier and Type | Method and Description |
---|---|
protected void |
addRule(DefaultResponseFactory.ListRule rule)
add a list rule
|
protected void |
addXmlMapping(javax.xml.namespace.QName qName,
java.lang.Class<? extends Response> cls)
add an XML mapping
|
protected void |
addXmlMapping(java.lang.String uri,
java.lang.String localName,
java.lang.Class<? extends Response> cls)
add an XML mapping
|
protected void |
createDefaults()
create the default entries
|
protected Response |
createInstance(java.lang.Class<? extends Response> cls)
create an instance of the given class, mapping the special exceptions
to RuntimeExceptions
|
Response |
createResponse(org.w3c.dom.Document doc,
Request request)
create an instance based on the given XML document.
|
Response |
createResponse(KVMultiList list,
Request request)
create an instance based on the given key-value pair list.
|
static ResponseFactory |
getFactory()
return the default factory
|
protected void |
setDefaultClass(java.lang.Class<? extends Response> cls)
set the default class
|
private java.util.Map<javax.xml.namespace.QName,java.lang.Class<? extends Response>> xmlMap
private java.util.SortedSet<DefaultResponseFactory.ListRule> rules
private java.lang.Class<? extends Response> defaultClass
private static final DefaultResponseFactory singleton
protected DefaultResponseFactory()
createDefaults
needs to be called.protected void setDefaultClass(java.lang.Class<? extends Response> cls)
cls
- the default classprotected void addXmlMapping(javax.xml.namespace.QName qName, java.lang.Class<? extends Response> cls)
qName
- the name of the XML elementcls
- the classprotected void addXmlMapping(java.lang.String uri, java.lang.String localName, java.lang.Class<? extends Response> cls)
uri
- the namespace URIlocalName
- the local namecls
- the classprotected void addRule(DefaultResponseFactory.ListRule rule)
rule
- the ruleprotected void createDefaults()
public static ResponseFactory getFactory()
protected Response createInstance(java.lang.Class<? extends Response> cls)
cls
- the class to instantiatepublic Response createResponse(org.w3c.dom.Document doc, Request request) throws org.w3c.dom.DOMException, ResponseParseException
createResponse
in interface ResponseFactory
doc
- the documentrequest
- the request, may be null
org.w3c.dom.DOMException
- on DOM exceptionsResponseParseException
- if the type could not be determinedpublic Response createResponse(KVMultiList list, Request request) throws ResponseParseException
createResponse
in interface ResponseFactory
list
- the listrequest
- the request, may be null
ResponseParseException
- if the type could not be determinedCopyright © 2005-2013 Knipp Medien und Kommunikation GmbH