/** * Configuration property: Auto-close streams. * <p> * Shortcut for calling <code>autoCloseStreams(<jk>true</jk>)</code>. * * <h5 class='section'>See Also:</h5> * <ul> * <li class='jf'>{@link Parser#PARSER_autoCloseStreams} * </ul> * * @return This object (for method chaining). */ public ParserGroupBuilder autoCloseStreams() { return set(PARSER_autoCloseStreams, true); }
/** * Returns a builder that's a copy of the settings on this parser group. * * @return A new {@link ParserGroupBuilder} initialized to this group. */ @Override /* Context */ public ParserGroupBuilder builder() { return new ParserGroupBuilder(this); }
bcb = beanContext.builder(); sgb.append(mSerializers); pgb.append(mParsers); pgb.apply(propertyStore); pgb.beanFilters(mBeanFilters); pgb.pojoSwaps(mPojoSwaps); serializers = sgb.build(); if (pgb != null) parsers = pgb.build(); if (uepb != null && partParser instanceof Parser) { Parser pp = (Parser)partParser;
/** * Constructor. */ protected BaseProvider() { try { properties = new ObjectMap(); JuneauProvider jp = getClass().getAnnotation(JuneauProvider.class); for (Property p : jp.properties()) properties.put(p.name(), p.value()); for (String p : jp.flags()) properties.put(p, true); serializers = SerializerGroup.create() .append(jp.serializers()) .beanFilters(jp.beanFilters()) .pojoSwaps(jp.pojoSwaps()) .set(properties) .build(); parsers = ParserGroup.create() .append(jp.parsers()) .beanFilters(jp.beanFilters()) .pojoSwaps(jp.pojoSwaps()) .set(properties) .build(); } catch (Exception e) { throw new RuntimeException(e); } }
@Test public void testInheritence() throws Exception { ParserGroupBuilder gb = null; ParserGroup g = null; gb = ParserGroup.create().append(P1.class, P2.class); g = gb.build(); assertObjectEquals("['text/1','text/2','text/2a']", g.getSupportedMediaTypes()); gb = g.builder().append(P3.class, P4.class); g = gb.build(); assertObjectEquals("['text/3','text/4','text/4a','text/1','text/2','text/2a']", g.getSupportedMediaTypes()); gb = g.builder().append(P5.class); g = gb.build(); assertObjectEquals("['text/5','text/3','text/4','text/4a','text/1','text/2','text/2a']", g.getSupportedMediaTypes()); }
/** * Creates a new {@link ParserGroup} object using a snapshot of the settings defined in this builder. * * <p> * This method can be called multiple times to produce multiple parser groups. * * @return A new {@link ParserGroup} object. */ @Override /* Context */ @SuppressWarnings("unchecked") public ParserGroup build() { List<Parser> l = new ArrayList<>(); for (Object p : parsers) { Class<? extends Parser> c = null; PropertyStore ps = getPropertyStore(); if (p instanceof Class) { c = (Class<? extends Parser>)p; l.add(ContextCache.INSTANCE.create(c, ps)); } else { l.add((Parser)p); } } return new ParserGroup(getPropertyStore(), ArrayUtils.toReverseArray(Parser.class, l)); }
bcb = beanContext.builder(); sgb.append(mSerializers); pgb.append(mParsers); pgb.apply(propertyStore); pgb.beanFilters(mBeanFilters); pgb.pojoSwaps(mPojoSwaps); serializers = sgb.build(); if (pgb != null) parsers = pgb.build(); if (uepb != null && partParser instanceof Parser) { Parser pp = (Parser)partParser;
/** * Constructor. */ protected BaseProvider() { try { properties = new ObjectMap(); JuneauProvider jp = getClass().getAnnotation(JuneauProvider.class); for (Property p : jp.properties()) properties.put(p.name(), p.value()); for (String p : jp.flags()) properties.put(p, true); serializers = SerializerGroup.create() .append(jp.serializers()) .beanFilters(jp.beanFilters()) .pojoSwaps(jp.pojoSwaps()) .set(properties) .build(); parsers = ParserGroup.create() .append(jp.parsers()) .beanFilters(jp.beanFilters()) .pojoSwaps(jp.pojoSwaps()) .set(properties) .build(); } catch (Exception e) { throw new RuntimeException(e); } }
@Test public void testParserGroupMatching() throws Exception { ParserGroup g = ParserGroup.create().append(Parser1.class, Parser2.class, Parser3.class).build(); assertInstanceOf(Parser1.class, g.getParser("text/foo")); assertInstanceOf(Parser1.class, g.getParser("text/foo_a")); assertInstanceOf(Parser1.class, g.getParser("text/foo_a+xxx")); assertInstanceOf(Parser1.class, g.getParser("text/xxx+foo_a")); assertInstanceOf(Parser2.class, g.getParser("text/foo+bar")); assertInstanceOf(Parser2.class, g.getParser("text/foo+bar_a")); assertInstanceOf(Parser2.class, g.getParser("text/bar+foo")); assertInstanceOf(Parser2.class, g.getParser("text/bar+foo+xxx")); assertInstanceOf(Parser3.class, g.getParser("text/baz")); assertInstanceOf(Parser3.class, g.getParser("text/baz_a")); assertInstanceOf(Parser3.class, g.getParser("text/baz+yyy")); assertInstanceOf(Parser3.class, g.getParser("text/baz_a+yyy")); assertInstanceOf(Parser3.class, g.getParser("text/yyy+baz")); assertInstanceOf(Parser3.class, g.getParser("text/yyy+baz_a")); }
/** * Creates a new {@link ParserGroup} object using a snapshot of the settings defined in this builder. * * <p> * This method can be called multiple times to produce multiple parser groups. * * @return A new {@link ParserGroup} object. */ @Override /* Context */ @SuppressWarnings("unchecked") public ParserGroup build() { List<Parser> l = new ArrayList<>(); for (Object p : parsers) { Class<? extends Parser> c = null; PropertyStore ps = getPropertyStore(); if (p instanceof Class) { c = (Class<? extends Parser>)p; l.add(ContextCache.INSTANCE.create(c, ps)); } else { l.add((Parser)p); } } return new ParserGroup(getPropertyStore(), ArrayUtils.toReverseArray(Parser.class, l)); }
bcb = beanContext.builder(); sgb.append(mSerializers); pgb.append(mParsers); pgb.apply(propertyStore); pgb.beanFilters(mBeanFilters); pgb.pojoSwaps(mPojoSwaps); serializers = sgb.build(); if (pgb != null) parsers = pgb.build(); if (uepb != null && partParser instanceof Parser) { Parser pp = (Parser)partParser;
/** * Configuration property: Auto-close streams. * <p> * Shortcut for calling <code>autoCloseStreams(<jk>true</jk>)</code>. * * <h5 class='section'>See Also:</h5> * <ul> * <li class='jf'>{@link Parser#PARSER_autoCloseStreams} * </ul> * * @return This object (for method chaining). */ public ParserGroupBuilder autoCloseStreams() { return set(PARSER_autoCloseStreams, true); }
/** * Returns a builder that's a copy of the settings on this parser group. * * @return A new {@link ParserGroupBuilder} initialized to this group. */ @Override /* Context */ public ParserGroupBuilder builder() { return new ParserGroupBuilder(this); }
/** * Creates a new {@link ParserGroup} object using a snapshot of the settings defined in this builder. * * <p> * This method can be called multiple times to produce multiple parser groups. * * @return A new {@link ParserGroup} object. */ @Override /* Context */ @SuppressWarnings("unchecked") public ParserGroup build() { List<Parser> l = new ArrayList<>(); for (Object p : parsers) { Class<? extends Parser> c = null; PropertyStore ps = getPropertyStore(); if (p instanceof Class) { c = (Class<? extends Parser>)p; l.add(ContextCache.INSTANCE.create(c, ps)); } else { l.add((Parser)p); } } return new ParserGroup(getPropertyStore(), ArrayUtils.toReverseArray(Parser.class, l)); }
/** * Configuration property: Unbuffered. * * <p> * Shortcut for calling <code>unbuffered(<jk>true</jk>)</code>. * * <h5 class='section'>See Also:</h5> * <ul> * <li class='jf'>{@link Parser#PARSER_unbuffered} * </ul> * * @return This object (for method chaining). */ public ParserGroupBuilder unbuffered() { return set(PARSER_unbuffered, true); }
/** * Instantiates a new clean-slate {@link ParserGroupBuilder} object. * * <p> * This is equivalent to simply calling <code><jk>new</jk> ParserGroupBuilder()</code>. * * @return A new {@link ParserGroupBuilder} object. */ public static ParserGroupBuilder create() { return new ParserGroupBuilder(); }
/** * Configuration property: Strict mode. * * <p> * Shortcut for calling <code>strict(<jk>true</jk>)</code>. * * <h5 class='section'>See Also:</h5> * <ul> * <li class='jf'>{@link Parser#PARSER_strict} * </ul> * * @return This object (for method chaining). */ public ParserGroupBuilder strict() { return set(PARSER_strict, true); }
/** * Instantiates a new clean-slate {@link ParserGroupBuilder} object. * * <p> * This is equivalent to simply calling <code><jk>new</jk> ParserGroupBuilder()</code>. * * @return A new {@link ParserGroupBuilder} object. */ public static ParserGroupBuilder create() { return new ParserGroupBuilder(); }
/** * Configuration property: Unbuffered. * * <p> * Shortcut for calling <code>unbuffered(<jk>true</jk>)</code>. * * <h5 class='section'>See Also:</h5> * <ul> * <li class='jf'>{@link Parser#PARSER_unbuffered} * </ul> * * @return This object (for method chaining). */ public ParserGroupBuilder unbuffered() { return set(PARSER_unbuffered, true); }
/** * Returns a builder that's a copy of the settings on this parser group. * * @return A new {@link ParserGroupBuilder} initialized to this group. */ @Override /* Context */ public ParserGroupBuilder builder() { return new ParserGroupBuilder(this); }