biz.c24.io.api.presentation
Class DefaultContext

java.lang.Object
  extended by biz.c24.io.api.presentation.DefaultContext

public class DefaultContext
extends Object

The parsing context hausing class.

Provides the stackable container of current parsing context. Implemented according to Thread-Specific Storage pattern, which allow multiple threads to use one logical access point to retrieve thread local data without incurring locking overhead for each access. The parsing context is hausing the data that is relevant to current parsing context, so its typical lifecycle is limited by the start and end element SAX events. The nested elements causes the stacking of context. Client is prohibited to change the designed behavior, but it is entitled to save the current context for the continuos restoring in case when it is needed to beyond from the current parsing context on a while (i.e. before the end element SAX event) and return back after.

Version:
$Revision: 15772 $ $Date: 2009-07-31 11:17:26 -0400 (Fri, 31 Jul 2009) $

Method Summary
 void addFailure(String reason)
          Sets the failure reason for current context data parsing.
protected  String computeCurrentPath()
           
protected  void foundAny()
          Signals about new ANY found in this context.
static DefaultContext getContext()
          Returns the current parsing context.
 String getCurrentPath()
           
 QName getElementName()
          Returns the FQ name of elemnet owned by this context.
 ParserException getFailure()
          Returns the first parsing failure reason if any.
 Locator getLocator()
           
 Logger getLog()
           
protected  boolean isAllowedAny(AnyElement element)
           
 boolean isFailed()
          Checks whether the current context data is failed to parse.
 void resetFailure()
          Resets the failure reason list.
 String resolvePrefixBy(String uri)
          The prefix by URI resolver.
 String resolveUriBy(String prefix)
          The URI by prefix resolver.
static void setContext(DefaultContext ctx)
          Sets the current parsing context.
 void setLogger(Logger logger)
           
protected  void updateTarget(ComplexDataObject object)
          This method do not check the parent since it ALWAYS has it.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getContext

public static DefaultContext getContext()
Returns the current parsing context.

Returns:
the current parsing context instance.

setContext

public static void setContext(DefaultContext ctx)
Sets the current parsing context.

Substitute the current context by specified one. Note. The binding is very sensitive to the context. So, be careful to change it, since its may cause the unexpected behavior.


getElementName

public QName getElementName()
Returns the FQ name of elemnet owned by this context. (I.e. element that is binding just now.)

Returns:
the name of context element, may be null.

resolveUriBy

public String resolveUriBy(String prefix)
The URI by prefix resolver.

Returns the URI of namespese with specified prefix.

Parameters:
prefix - the prefix of requested namespace URI.
Returns:
the URI of requested namespace.

resolvePrefixBy

public String resolvePrefixBy(String uri)
The prefix by URI resolver.

Returns the prefix of namespese with specified URI.

Parameters:
uri - the requested namespace URI.
Returns:
the prefix of requested namespace.

getLocator

public Locator getLocator()

isFailed

public boolean isFailed()
Checks whether the current context data is failed to parse.

Returns:
true if and only if data in current context was successfully parsed.

getFailure

public ParserException getFailure()
Returns the first parsing failure reason if any.

Returns:
the failure reason as list.

addFailure

public void addFailure(String reason)
Sets the failure reason for current context data parsing.

Parameters:
reason - the failure reason.

getLog

public Logger getLog()

setLogger

public void setLogger(Logger logger)

getCurrentPath

public String getCurrentPath()

resetFailure

public void resetFailure()
Resets the failure reason list.


updateTarget

protected void updateTarget(ComplexDataObject object)
This method do not check the parent since it ALWAYS has it. If there is NPE the DefaultContext are popping in wrong order or its nesting are abnormal. NPE HERE MEANS THE WRONG MODEL INTERPRETATION! DO NOT REMOVE IT FOR CLEAR UNDERSTANDING THE NATURE OF ISSUE!

Parameters:
object - the CDO that should be updated before popping out.
See Also:
DocumentContext#updateTarget(biz.c24.io.api.data.ComplexDataObject)

computeCurrentPath

protected String computeCurrentPath()

foundAny

protected void foundAny()
Signals about new ANY found in this context.

Increments the counter of ANY found in this context. Required for count the ANY particles found in this context to care about its cardinality.

Note. Checking should consider that it is incremented before actual instance will be bound.

See Also:
isAllowedAny(biz.c24.io.api.data.AnyElement)

isAllowedAny

protected boolean isAllowedAny(AnyElement element)


C24 Technologies © 2002-2012: All Rights Reserved.