public void prepare(StringConverter<?>... aConverters) { context = new Context(aConverters); handler = root; }
public <T> StringConverter<T> getConverter(Class<T> aTo) { return (StringConverter<T>) getConverter(String.class, aTo); }
@SuppressWarnings("unchecked") public R getResult() { return (R) context.getResult(); }
public TagHandler<?> moveDown(String aQName, Attributes anAttributes, Context aCtx) { try { if (modelType != null) { R _model = Classes.newInstance(modelType); aCtx.push(_model); } if (attributes != null) attributes.handle(aCtx, aCtx.peek(), anAttributes); return this; } catch (ParsingException anExc) { throw anExc; } catch (Exception anExc) { throw new ParsingException(anExc); } }
public TagHandler<?> moveUp(String aQName, Context aCtx) { if (text != null) { text.complete(aCtx); } if (modelType != null) { R _model = (R) aCtx.pop(); if (parent != null) { Object _parent = aCtx.peek(); if (_parent != null) { if (factory != null) { Object _result = factory.newTarget(_model); ContextMutator _m = getMutator(_parent.getClass(), _result.getClass(), tagName); _m.apply(_parent, _result); } else { ContextMutator _m = getMutator(_parent.getClass(), modelType, tagName); _m.apply(_parent, _model); } } } } return parent; }
public void complete(Context aContext) { Object _currentContext = aContext.peek(); try { ValueSetter _vs = getSetter(aContext, _currentContext.getClass(), field); _vs.invoke(field, _currentContext, chars.toString()); chars.setLength(0); } catch (ParsingException anExc) { throw anExc; } catch (Exception anExc) { throw new ParsingException(anExc); } }
public Context(TypeSafeConverter<?,?>... aConverters) { converters = new ArrayList<TypeSafeConverter<?,?>>(); registerConverters( new PrimitiveBooleanStringConverter(), new PrimitiveByteStringConverter(), new PrimitiveShortStringConverter(), new PrimitiveIntStringConverter(), new PrimitiveLongStringConverter(), new PrimitiveCharStringConverter(), new PrimitiveFloatStringConverter(), new PrimitiveDoubleStringConverter(), new BooleanStringConverter(), new ByteStringConverter(), new ShortStringConverter(), new IntegerStringConverter(), new LongStringConverter(), new CharacterStringConverter(), new FloatStringConverter(), new DoubleStringConverter(), new ClassStringConverter(), new StringStringConverter() ); if (aConverters != null) converters.addAll(0, Arrays.asList(aConverters)); }