: Class PropertyTreeConverter

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## com.mortbay.Util
Class PropertyTreeConverter

    java.lang.Object
      |
      +--com.mortbay.Util.ConverterBase
            |
            +--com.mortbay.Util.PropertyTreeConverter

public class PropertyTreeConverter
extends ConverterBase

Class to convert Objects into PropertyTrees.

This class is a Converter that handles converting of arbitrary Objects into PropertyTrees. This will work well with objects that have public fields or have well-formed get/set pairs enabling their deconstruction/reconstruction. The resultant PropertyTree can then be output to a file and re-read in then converted back to an Object using the ObjectConverter.

The conversion continues recursively until object are resolved down to primitive types. (@see com.mortbay.Util.ConverterSet.PrimitiveConverter).

#### Note

Note that since this Converter handles ALL types, if asked to convert to a PropertyTree, it will convert everything it is given. Arrays don't convert too well, unless they are arrays of primitive types.

#### Usage

     Converter cnv = new PropertyTreeConverter();
     cnv.convert(object, PropertyTree.class, cnv);

Version:
  1.0 Fri Jun 9 2000
Author:
  Matthew Watson (mattw)

Constructor Summary
`PropertyTreeConverter()`

Method Summary
`protected java.lang.Object` | `doConvert(java.lang.Object toConvert, java.lang.Class convertTo, Converter context, boolean safe)` Convert an Object to another type.
`protected java.lang.Object` | `doConvert(PropertyTree to, java.lang.String prefix, java.lang.Object toConvert)`

Methods inherited from class com.mortbay.Util.ConverterBase
`convert, setTransformMode, unsafeConvert`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### PropertyTreeConverter

    public PropertyTreeConverter()

Method Detail

### doConvert

    protected java.lang.Object doConvert(java.lang.Object toConvert,
                                         java.lang.Class convertTo,
                                         Converter context,
                                         boolean safe)

  Description copied from class: ConverterBase
  Convert an Object to another type.
  Overrides:
    doConvert in class ConverterBase
  Tags copied from class: ConverterBase
  Parameters:
    `toConvert` - Value to convert
    `convertTo` - Type to convert to
    `context` - The context within which the converter was called. If Converters use other Converters, this is passed as the outermost Converter so that recursive calls have access to all available Converters. Converter implementations should pass this if passed null.
    `safe` - If false, errors should be returned.
  Returns:
    null if this converter doesn't handle this type to convertTo, or a ConvertFail exception if there was an error and safe is false.

### doConvert

    protected java.lang.Object doConvert(PropertyTree to,
                                         java.lang.String prefix,
                                         java.lang.Object toConvert)

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD