gnu.java.beans.decoder

Class DecoderContext

Implemented Interfaces:
gnu.java.beans.decoder.Context

public class DecoderContext
extends gnu.java.beans.decoder.AbstractContext

DecoderContext is a Context implementation which allows access to the XMLDecoder instance itself. This is used for the <java> tag.

Constructor Summary

DecoderContext(XMLDecoder xmlDecoder)

Method Summary

void
addParameterObject(Object o)
Adds a parameter object to the context.
Object
endContext(gnu.java.beans.decoder.Context outerContext)
Notifies that the context ends and the returns the appropriate result object.
Object
get(int index)
Calls an appropriate indexed get method if it is available or throws an AssemblerException if that is not allowed on this Context.
Object
getResult()
Returns the result which was calculated by calling endContext() or reportStatement().
Iterator
iterator()
Returns an Iterator that retrieves the assembled objects.
void
notifyStatement(gnu.java.beans.decoder.Context outerContext)
Notifies that the next element is a statement.
void
set(int index, Object o)
Calls an appropriate indexed set method if it is available or throws an AssemblerException if that is not allowed on this Context.
boolean
subContextFailed()
Notifies that the assembly of a subcontext failed and returns whether this Context is affected in a way that it fails too.

Methods inherited from class gnu.java.beans.decoder.AbstractContext

getId, isStatement, setId, setStatement

Methods inherited from class java.lang.Object

clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructor Details

DecoderContext

public DecoderContext(XMLDecoder xmlDecoder)

Method Details

addParameterObject

public void addParameterObject(Object o)
            throws gnu.java.beans.decoder.AssemblyException
Adds a parameter object to the context. This method is used when sub-Contexts return their result. Some Contexts do not accept more than a certain amount of objects and throw an AssemblerException if the amount is exceeded.
Specified by:
addParameterObject in interface gnu.java.beans.decoder.Context
Parameters:
o - The object added to this context.

endContext

public Object endContext(gnu.java.beans.decoder.Context outerContext)
            throws gnu.java.beans.decoder.AssemblyException
Notifies that the context ends and the returns the appropriate result object.
Specified by:
endContext in interface gnu.java.beans.decoder.Context
Parameters:
outerContext -
Returns:

get

public Object get(int index)
            throws gnu.java.beans.decoder.AssemblyException
Calls an appropriate indexed get method if it is available or throws an AssemblerException if that is not allowed on this Context. The behaviour of this method is equal to List.get(int).
Specified by:
get in interface gnu.java.beans.decoder.Context
Parameters:
index - Index position of the object return.

getResult

public Object getResult()
Returns the result which was calculated by calling endContext() or reportStatement(). Its the handler's responsibility to care that any of these two methods was called. This is used by sub-Contexts to access this Context's result.
Specified by:
getResult in interface gnu.java.beans.decoder.Context
Returns:

iterator

public Iterator iterator()
Returns an Iterator that retrieves the assembled objects.
Returns:
An Iterator retrieving assembled objects.

notifyStatement

public void notifyStatement(gnu.java.beans.decoder.Context outerContext)
            throws gnu.java.beans.decoder.AssemblyException
Notifies that the next element is a statement. This can mean that an argument list is complete to be called.
Specified by:
notifyStatement in interface gnu.java.beans.decoder.Context

set

public void set(int index,
                Object o)
            throws gnu.java.beans.decoder.AssemblyException
Calls an appropriate indexed set method if it is available or throws an AssemblerException if that is not allowed on this Context. The behaviour of this method is equal to List.set(int, Object).
Specified by:
set in interface gnu.java.beans.decoder.Context
Parameters:
index - Index position to be set.
o - Object to be set at the given index position.

subContextFailed

public boolean subContextFailed()
Notifies that the assembly of a subcontext failed and returns whether this Context is affected in a way that it fails too.
Specified by:
subContextFailed in interface gnu.java.beans.decoder.Context
Returns:
Whether the failure of a subcontext lets this context fail, too.

gnu.java.beans.decoder.DecoderContext Copyright (C) 2004 Free Software Foundation, Inc. This file is part of GNU Classpath. GNU Classpath is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. GNU Classpath 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 General Public License for more details. You should have received a copy of the GNU General Public License along with GNU Classpath; see the file COPYING. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. Linking this library statically or dynamically with other modules is making a combined work based on this library. Thus, the terms and conditions of the GNU General Public License cover the whole combination. As a special exception, the copyright holders of this library give you permission to link this library with independent modules to produce an executable, regardless of the license terms of these independent modules, and to copy and distribute the resulting executable under terms of your choice, provided that you also meet, for each linked independent module, the terms and conditions of the license of that module. An independent module is a module which is not derived from or based on this library. If you modify this library, you may extend this exception to your version of the library, but you are not obligated to do so. If you do not wish to do so, delete this exception statement from your version.