daniel
7 years ago
1829 changed files with 327806 additions and 0 deletions
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -0,0 +1,74 @@
|
||||
Manifest-Version: 1.0 |
||||
Implementation-Title: hibernate-ehcache |
||||
Bundle-Description: A module of the Hibernate O/RM project |
||||
Bundle-SymbolicName: com.fr.third.org.hibernate.ehcache |
||||
Implementation-Version: 5.2.12.Final |
||||
Bundle-ManifestVersion: 2 |
||||
Bnd-LastModified: 1508428584000 |
||||
Specification-Vendor: Hibernate.org |
||||
Specification-Title: hibernate-ehcache |
||||
Implementation-Vendor-Id: com.fr.third.org.hibernate |
||||
Bundle-Vendor: Hibernate.org |
||||
Import-Package: javax.transaction;version="[1.1,2)",javax.management,j |
||||
avax.management.openmbean,javax.naming,net.sf.ehcache;version="[2.10, |
||||
3)",net.sf.ehcache.concurrent;version="[2.10,3)",net.sf.ehcache.confi |
||||
g;version="[2.10,3)",net.sf.ehcache.constructs.nonstop;version="[2.10 |
||||
,3)",net.sf.ehcache.event;version="[2.10,3)",net.sf.ehcache.hibernate |
||||
.management.api;version="[2.10,3)",net.sf.ehcache.statistics;version= |
||||
"[2.10,3)",net.sf.ehcache.statistics.extended;version="[2.10,3)",net. |
||||
sf.ehcache.util;version="[2.10,3)",org.hibernate;version="[5.2,6)",or |
||||
g.hibernate.boot.registry.classloading.spi;version="[5.2,6)",org.hibe |
||||
rnate.boot.registry.selector;version="[5.2,6)",org.hibernate.boot.spi |
||||
;version="[5.2,6)",org.hibernate.cache;version="[5.2,6)",org.hibernat |
||||
e.cache.ehcache;version="[5.2,6)",org.hibernate.cache.ehcache.interna |
||||
l.nonstop;version="[5.2,6)",org.hibernate.cache.ehcache.internal.regi |
||||
ons;version="[5.2,6)",org.hibernate.cache.ehcache.internal.strategy;v |
||||
ersion="[5.2,6)",org.hibernate.cache.ehcache.internal.util;version="[ |
||||
5.2,6)",org.hibernate.cache.ehcache.management.impl;version="[5.2,6)" |
||||
,org.hibernate.cache.internal;version="[5.2,6)",org.hibernate.cache.s |
||||
pi;version="[5.2,6)",org.hibernate.cache.spi.access;version="[5.2,6)" |
||||
,org.hibernate.dialect;version="[5.2,6)",org.hibernate.engine.jdbc.di |
||||
alect.spi;version="[5.2,6)",org.hibernate.engine.jndi;version="[5.2,6 |
||||
)",org.hibernate.engine.loading.internal;version="[5.2,6)",org.hibern |
||||
ate.engine.spi;version="[5.2,6)",org.hibernate.id;version="[5.2,6)",o |
||||
rg.hibernate.internal;version="[5.2,6)",org.hibernate.persister.colle |
||||
ction;version="[5.2,6)",org.hibernate.persister.entity;version="[5.2, |
||||
6)",org.hibernate.service.spi;version="[5.2,6)",org.hibernate.stat;ve |
||||
rsion="[5.2,6)",org.hibernate.type;version="[5.2,6)",org.jboss.loggin |
||||
g;version="[3.3,4)" |
||||
Require-Capability: osgi.ee;filter:="(&(osgi.ee=JavaSE)(version=1.8))" |
||||
Tool: Bnd-3.4.0.201707252008 |
||||
Implementation-Vendor: Hibernate.org |
||||
Export-Package: com.fr.third.org.hibernate.cache.ehcache;version="5.2.12.Final";use |
||||
s:="javax.naming,javax.transaction,org.hibernate,org.hibernate.boot.r |
||||
egistry.classloading.spi,org.hibernate.boot.registry.selector,org.hib |
||||
ernate.boot.spi,org.hibernate.cache,org.hibernate.cache.spi,org.hiber |
||||
nate.cache.spi.access,org.hibernate.dialect,org.hibernate.engine.jdbc |
||||
.dialect.spi,org.hibernate.engine.jndi,org.hibernate.engine.loading.i |
||||
nternal,org.hibernate.engine.spi,org.hibernate.id,org.hibernate.inter |
||||
nal,org.hibernate.service.spi,org.hibernate.type,org.jboss.logging",o |
||||
rg.hibernate.cache.ehcache.internal.nonstop;version="5.2.12.Final";us |
||||
es:="net.sf.ehcache.constructs.nonstop,org.hibernate.cache,org.hibern |
||||
ate.cache.ehcache.internal.regions,org.hibernate.cache.ehcache.intern |
||||
al.strategy,org.hibernate.cache.spi,org.hibernate.cache.spi.access,or |
||||
g.hibernate.engine.spi,org.hibernate.persister.collection,org.hiberna |
||||
te.persister.entity",org.hibernate.cache.ehcache.internal.regions;ver |
||||
sion="5.2.12.Final";uses:="net.sf.ehcache,org.hibernate.boot.spi,org. |
||||
hibernate.cache,org.hibernate.cache.ehcache.internal.strategy,org.hib |
||||
ernate.cache.spi,org.hibernate.cache.spi.access,org.hibernate.engine. |
||||
spi",org.hibernate.cache.ehcache.internal.strategy;version="5.2.12.Fi |
||||
nal";uses:="net.sf.ehcache,org.hibernate.boot.spi,org.hibernate.cache |
||||
,org.hibernate.cache.ehcache.internal.regions,org.hibernate.cache.spi |
||||
,org.hibernate.cache.spi.access,org.hibernate.engine.spi,org.hibernat |
||||
e.persister.collection,org.hibernate.persister.entity",org.hibernate. |
||||
cache.ehcache.internal.util;version="5.2.12.Final";uses:="net.sf.ehca |
||||
che.config",org.hibernate.cache.ehcache.management.impl;version="5.2. |
||||
12.Final";uses:="javax.management,javax.management.openmbean,net.sf.e |
||||
hcache,net.sf.ehcache.event,net.sf.ehcache.hibernate.management.api,o |
||||
rg.hibernate,org.hibernate.stat" |
||||
Bundle-Name: hibernate-ehcache |
||||
Bundle-Version: 5.2.12.Final |
||||
Created-By: 1.8.0_144 (Oracle Corporation) |
||||
Specification-Version: 5.2.12.Final |
||||
Implementation-Url: http://hibernate.org |
||||
|
@ -0,0 +1 @@
|
||||
com.fr.third.fasterxml.jackson.core.JsonFactory |
@ -0,0 +1 @@
|
||||
com.fr.third.fasterxml.jackson.databind.ObjectMapper |
@ -0,0 +1 @@
|
||||
com.fr.third.fasterxml.jackson.module.jaxb.JaxbAnnotationModule |
@ -0,0 +1 @@
|
||||
com.fr.third.net.sf.ehcache.management.ManagementServerImpl |
@ -0,0 +1,2 @@
|
||||
com.terracotta.management.ApplicationEhCacheV1 |
||||
com.terracotta.management.ApplicationEhCacheV2 |
@ -0,0 +1 @@
|
||||
org.glassfish.jersey.servlet.init.JerseyServletContainerInitializer |
@ -0,0 +1 @@
|
||||
com.fr.third.fasterxml.jackson.jaxrs.json.JacksonJsonProvider |
@ -0,0 +1 @@
|
||||
com.fr.third.fasterxml.jackson.jaxrs.json.JacksonJsonProvider |
@ -0,0 +1 @@
|
||||
org.glassfish.jersey.servlet.async.AsyncContextDelegateProviderImpl |
@ -0,0 +1,13 @@
|
||||
# |
||||
# Hibernate, Relational Persistence for Idiomatic Java |
||||
# |
||||
# License: GNU Lesser General Public License (LGPL), version 2.1 or later. |
||||
# See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>. |
||||
# |
||||
# |
||||
# Hibernate, Relational Persistence for Idiomatic Java |
||||
# |
||||
# License: GNU Lesser General Public License (LGPL), version 2.1 or later. |
||||
# See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>. |
||||
# |
||||
com.fr.third.org.hibernate.cache.ehcache.StrategyRegistrationProviderImpl |
@ -0,0 +1 @@
|
||||
# Don't remove this line -- if file is empty then everything will become an API type |
@ -0,0 +1,16 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?> |
||||
|
||||
<!-- |
||||
~ Hibernate, Relational Persistence for Idiomatic Java |
||||
~ |
||||
~ License: GNU Lesser General Public License (LGPL), version 2.1 or later. |
||||
~ See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>. |
||||
--> |
||||
<blueprint default-activation="eager" |
||||
xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0" |
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> |
||||
|
||||
<bean id="strategyRegistrationProvider" class="com.fr.third.org.hibernate.cache.ehcache.StrategyRegistrationProviderImpl"/> |
||||
<service ref="strategyRegistrationProvider" interface="org.hibernate.boot.registry.selector.StrategyRegistrationProvider"/> |
||||
|
||||
</blueprint> |
@ -0,0 +1,20 @@
|
||||
package com.fr.third.fasterxml.jackson.annotation; |
||||
|
||||
import java.lang.annotation.ElementType; |
||||
import java.lang.annotation.Retention; |
||||
import java.lang.annotation.RetentionPolicy; |
||||
import java.lang.annotation.Target; |
||||
|
||||
/** |
||||
* Meta-annotation (annotations used on other annotations) |
||||
* used for marking all annotations that are |
||||
* part of Jackson package. Can be used for recognizing all |
||||
* Jackson annotations generically, and in future also for |
||||
* passing other generic annotation configuration. |
||||
*/ |
||||
@Target({ElementType.ANNOTATION_TYPE}) |
||||
@Retention(RetentionPolicy.RUNTIME) |
||||
public @interface JacksonAnnotation |
||||
{ |
||||
// for now, a pure tag annotation, no parameters
|
||||
} |
@ -0,0 +1,25 @@
|
||||
package com.fr.third.fasterxml.jackson.annotation; |
||||
|
||||
import java.lang.annotation.ElementType; |
||||
import java.lang.annotation.Retention; |
||||
import java.lang.annotation.RetentionPolicy; |
||||
import java.lang.annotation.Target; |
||||
|
||||
/** |
||||
* Meta-annotation (annotations used on other annotations) |
||||
* used for indicating that instead of using target annotation |
||||
* (annotation annotated with this annotation), |
||||
* Jackson should use meta-annotations it has. |
||||
* This can be useful in creating "combo-annotations" by having |
||||
* a container annotation, which needs to be annotated with this |
||||
* annotation as well as all annotations it 'contains'. |
||||
* |
||||
* @since 2.0 |
||||
*/ |
||||
@Target({ElementType.ANNOTATION_TYPE}) |
||||
@Retention(RetentionPolicy.RUNTIME) |
||||
@JacksonAnnotation |
||||
public @interface JacksonAnnotationsInside |
||||
{ |
||||
|
||||
} |
@ -0,0 +1,28 @@
|
||||
package com.fr.third.fasterxml.jackson.annotation; |
||||
|
||||
import java.lang.annotation.ElementType; |
||||
import java.lang.annotation.Retention; |
||||
import java.lang.annotation.RetentionPolicy; |
||||
import java.lang.annotation.Target; |
||||
|
||||
import com.fr.third.fasterxml.jackson.annotation.JacksonAnnotation; |
||||
|
||||
/** |
||||
* Jackson-specific annotation used for indicating that value of |
||||
* annotated property will be "injected", i.e. set based on value |
||||
* configured by <code>ObjectMapper</code> (usually on per-call basis). |
||||
* Usually property is not deserialized from JSON, although it possible |
||||
* to have injected value as default and still allow optional override |
||||
* from JSON. |
||||
*/ |
||||
@Target({ElementType.ANNOTATION_TYPE, ElementType.METHOD, ElementType.FIELD, ElementType.PARAMETER}) |
||||
@Retention(RetentionPolicy.RUNTIME) |
||||
@JacksonAnnotation |
||||
public @interface JacksonInject |
||||
{ |
||||
/** |
||||
* Logical id of the value to inject; if not specified (or specified |
||||
* as empty String), will use id based on declared type of property. |
||||
*/ |
||||
public String value() default ""; |
||||
} |
@ -0,0 +1,23 @@
|
||||
package com.fr.third.fasterxml.jackson.annotation; |
||||
|
||||
import java.lang.annotation.ElementType; |
||||
import java.lang.annotation.Retention; |
||||
import java.lang.annotation.RetentionPolicy; |
||||
import java.lang.annotation.Target; |
||||
|
||||
/** |
||||
* Marker annotation that can be used to define a non-static, |
||||
* no-argument method or member field as something of a reverse of |
||||
* {@link JsonAnySetter} method; basically being used like a |
||||
* getter but such that contents of the returned Map (type <b>must</b> be |
||||
* {@link java.util.Map}) are serialized as if they were actual properties |
||||
* of the bean that contains method/field with this annotations. |
||||
* As with {@link JsonAnySetter}, only one property should be annotated |
||||
* with this annotation. |
||||
*/ |
||||
@Target({ElementType.ANNOTATION_TYPE, ElementType.METHOD}) |
||||
@Retention(RetentionPolicy.RUNTIME) |
||||
@JacksonAnnotation |
||||
public @interface JsonAnyGetter |
||||
{ |
||||
} |
@ -0,0 +1,25 @@
|
||||
package com.fr.third.fasterxml.jackson.annotation; |
||||
|
||||
import java.lang.annotation.ElementType; |
||||
import java.lang.annotation.Retention; |
||||
import java.lang.annotation.RetentionPolicy; |
||||
import java.lang.annotation.Target; |
||||
|
||||
/** |
||||
* Marker annotation that can be used to define a non-static, |
||||
* two-argument method (first argument name of property, second value |
||||
* to set), to be used as a "fallback" handler |
||||
* for all otherwise unrecognized properties found from JSON content. |
||||
* It is similar to {@link javax.xml.bind.annotation.XmlAnyElement} |
||||
* in behavior; and can only be used to denote a single property |
||||
* per type. |
||||
*<p> |
||||
* If used, all otherwise unmapped key-value pairs from JSON Object values |
||||
* are added to the property (of type Map or bean). |
||||
*/ |
||||
@Target({ElementType.ANNOTATION_TYPE, ElementType.METHOD}) |
||||
@Retention(RetentionPolicy.RUNTIME) |
||||
@JacksonAnnotation |
||||
public @interface JsonAnySetter |
||||
{ |
||||
} |
@ -0,0 +1,126 @@
|
||||
package com.fr.third.fasterxml.jackson.annotation; |
||||
|
||||
import java.lang.annotation.ElementType; |
||||
import java.lang.annotation.Retention; |
||||
import java.lang.annotation.RetentionPolicy; |
||||
import java.lang.annotation.Target; |
||||
import java.lang.reflect.Member; |
||||
import java.lang.reflect.Modifier; |
||||
|
||||
/** |
||||
* Class annotation that can be used to define which kinds of Methods |
||||
* are to be detected by auto-detection. |
||||
* Auto-detection means using name conventions |
||||
* and/or signature templates to find methods to use for data binding. |
||||
* For example, so-called "getters" can be auto-detected by looking for |
||||
* public member methods that return a value, do not take argument, |
||||
* and have prefix "get" in their name. |
||||
*<p> |
||||
* Pseudo-value <code>NONE</code> means that all auto-detection is disabled |
||||
* for the <b>specific</b> class that annotation is applied to (including |
||||
* its super-types, but only when resolving that class). |
||||
* Pseudo-value <code>ALWAYS</code> means that auto-detection is enabled |
||||
* for all method types for the class in similar way. |
||||
*<p> |
||||
* The default value is <code>ALWAYS</code>: that is, by default, auto-detection |
||||
* is enabled for all classes unless instructed otherwise. |
||||
*<p> |
||||
* Starting with version 1.5, it is also possible to use more fine-grained |
||||
* definitions, to basically define minimum visibility level needed. Defaults |
||||
* are different for different types (getters need to be public; setters can |
||||
* have any access modifier, for example). |
||||
*/ |
||||
@Target({ElementType.ANNOTATION_TYPE, ElementType.TYPE}) |
||||
@Retention(RetentionPolicy.RUNTIME) |
||||
@JacksonAnnotation |
||||
public @interface JsonAutoDetect |
||||
{ |
||||
/** |
||||
* Enumeration for possible visibility thresholds (minimum visibility) |
||||
* that can be used to limit which methods (and fields) are |
||||
* auto-detected. |
||||
*/ |
||||
public enum Visibility { |
||||
/** |
||||
* Value that means that all kinds of access modifiers are acceptable, |
||||
* from private to public. |
||||
*/ |
||||
ANY, |
||||
/** |
||||
* Value that means that any other access modifier other than 'private' |
||||
* is considered auto-detectable. |
||||
*/ |
||||
NON_PRIVATE, |
||||
/** |
||||
* Value that means access modifiers 'protected' and 'public' are |
||||
* auto-detectable (and 'private' and "package access" == no modifiers |
||||
* are not) |
||||
*/ |
||||
PROTECTED_AND_PUBLIC, |
||||
/** |
||||
* Value to indicate that only 'public' access modifier is considered |
||||
* auto-detectable. |
||||
*/ |
||||
PUBLIC_ONLY, |
||||
/** |
||||
* Value that indicates that no access modifiers are auto-detectable: |
||||
* this can be used to explicitly disable auto-detection for specified |
||||
* types. |
||||
*/ |
||||
NONE, |
||||
|
||||
/** |
||||
* Value that indicates that default visibility level (whatever it is, |
||||
* depends on context) is to be used. This usually means that inherited |
||||
* value (from parent visibility settings) is to be used. |
||||
*/ |
||||
DEFAULT; |
||||
|
||||
public boolean isVisible(Member m) { |
||||
switch (this) { |
||||
case ANY: |
||||
return true; |
||||
case NONE: |
||||
return false; |
||||
case NON_PRIVATE: |
||||
return !Modifier.isPrivate(m.getModifiers()); |
||||
case PROTECTED_AND_PUBLIC: |
||||
if (Modifier.isProtected(m.getModifiers())) { |
||||
return true; |
||||
} |
||||
// fall through to public case:
|
||||
case PUBLIC_ONLY: |
||||
return Modifier.isPublic(m.getModifiers()); |
||||
default: |
||||
return false; |
||||
} |
||||
} |
||||
} |
||||
|
||||
/** |
||||
* Minimum visibility required for auto-detecting regular getter methods. |
||||
*/ |
||||
Visibility getterVisibility() default Visibility.DEFAULT; |
||||
|
||||
/** |
||||
* Minimum visibility required for auto-detecting is-getter methods. |
||||
*/ |
||||
Visibility isGetterVisibility() default Visibility.DEFAULT; |
||||
|
||||
/** |
||||
* Minimum visibility required for auto-detecting setter methods. |
||||
*/ |
||||
Visibility setterVisibility() default Visibility.DEFAULT; |
||||
|
||||
/** |
||||
* Minimum visibility required for auto-detecting Creator methods, |
||||
* except for no-argument constructors (which are always detected |
||||
* no matter what). |
||||
*/ |
||||
Visibility creatorVisibility() default Visibility.DEFAULT; |
||||
|
||||
/** |
||||
* Minimum visibility required for auto-detecting member fields. |
||||
*/ |
||||
Visibility fieldVisibility() default Visibility.DEFAULT; |
||||
} |
@ -0,0 +1,39 @@
|
||||
package com.fr.third.fasterxml.jackson.annotation; |
||||
|
||||
import java.lang.annotation.ElementType; |
||||
import java.lang.annotation.Retention; |
||||
import java.lang.annotation.RetentionPolicy; |
||||
import java.lang.annotation.Target; |
||||
|
||||
/** |
||||
* Annotation used to indicate that associated property is part of |
||||
* two-way linkage between fields; and that its role is "child" (or "back") link. |
||||
* Value type of the property must be a bean: it can not be a Collection, Map, |
||||
* Array or enumeration. |
||||
* Linkage is handled such that the property |
||||
* annotated with this annotation is not serialized; and during deserialization, |
||||
* its value is set to instance that has the "managed" (forward) link. |
||||
*<p> |
||||
* All references have logical name to allow handling multiple linkages; typical case |
||||
* would be that where nodes have both parent/child and sibling linkages. If so, |
||||
* pairs of references should be named differently. |
||||
* It is an error for a class to have multiple back references with same name, |
||||
* even if types pointed are different. |
||||
*<p> |
||||
* Note: only methods and fields can be annotated with this annotation: constructor |
||||
* arguments should NOT be annotated, as they can not be either managed or back |
||||
* references. |
||||
*/ |
||||
@Target({ElementType.ANNOTATION_TYPE, ElementType.FIELD, ElementType.METHOD}) |
||||
@Retention(RetentionPolicy.RUNTIME) |
||||
@JacksonAnnotation |
||||
public @interface JsonBackReference |
||||
{ |
||||
/** |
||||
* Logical have for the reference property pair; used to link managed and |
||||
* back references. Default name can be used if there is just single |
||||
* reference pair (for example, node class that just has parent/child linkage, |
||||
* consisting of one managed reference and matching back reference) |
||||
*/ |
||||
public String value() default "defaultReference"; |
||||
} |
@ -0,0 +1,36 @@
|
||||
package com.fr.third.fasterxml.jackson.annotation; |
||||
|
||||
import java.lang.annotation.ElementType; |
||||
import java.lang.annotation.Retention; |
||||
import java.lang.annotation.RetentionPolicy; |
||||
import java.lang.annotation.Target; |
||||
|
||||
/** |
||||
* Marker annotation that can be used to define constructors and factory |
||||
* methods as one to use for instantiating new instances of the associated |
||||
* class. |
||||
*<p> |
||||
* NOTE: when annotating creator methods (constructors, factory methods), |
||||
* method must either be: |
||||
*<ul> |
||||
* <li>Single-argument constructor/factory method without {@link JsonProperty} |
||||
* annotation for the argument: if so, this is so-called "delegate creator", |
||||
* in which case Jackson first binds JSON into type of the argument, and |
||||
* then calls creator |
||||
* </li> |
||||
* <li>Constructor/factory method where <b>every argument</b> is annotated with |
||||
* either {@link JsonProperty} or {@link JacksonInject}, to indicate name |
||||
* of property to bind to |
||||
* </li> |
||||
* </ul> |
||||
* Also note that all {@link JsonProperty} annotations MUST use actual name |
||||
* (NOT empty String for "default"): this because Java bytecode does not |
||||
* retain names of method or constructor arguments. |
||||
*/ |
||||
@Target({ElementType.ANNOTATION_TYPE, ElementType.METHOD, ElementType.CONSTRUCTOR}) |
||||
@Retention(RetentionPolicy.RUNTIME) |
||||
@JacksonAnnotation |
||||
public @interface JsonCreator |
||||
{ |
||||
// no values, since there's no property
|
||||
} |
@ -0,0 +1,33 @@
|
||||
package com.fr.third.fasterxml.jackson.annotation; |
||||
|
||||
import java.lang.annotation.ElementType; |
||||
import java.lang.annotation.Retention; |
||||
import java.lang.annotation.RetentionPolicy; |
||||
import java.lang.annotation.Target; |
||||
|
||||
/** |
||||
* Annotation used to indicate which logical filter is to be used |
||||
* for filtering out properties of type (class) annotated; |
||||
* association made by this annotation declaring ids of filters, |
||||
* and <code>com.fr.third.fasterxml.jackson.databind.ObjectMapper</code> (or objects |
||||
* it delegates to) providing matching filters by id. |
||||
*<p> |
||||
* Filters to use are usually of type |
||||
* <code>com.fr.third.fasterxml.jackson.databind.ser.BeanPropertyFilter</code> and |
||||
* are registered through <code>com.fr.third.fasterxml.jackson.databind.ObjectMapper</code> |
||||
*<p> |
||||
* Since 2.3, this annotation can also be used on properties (fields, methods, |
||||
* constructor parameters). |
||||
*/ |
||||
@Target({ElementType.ANNOTATION_TYPE, ElementType.TYPE, |
||||
ElementType.METHOD, ElementType.FIELD, ElementType.PARAMETER // new in 2.3
|
||||
}) |
||||
@Retention(RetentionPolicy.RUNTIME) |
||||
@com.fr.third.fasterxml.jackson.annotation.JacksonAnnotation |
||||
public @interface JsonFilter |
||||
{ |
||||
/** |
||||
* Id of filter to use; if empty String (""), no filter is to be used. |
||||
*/ |
||||
public String value(); |
||||
} |
@ -0,0 +1,252 @@
|
||||
package com.fr.third.fasterxml.jackson.annotation; |
||||
|
||||
import java.lang.annotation.ElementType; |
||||
import java.lang.annotation.Retention; |
||||
import java.lang.annotation.RetentionPolicy; |
||||
import java.lang.annotation.Target; |
||||
import java.util.Locale; |
||||
import java.util.TimeZone; |
||||
|
||||
/** |
||||
* General-purpose annotation used for configuring details of how |
||||
* values of properties are to be serialized. |
||||
* Unlike most other Jackson annotations, annotation does not |
||||
* have specific universal interpretation: instead, effect depends on datatype |
||||
* of property being annotated (or more specifically, deserializer |
||||
* and serializer being used). |
||||
*<p> |
||||
* Common uses include choosing between alternate representations -- for example, |
||||
* whether {@link java.util.Date} is to be serialized as number (Java timestamp) |
||||
* or String (such as ISO-8601 compatible time value) -- as well as configuring |
||||
* exact details with {@link #pattern} property. |
||||
*<p> |
||||
* As of Jackson 2.1, known special handling include: |
||||
*<ul> |
||||
* <li>{@link java.util.Date}: Shape can be {@link Shape#STRING} or {@link Shape#NUMBER}; |
||||
* pattern may contain {@link java.text.SimpleDateFormat}-compatible pattern definition. |
||||
* </li> |
||||
*</ul> |
||||
* Jackson 2.1 added following new features: |
||||
*<ul> |
||||
* <li>Can now be used on Classes (types) as well, for modified default behavior, possibly |
||||
* overridden by per-property annotation |
||||
* </li> |
||||
* <li>{@link java.lang.Enum}s: Shapes {@link Shape#STRING} and {@link Shape#NUMBER} can be |
||||
* used to change between numeric (index) and textual (name or <code>toString()</code>); |
||||
* but it is also possible to use {@link Shape#OBJECT} to serialize (but not deserialize) |
||||
* {@link java.lang.Enum}s as JSON Objects (as if they were POJOs). NOTE: serialization |
||||
* as JSON Object only works with class annotation; |
||||
* will not work as per-property annotation. |
||||
* </li> |
||||
* <li>{@link java.util.Collection}s can be serialized as (and deserialized from) JSON Objects, |
||||
* if {@link Shape#OBJECT} is used. NOTE: can ONLY be used as class annotation; |
||||
* will not work as per-property annotation. |
||||
* </li> |
||||
*</ul> |
||||
* |
||||
* @since 2.0 |
||||
*/ |
||||
@Target({ElementType.ANNOTATION_TYPE, ElementType.FIELD, ElementType.METHOD, ElementType.PARAMETER, |
||||
ElementType.TYPE}) |
||||
@Retention(RetentionPolicy.RUNTIME) |
||||
@JacksonAnnotation |
||||
public @interface JsonFormat |
||||
{ |
||||
/** |
||||
* Value that indicates that default {@link java.util.Locale} |
||||
* (from deserialization or serialization context) should be used: |
||||
* annotation does not define value to use. |
||||
*/ |
||||
public final static String DEFAULT_LOCALE = "##default"; |
||||
|
||||
/** |
||||
* Value that indicates that default {@link java.util.TimeZone} |
||||
* (from deserialization or serialization context) should be used: |
||||
* annotation does not define value to use. |
||||
*/ |
||||
public final static String DEFAULT_TIMEZONE = "##default"; |
||||
|
||||
/** |
||||
* Datatype-specific additional piece of configuration that may be used |
||||
* to further refine formatting aspects. This may, for example, determine |
||||
* low-level format String used for {@link java.util.Date} serialization; |
||||
* however, exact use is determined by specific <code>JsonSerializer</code> |
||||
*/ |
||||
public String pattern() default ""; |
||||
|
||||
/** |
||||
* Structure to use for serialization: definition of mapping depends on datatype, |
||||
* but usually has straight-forward counterpart in data format (JSON). |
||||
* Note that commonly only a subset of shapes is available; and if 'invalid' value |
||||
* is chosen, defaults are usually used. |
||||
*/ |
||||
public Shape shape() default Shape.ANY; |
||||
|
||||
/** |
||||
* {@link java.util.Locale} to use for serialization (if needed). |
||||
* Special value of {@link #DEFAULT_LOCALE} |
||||
* can be used to mean "just use the default", where default is specified |
||||
* by the serialization context, which in turn defaults to system |
||||
* defaults ({@link java.util.Locale#getDefault()}) unless explicitly |
||||
* set to another locale. |
||||
*/ |
||||
public String locale() default DEFAULT_LOCALE; |
||||
|
||||
/** |
||||
* {@link java.util.TimeZone} to use for serialization (if needed). |
||||
* Special value of {@link #DEFAULT_TIMEZONE} |
||||
* can be used to mean "just use the default", where default is specified |
||||
* by the serialization context, which in turn defaults to system |
||||
* defaults ({@link java.util.TimeZone#getDefault()}) unless explicitly |
||||
* set to another locale. |
||||
*/ |
||||
public String timezone() default DEFAULT_TIMEZONE; |
||||
|
||||
/* |
||||
/********************************************************** |
||||
/* Value enumeration(s), value class(es) |
||||
/********************************************************** |
||||
*/ |
||||
|
||||
/** |
||||
* Value enumeration used for indicating preferred Shape; translates |
||||
* loosely to JSON types, with some extra values to indicate less precise |
||||
* choices (i.e. allowing one of multiple actual shapes) |
||||
*/ |
||||
public enum Shape |
||||
{ |
||||
/** |
||||
* Marker enum value that indicates "default" (or "whatever") choice; needed |
||||
* since Annotations can not have null values for enums. |
||||
*/ |
||||
ANY, |
||||
|
||||
/** |
||||
* Value that indicates shape should not be structural (that is, not |
||||
* {@link #ARRAY} or {@link #OBJECT}, but can be any other shape. |
||||
*/ |
||||
SCALAR, |
||||
|
||||
/** |
||||
* Value that indicates that (JSON) Array type should be used. |
||||
*/ |
||||
ARRAY, |
||||
|
||||
/** |
||||
* Value that indicates that (JSON) Object type should be used. |
||||
*/ |
||||
OBJECT, |
||||
|
||||
/** |
||||
* Value that indicates that a numeric (JSON) type should be used |
||||
* (but does not specify whether integer or floating-point representation |
||||
* should be used) |
||||
*/ |
||||
NUMBER, |
||||
|
||||
/** |
||||
* Value that indicates that floating-point numeric type should be used |
||||
*/ |
||||
NUMBER_FLOAT, |
||||
|
||||
/** |
||||
* Value that indicates that integer number type should be used |
||||
* (and not {@link #NUMBER_FLOAT}). |
||||
*/ |
||||
NUMBER_INT, |
||||
|
||||
/** |
||||
* Value that indicates that (JSON) String type should be used. |
||||
*/ |
||||
STRING, |
||||
|
||||
/** |
||||
* Value that indicates that (JSON) boolean type |
||||
* (true, false) should be used. |
||||
*/ |
||||
BOOLEAN |
||||
; |
||||
|
||||
public boolean isNumeric() { |
||||
return (this == NUMBER) || (this == NUMBER_INT) || (this == NUMBER_FLOAT); |
||||
} |
||||
|
||||
public boolean isStructured() { |
||||
return (this == OBJECT) || (this == ARRAY); |
||||
} |
||||
} |
||||
|
||||
/** |
||||
* Helper class used to contain information from a single {@link JsonFormat} |
||||
* annotation. |
||||
*/ |
||||
public static class Value |
||||
{ |
||||
private final String pattern; |
||||
private final Shape shape; |
||||
private final Locale locale; |
||||
private final TimeZone timezone; |
||||
|
||||
public Value() { |
||||
this("", Shape.ANY, "", ""); |
||||
} |
||||
|
||||
public Value(JsonFormat ann) { |
||||
this(ann.pattern(), ann.shape(), ann.locale(), ann.timezone()); |
||||
} |
||||
|
||||
public Value(String p, Shape sh, String localeStr, String tzStr) |
||||
{ |
||||
this(p, sh |
||||
,(localeStr == null || localeStr.length() == 0 || DEFAULT_LOCALE.equals(localeStr)) ? |
||||
null : new Locale(localeStr) |
||||
,(tzStr == null || tzStr.length() == 0 || DEFAULT_TIMEZONE.equals(tzStr)) ? |
||||
null : TimeZone.getTimeZone(tzStr) |
||||
); |
||||
} |
||||
|
||||
/** |
||||
* @since 2.1 |
||||
*/ |
||||
public Value(String p, Shape sh, Locale l, TimeZone tz) |
||||
{ |
||||
pattern = p; |
||||
shape = sh; |
||||
locale = l; |
||||
timezone = tz; |
||||
} |
||||
|
||||
/** |
||||
* @since 2.1 |
||||
*/ |
||||
public Value withPattern(String p) { |
||||
return new Value(p, shape, locale, timezone); |
||||
} |
||||
|
||||
/** |
||||
* @since 2.1 |
||||
*/ |
||||
public Value withShape(Shape s) { |
||||
return new Value(pattern, s, locale, timezone); |
||||
} |
||||
|
||||
/** |
||||
* @since 2.1 |
||||
*/ |
||||
public Value withLocale(Locale l) { |
||||
return new Value(pattern, shape, l, timezone); |
||||
} |
||||
|
||||
/** |
||||
* @since 2.1 |
||||
*/ |
||||
public Value withTimeZone(TimeZone tz) { |
||||
return new Value(pattern, shape, locale, tz); |
||||
} |
||||
|
||||
public String getPattern() { return pattern; } |
||||
public Shape getShape() { return shape; } |
||||
public Locale getLocale() { return locale; } |
||||
public TimeZone getTimeZone() { return timezone; } |
||||
} |
||||
} |
@ -0,0 +1,33 @@
|
||||
package com.fr.third.fasterxml.jackson.annotation; |
||||
|
||||
import java.lang.annotation.ElementType; |
||||
import java.lang.annotation.Retention; |
||||
import java.lang.annotation.RetentionPolicy; |
||||
import java.lang.annotation.Target; |
||||
|
||||
/** |
||||
* Marker annotation that can be used to define a non-static, |
||||
* no-argument value-returning (non-void) method to be used as a "getter" |
||||
* for a logical property. |
||||
* It can be used as an alternative to more general |
||||
* {@link JsonProperty} annotation (which is the recommended choice in |
||||
* general case). |
||||
*<p> |
||||
* Getter means that when serializing Object instance of class that has |
||||
* this method (possibly inherited from a super class), a call is made |
||||
* through the method, and return value will be serialized as value of |
||||
* the property. |
||||
*/ |
||||
@Target({ElementType.ANNOTATION_TYPE, ElementType.METHOD}) |
||||
@Retention(RetentionPolicy.RUNTIME) |
||||
@JacksonAnnotation |
||||
public @interface JsonGetter |
||||
{ |
||||
/** |
||||
* Defines name of the logical property this |
||||
* method is used to access ("get"); empty String means that |
||||
* name should be derived from the underlying method (using |
||||
* standard Bean name detection rules) |
||||
*/ |
||||
String value() default ""; |
||||
} |
@ -0,0 +1,75 @@
|
||||
package com.fr.third.fasterxml.jackson.annotation; |
||||
|
||||
import java.lang.annotation.ElementType; |
||||
import java.lang.annotation.Retention; |
||||
import java.lang.annotation.RetentionPolicy; |
||||
import java.lang.annotation.Target; |
||||
|
||||
/** |
||||
* Annotation used for indicating that values of annotated type |
||||
* or property should be serializing so that instances either |
||||
* contain additional object identifier (in addition actual object |
||||
* properties), or as a reference that consists of an object id |
||||
* that refers to a full serialization. In practice this is done |
||||
* by serializing the first instance as full object and object |
||||
* identity, and other references to the object as reference values. |
||||
*<p> |
||||
* There are two main approaches to generating object identifier: |
||||
* either using a generator (either one of standard ones, or a custom |
||||
* generator), or using a value of a property. The latter case is |
||||
* indicated by using a placeholder generator marker |
||||
* {@link ObjectIdGenerators.PropertyGenerator}; former by using explicit generator. |
||||
* Object id has to be serialized as a property in case of POJOs; |
||||
* object identity is currently NOT support for JSON Array types |
||||
* (Java arrays or Lists) or Java Map types. |
||||
*<p> |
||||
* Finally, note that generator type of {@link ObjectIdGenerators.None} |
||||
* indicates that no Object Id should be included or used: it is included |
||||
* to allow suppressing Object Ids using mix-in annotations. |
||||
* |
||||
* @since 2.0 |
||||
*/ |
||||
@Target({ElementType.ANNOTATION_TYPE, ElementType.TYPE, |
||||
ElementType.FIELD, ElementType.METHOD, ElementType.PARAMETER}) |
||||
@Retention(RetentionPolicy.RUNTIME) |
||||
@JacksonAnnotation |
||||
public @interface JsonIdentityInfo |
||||
{ |
||||
/** |
||||
* Name of JSON property in which Object Id will reside: also, |
||||
* if "from property" marker generator is used, identifies |
||||
* property that will be accessed to get type id. |
||||
* If a property is used, name must match its external |
||||
* name (one defined by annotation, or derived from accessor |
||||
* name as per Java Bean Introspection rules). |
||||
*<p> |
||||
* Default value is <code>@id</code>. |
||||
*/ |
||||
public String property() default "@id"; |
||||
|
||||
/** |
||||
* Generator to use for producing Object Identifier for objects: |
||||
* either one of pre-defined generators from |
||||
* {@link ObjectIdGenerator}, or a custom generator. |
||||
* Defined as class to instantiate. |
||||
*<p> |
||||
* Note that special type |
||||
* {@link ObjectIdGenerators.None} |
||||
* can be used to disable inclusion of Object Ids. |
||||
*/ |
||||
public Class<? extends ObjectIdGenerator<?>> generator(); |
||||
|
||||
/** |
||||
* Scope is used to define applicability of an Object Id: all ids |
||||
* must be unique within their scope; where scope is defined |
||||
* as combination of this value and generator type. |
||||
* Comparison is simple equivalence, meaning that both type |
||||
* generator type and scope class must be the same. |
||||
*<p> |
||||
* Scope is used for determining how many generators are needed; |
||||
* more than one scope is typically only needed if external Object Ids |
||||
* have overlapping value domains (i.e. are only unique within some |
||||
* limited scope) |
||||
*/ |
||||
public Class<?> scope() default Object.class; |
||||
} |
@ -0,0 +1,35 @@
|
||||
package com.fr.third.fasterxml.jackson.annotation; |
||||
|
||||
import java.lang.annotation.ElementType; |
||||
import java.lang.annotation.Retention; |
||||
import java.lang.annotation.RetentionPolicy; |
||||
import java.lang.annotation.Target; |
||||
|
||||
/** |
||||
* Optional annotation that can be used for customizing details of a reference |
||||
* to Objects for which "Object Identity" is enabled (see {@link JsonIdentityInfo}). |
||||
* The main use case is that of enforcing use of Object Id even for the first |
||||
* time an Object is referenced, instead of first instance being serialized |
||||
* as full POJO. |
||||
* |
||||
* @since 2.1 |
||||
*/ |
||||
@Target({ElementType.ANNOTATION_TYPE, ElementType.TYPE, |
||||
ElementType.FIELD, ElementType.METHOD, ElementType.PARAMETER}) |
||||
@Retention(RetentionPolicy.RUNTIME) |
||||
@JacksonAnnotation |
||||
public @interface JsonIdentityReference |
||||
{ |
||||
/** |
||||
* Marker to indicate whether all referenced values are to |
||||
* be serialized as ids (true); or by serializing the |
||||
* first encountered reference as POJO and only then as id (false). |
||||
*<p> |
||||
* Note that if value of 'true' is used, deserialization may require |
||||
* additional contextual information, and possibly using a custom |
||||
* id resolver -- the default handling may not be sufficient. |
||||
* |
||||
* @since 2.1 |
||||
*/ |
||||
public boolean alwaysAsId() default false; |
||||
} |
@ -0,0 +1,58 @@
|
||||
package com.fr.third.fasterxml.jackson.annotation; |
||||
|
||||
import java.lang.annotation.ElementType; |
||||
import java.lang.annotation.Retention; |
||||
import java.lang.annotation.RetentionPolicy; |
||||
import java.lang.annotation.Target; |
||||
|
||||
/** |
||||
* Marker annotation that indicates that the annotated method or field is to be |
||||
* ignored by introspection-based |
||||
* serialization and deserialization functionality. That is, it should |
||||
* not be consider a "getter", "setter" or "creator". |
||||
*<p> |
||||
* In addition, starting with Jackson 1.9, if this is the only annotation |
||||
* associated with a property, it will also cause cause the whole |
||||
* property to be ignored: that is, if setter has this annotation and |
||||
* getter has no annotations, getter is also effectively ignored. |
||||
* It is still possible for different accessors to use different |
||||
* annotations; so if only "getter" is to be ignored, other accessors |
||||
* (setter or field) would need explicit annotation to prevent |
||||
* ignoral (usually {@link JsonProperty}). |
||||
* <p> |
||||
* For example, a "getter" method that would otherwise denote |
||||
* a property (like, say, "getValue" to suggest property "value") |
||||
* to serialize, would be ignored and no such property would |
||||
* be output unless another annotation defines alternative method to use. |
||||
*<p> |
||||
* Before version 1.9, this annotation worked purely on method-by-method (or field-by-field) |
||||
* basis; annotation on one method or field did not imply ignoring other methods |
||||
* or fields. However, with version 1.9 and above, annotations associated |
||||
* with various accessors (getter, setter, field, constructor parameter) of |
||||
* a logical property are combined; meaning that annotations in one (say, setter) |
||||
* can have effects on all of them (if getter or field has nothing indicating |
||||
* otherwise). |
||||
*<p> |
||||
* Annotation is usually used just a like a marker annotation, that |
||||
* is, without explicitly defining 'value' argument (which defaults |
||||
* to <code>true</code>): but argument can be explicitly defined. |
||||
* This can be done to override an existing JsonIgnore by explicitly |
||||
* defining one with 'false' argument. |
||||
*<p> |
||||
* Annotation is similar to {@link javax.xml.bind.annotation.XmlTransient} |
||||
*/ |
||||
@Target({ElementType.ANNOTATION_TYPE, ElementType.METHOD, ElementType.CONSTRUCTOR, ElementType.FIELD}) |
||||
@Retention(RetentionPolicy.RUNTIME) |
||||
@JacksonAnnotation |
||||
public @interface JsonIgnore |
||||
{ |
||||
/** |
||||
* Optional argument that defines whether this annotation is active |
||||
* or not. The only use for value 'false' if for overriding purposes |
||||
* (which is not needed often); most likely it is needed for use |
||||
* with "mix-in annotations" (aka "annotation overrides"). |
||||
* For most cases, however, default value of "true" is just fine |
||||
* and should be omitted. |
||||
*/ |
||||
boolean value() default true; |
||||
} |
@ -0,0 +1,51 @@
|
||||
package com.fr.third.fasterxml.jackson.annotation; |
||||
|
||||
import java.lang.annotation.ElementType; |
||||
import java.lang.annotation.Retention; |
||||
import java.lang.annotation.RetentionPolicy; |
||||
import java.lang.annotation.Target; |
||||
|
||||
/** |
||||
* Annotation that can be used to either suppress serialization of |
||||
* properties (during serialization), or ignore processing of |
||||
* JSON properties read (during deserialization). |
||||
*<p> |
||||
* Example: |
||||
*<pre> |
||||
* // to prevent specified fields from being serialized or deserialized
|
||||
* // (i.e. not include in JSON output; or being set even if they were included)
|
||||
* @JsonIgnoreProperties({ "internalId", "secretKey" }) |
||||
* // To ignore any unknown properties in JSON input without exception:
|
||||
* @JsonIgnoreProperties(ignoreUnknown=true) |
||||
*</pre> |
||||
*<p> |
||||
* Starting with 2.0, this annotation can be applied both to classes and |
||||
* to properties. If used for both, actual set will be union of all |
||||
* ignorals: that is, you can only add properties to ignore, not remove |
||||
* or override. So you can not remove properties to ignore using |
||||
* per-property annotation. |
||||
*/ |
||||
@Target({ElementType.ANNOTATION_TYPE, ElementType.TYPE, |
||||
ElementType.METHOD, ElementType.CONSTRUCTOR, ElementType.FIELD}) |
||||
@Retention(RetentionPolicy.RUNTIME) |
||||
@JacksonAnnotation |
||||
public @interface JsonIgnoreProperties |
||||
{ |
||||
/** |
||||
* Names of properties to ignore. |
||||
*/ |
||||
public String[] value() default { }; |
||||
|
||||
/** |
||||
* Property that defines whether it is ok to just ignore any |
||||
* unrecognized properties during deserialization. |
||||
* If true, all properties that are unrecognized -- that is, |
||||
* there are no setters or creators that accept them -- are |
||||
* ignored without warnings (although handlers for unknown |
||||
* properties, if any, will still be called) without |
||||
* exception. |
||||
*<p> |
||||
* Does not have any effect on serialization. |
||||
*/ |
||||
public boolean ignoreUnknown() default false; |
||||
} |
@ -0,0 +1,31 @@
|
||||
package com.fr.third.fasterxml.jackson.annotation; |
||||
|
||||
import java.lang.annotation.ElementType; |
||||
import java.lang.annotation.Retention; |
||||
import java.lang.annotation.RetentionPolicy; |
||||
import java.lang.annotation.Target; |
||||
|
||||
/** |
||||
* Marker annotation that indicates that all properties of annotated |
||||
* type are to be ignored during serialization and deserialization. |
||||
*<p> |
||||
* Note: annotation does have boolean 'value' property (which defaults |
||||
* to 'true'), so that it is actually possible to override value |
||||
* using mix-in annotations. |
||||
*/ |
||||
@Target({ElementType.ANNOTATION_TYPE, ElementType.TYPE}) |
||||
@Retention(RetentionPolicy.RUNTIME) |
||||
@JacksonAnnotation |
||||
public @interface JsonIgnoreType |
||||
{ |
||||
/** |
||||
* Optional argument that defines whether this annotation is active |
||||
* or not. The only use for value 'false' if for overriding purposes |
||||
* (which is not needed often); most likely it is needed for use |
||||
* with "mix-in annotations" ("annotation overrides"). |
||||
* For most cases, however, default value of "true" is just fine |
||||
* and should be omitted. |
||||
*/ |
||||
boolean value() default true; |
||||
|
||||
} |
@ -0,0 +1,96 @@
|
||||
package com.fr.third.fasterxml.jackson.annotation; |
||||
|
||||
import java.lang.annotation.ElementType; |
||||
import java.lang.annotation.Retention; |
||||
import java.lang.annotation.RetentionPolicy; |
||||
import java.lang.annotation.Target; |
||||
|
||||
/** |
||||
* Annotation used to indicate when value of the annotated property (when |
||||
* used for a field, method or constructor parameter), or all |
||||
* properties of the annotated class, is to be serialized. |
||||
* Without annotation property values are always included, but by using |
||||
* this annotation one can specify simple exclusion rules to reduce |
||||
* amount of properties to write out. |
||||
* |
||||
* @since 2.0 |
||||
*/ |
||||
@Target({ElementType.ANNOTATION_TYPE, ElementType.METHOD, ElementType.FIELD, |
||||
ElementType.TYPE, ElementType.PARAMETER}) |
||||
@Retention(RetentionPolicy.RUNTIME) |
||||
@com.fr.third.fasterxml.jackson.annotation.JacksonAnnotation |
||||
public @interface JsonInclude |
||||
{ |
||||
/** |
||||
* Inclusion rule to use. |
||||
*/ |
||||
public Include value() default Include.ALWAYS; |
||||
|
||||
/* |
||||
/********************************************************** |
||||
/* Value enumerations needed |
||||
/********************************************************** |
||||
*/ |
||||
|
||||
/** |
||||
* Enumeration used with {@link JsonInclude} |
||||
* to define which properties |
||||
* of Java Beans are to be included in serialization. |
||||
*<p> |
||||
* Note: Jackson 1.x had similarly named ("Inclusion") enumeration included |
||||
* in <code>JsonSerialize</code> annotation: it is not deprecated |
||||
* and this value used instead. |
||||
*/ |
||||
public enum Include |
||||
{ |
||||
/** |
||||
* Value that indicates that property is to be always included, |
||||
* independent of value of the property. |
||||
*/ |
||||
ALWAYS, |
||||
|
||||
/** |
||||
* Value that indicates that only properties with non-null |
||||
* values are to be included. |
||||
*/ |
||||
NON_NULL, |
||||
|
||||
/** |
||||
* Value that indicates that only properties that have values |
||||
* that differ from default settings (meaning values they have |
||||
* when Bean is constructed with its no-arguments constructor) |
||||
* are to be included. Value is generally not useful with |
||||
* {@link java.util.Map}s, since they have no default values; |
||||
* and if used, works same as {@link #ALWAYS}. |
||||
*/ |
||||
NON_DEFAULT, |
||||
|
||||
/** |
||||
* Value that indicates that only properties that have values |
||||
* that values that are null or what is considered empty are |
||||
* not to be included. |
||||
*<p> |
||||
* Default emptiness is defined for following type: |
||||
*<ul> |
||||
* <li>For {@link java.util.Collection}s and {@link java.util.Map}s, |
||||
* method <code>isEmpty()</code> is called; |
||||
* </li> |
||||
* <li>For Java arrays, empty arrays are ones with length of 0 |
||||
* </li> |
||||
* <li>For Java {@link java.lang.String}s, <code>length()</code> is called, |
||||
* and return value of 0 indicates empty String (note that <code>String.isEmpty()</code> |
||||
* was added in Java 1.6 and as such can not be used by Jackson |
||||
* </li> |
||||
* <ul> |
||||
* and for other types, non-null values are to be included. |
||||
*<p> |
||||
* Note that this default handling can be overridden by custom |
||||
* <code>JsonSerializer</code> implementation: if method <code>isEmpty()</code> |
||||
* is overridden, it will be called to see if non-null values are |
||||
* considered empty (null is always considered empty). |
||||
*/ |
||||
NON_EMPTY |
||||
; |
||||
} |
||||
|
||||
} |
@ -0,0 +1,41 @@
|
||||
package com.fr.third.fasterxml.jackson.annotation; |
||||
|
||||
import java.lang.annotation.ElementType; |
||||
import java.lang.annotation.Retention; |
||||
import java.lang.annotation.RetentionPolicy; |
||||
import java.lang.annotation.Target; |
||||
|
||||
/** |
||||
* Annotation used to indicate that annotated property is part of |
||||
* two-way linkage between fields; and that its role is "parent" (or "forward") link. |
||||
* Value type (class) of property must have a single compatible property annotated with |
||||
* {@link JsonBackReference}. Linkage is handled such that the property |
||||
* annotated with this annotation is handled normally (serialized normally, no |
||||
* special handling for deserialization); it is the matching back reference |
||||
* that requires special handling |
||||
*<p> |
||||
* All references have logical name to allow handling multiple linkages; typical case |
||||
* would be that where nodes have both parent/child and sibling linkages. If so, |
||||
* pairs of references should be named differently. |
||||
* It is an error for a class too have multiple managed references with same name, |
||||
* even if types pointed are different. |
||||
*<p> |
||||
* Note: only methods and fields can be annotated with this annotation: constructor |
||||
* arguments should NOT be annotated, as they can not be either managed or back |
||||
* references. |
||||
* |
||||
* @author tatu |
||||
*/ |
||||
@Target({ElementType.ANNOTATION_TYPE, ElementType.FIELD, ElementType.METHOD}) |
||||
@Retention(RetentionPolicy.RUNTIME) |
||||
@JacksonAnnotation |
||||
public @interface JsonManagedReference |
||||
{ |
||||
/** |
||||
* Logical have for the reference property pair; used to link managed and |
||||
* back references. Default name can be used if there is just single |
||||
* reference pair (for example, node class that just has parent/child linkage, |
||||
* consisting of one managed reference and matching back reference) |
||||
*/ |
||||
public String value() default "defaultReference"; |
||||
} |
@ -0,0 +1,67 @@
|
||||
package com.fr.third.fasterxml.jackson.annotation; |
||||
|
||||
import java.lang.annotation.ElementType; |
||||
import java.lang.annotation.Retention; |
||||
import java.lang.annotation.RetentionPolicy; |
||||
import java.lang.annotation.Target; |
||||
|
||||
/** |
||||
* Marker annotation that can be used to define a non-static |
||||
* method as a "setter" or "getter" for a logical property |
||||
* (depending on its signature), |
||||
* or non-static object field to be used (serialized, deserialized) as |
||||
* a logical property. |
||||
*<p> |
||||
* Default value ("") indicates that the field name is used |
||||
* as the property name without any modifications, but it |
||||
* can be specified to non-empty value to specify different |
||||
* name. Property name refers to name used externally, as |
||||
* the field name in JSON objects. |
||||
*/ |
||||
@Target({ElementType.ANNOTATION_TYPE, ElementType.FIELD, ElementType.METHOD, ElementType.PARAMETER}) |
||||
@Retention(RetentionPolicy.RUNTIME) |
||||
@JacksonAnnotation |
||||
public @interface JsonProperty |
||||
{ |
||||
/** |
||||
* Special value that indicates that handlers should use the default |
||||
* name (derived from method or field name) for property. |
||||
* |
||||
* @since 2.1 |
||||
*/ |
||||
public final static String USE_DEFAULT_NAME = ""; |
||||
|
||||
/** |
||||
* Defines name of the logical property, i.e. JSON object field |
||||
* name to use for the property. If value is empty String (which is the |
||||
* default), will try to use name of the field that is annotated. |
||||
* Note that there is |
||||
* <b>no default name available for constructor arguments</b>, |
||||
* meaning that |
||||
* <b>Empty String is not a valid value for constructor arguments</b>. |
||||
*/ |
||||
String value() default USE_DEFAULT_NAME; |
||||
|
||||
/** |
||||
* Property that indicates whether a value (which may be explicit |
||||
* null) is expected for property during deserialization or not. |
||||
* If expected, <code>BeanDeserialized</code> should indicate |
||||
* this as a validity problem (usually by throwing an exception, |
||||
* but this may be sent via problem handlers that can try to |
||||
* rectify the problem, for example, by supplying a default |
||||
* value). |
||||
*<p> |
||||
* Note that as of 2.0, this property is NOT used by |
||||
* <code>BeanDeserializer</code>: support is expected to be |
||||
* added for a later minor version. |
||||
* |
||||
* @since 2.0 |
||||
*/ |
||||
boolean required() default false; |
||||
|
||||
/* NOTE: considering of adding ability to specify default |
||||
* String value -- would work well for scalar types, most of |
||||
* which can coerce from Strings. But won't add for 2.0 yet. |
||||
*/ |
||||
//String defaultValue() default "";
|
||||
} |
@ -0,0 +1,25 @@
|
||||
package com.fr.third.fasterxml.jackson.annotation; |
||||
|
||||
import java.lang.annotation.ElementType; |
||||
import java.lang.annotation.Retention; |
||||
import java.lang.annotation.RetentionPolicy; |
||||
import java.lang.annotation.Target; |
||||
|
||||
/** |
||||
* Annotaion used to define a human readable description for a logical |
||||
* property. |
||||
* Currently used to populate the description field in generated JSON |
||||
* Schemas. |
||||
*/ |
||||
@Target({ElementType.ANNOTATION_TYPE, ElementType.FIELD, ElementType.METHOD, ElementType.PARAMETER}) |
||||
@Retention(RetentionPolicy.RUNTIME) |
||||
@JacksonAnnotation |
||||
public @interface JsonPropertyDescription |
||||
{ |
||||
/** |
||||
* Defines a human readable description of the logical property. |
||||
* Currently used to populate the description field in generated JSON |
||||
* Schemas. |
||||
*/ |
||||
String value() default ""; |
||||
} |
@ -0,0 +1,46 @@
|
||||
package com.fr.third.fasterxml.jackson.annotation; |
||||
|
||||
import java.lang.annotation.ElementType; |
||||
import java.lang.annotation.Retention; |
||||
import java.lang.annotation.RetentionPolicy; |
||||
import java.lang.annotation.Target; |
||||
|
||||
/** |
||||
* Annotation that can be used to define ordering (possibly partial) to use |
||||
* when serializing object properties. Properties included in annotation |
||||
* declaration will be serialized first (in defined order), followed by |
||||
* any properties not included in the definition. |
||||
* Annotation definition will override any implicit orderings (such as |
||||
* guarantee that Creator-properties are serialized before non-creator |
||||
* properties) |
||||
*<p> |
||||
* Examples: |
||||
*<pre> |
||||
* // ensure that "id" and "name" are output before other properties
|
||||
* <div>@</div>JsonPropertyOrder({ "id", "name" }) |
||||
* // order any properties that don't have explicit setting using alphabetic order
|
||||
* <div>@</div>JsonPropertyOrder(alphabetic=true) |
||||
*</pre> |
||||
*<p> |
||||
* This annotation may or may not have effect on deserialization: for basic JSON |
||||
* handling there is no effect, but for other supported data types (or structural |
||||
* conventions) there may be. |
||||
*/ |
||||
@Target({ElementType.ANNOTATION_TYPE, ElementType.TYPE}) |
||||
@Retention(RetentionPolicy.RUNTIME) |
||||
@JacksonAnnotation |
||||
public @interface JsonPropertyOrder |
||||
{ |
||||
/** |
||||
* Order in which properties of annotated object are to be serialized in. |
||||
*/ |
||||
public String[] value() default { }; |
||||
|
||||
/** |
||||
* Property that defines what to do regarding ordering of properties |
||||
* not explicitly included in annotation instance. If set to true, |
||||
* they will be alphabetically ordered; if false, order is |
||||
* undefined (default setting) |
||||
*/ |
||||
public boolean alphabetic() default false; |
||||
} |
@ -0,0 +1,31 @@
|
||||
package com.fr.third.fasterxml.jackson.annotation; |
||||
|
||||
import java.lang.annotation.ElementType; |
||||
import java.lang.annotation.Retention; |
||||
import java.lang.annotation.RetentionPolicy; |
||||
import java.lang.annotation.Target; |
||||
|
||||
/** |
||||
* Marker annotation that indicates that the annotated method |
||||
* or field should be serialized by including literal String value |
||||
* of the property as is, without quoting of characters. |
||||
* This can be useful for injecting values already serialized in JSON or |
||||
* passing javascript function definitions from server to a javascript client. |
||||
*<p> |
||||
* Warning: the resulting JSON stream may be invalid depending on your input value. |
||||
*/ |
||||
@Target({ElementType.ANNOTATION_TYPE, ElementType.METHOD, ElementType.FIELD }) |
||||
@Retention(RetentionPolicy.RUNTIME) |
||||
@JacksonAnnotation |
||||
public @interface JsonRawValue |
||||
{ |
||||
/** |
||||
* Optional argument that defines whether this annotation is active |
||||
* or not. The only use for value 'false' if for overriding purposes |
||||
* (which is not needed often); most likely it is needed for use |
||||
* with "mix-in annotations" (aka "annotation overrides"). |
||||
* For most cases, however, default value of "true" is just fine |
||||
* and should be omitted. |
||||
*/ |
||||
boolean value() default true; |
||||
} |
@ -0,0 +1,25 @@
|
||||
package com.fr.third.fasterxml.jackson.annotation; |
||||
|
||||
import java.lang.annotation.ElementType; |
||||
import java.lang.annotation.Retention; |
||||
import java.lang.annotation.RetentionPolicy; |
||||
import java.lang.annotation.Target; |
||||
|
||||
/** |
||||
* Annotation similar to {@link javax.xml.bind.annotation.XmlRootElement}, |
||||
* used to indicate name to use for root-level wrapping, if wrapping is |
||||
* enabled. Annotation itself does not indicate that wrapping should |
||||
* be used; but if it is, name used for serialization should be name |
||||
* specified here, and deserializer will expect the name as well. |
||||
*/ |
||||
@Target({ElementType.ANNOTATION_TYPE, ElementType.TYPE}) |
||||
@Retention(RetentionPolicy.RUNTIME) |
||||
@com.fr.third.fasterxml.jackson.annotation.JacksonAnnotation |
||||
public @interface JsonRootName |
||||
{ |
||||
/** |
||||
* Root name to use if root-level wrapping is enabled. |
||||
*/ |
||||
public String value(); |
||||
|
||||
} |
@ -0,0 +1,33 @@
|
||||
package com.fr.third.fasterxml.jackson.annotation; |
||||
|
||||
import java.lang.annotation.ElementType; |
||||
import java.lang.annotation.Retention; |
||||
import java.lang.annotation.RetentionPolicy; |
||||
import java.lang.annotation.Target; |
||||
|
||||
/** |
||||
* Marker annotation that can be used to define a non-static, |
||||
* single-argument method to be used as a "setter" for a logical property |
||||
* as an alternative to recommended |
||||
* {@link JsonProperty} annotation (which was introduced in version 1.1). |
||||
*<p> |
||||
* Setter means that when a property with matching name is encountered in |
||||
* JSON content, this method will be used to set value of the property. |
||||
*<p> |
||||
* NOTE: this annotation was briefly deprecated for version 1.5; but has |
||||
* since been un-deprecated to both allow for asymmetric naming (possibly |
||||
* different name when reading and writing JSON), and more importantly to |
||||
* allow multi-argument setter method in future. |
||||
*/ |
||||
@Target({ElementType.ANNOTATION_TYPE, ElementType.METHOD}) |
||||
@Retention(RetentionPolicy.RUNTIME) |
||||
@JacksonAnnotation |
||||
public @interface JsonSetter |
||||
{ |
||||
/** |
||||
* Optional default argument that defines logical property this |
||||
* method is used to modify ("set"); this is the property |
||||
* name used in JSON content. |
||||
*/ |
||||
String value() default ""; |
||||
} |
@ -0,0 +1,43 @@
|
||||
package com.fr.third.fasterxml.jackson.annotation; |
||||
|
||||
import java.lang.annotation.ElementType; |
||||
import java.lang.annotation.Retention; |
||||
import java.lang.annotation.RetentionPolicy; |
||||
import java.lang.annotation.Target; |
||||
|
||||
/** |
||||
* Annotation used with {@link JsonTypeInfo} to indicate sub types of serializable |
||||
* polymorphic types, and to associate logical names used within JSON content |
||||
* (which is more portable than using physical Java class names). |
||||
*/ |
||||
@Target({ElementType.ANNOTATION_TYPE, ElementType.TYPE, ElementType.FIELD, |
||||
ElementType.METHOD, ElementType.PARAMETER}) |
||||
@Retention(RetentionPolicy.RUNTIME) |
||||
@JacksonAnnotation |
||||
public @interface JsonSubTypes { |
||||
/** |
||||
* Subtypes of the annotated type (annotated class, or property value type |
||||
* associated with the annotated method). These will be checked recursively |
||||
* so that types can be defined by only including direct subtypes. |
||||
*/ |
||||
public Type[] value(); |
||||
|
||||
/** |
||||
* Definition of a subtype, along with optional name. If name is missing, class
|
||||
* of the type will be checked for {@link JsonTypeName} annotation; and if that |
||||
* is also missing or empty, a default |
||||
* name will be constructed by type id mechanism. |
||||
* Default name is usually based on class name. |
||||
*/ |
||||
public @interface Type { |
||||
/** |
||||
* Class of the subtype |
||||
*/ |
||||
public Class<?> value(); |
||||
|
||||
/** |
||||
* Logical type name used as the type identifier for the class
|
||||
*/ |
||||
public String name() default ""; |
||||
} |
||||
} |
@ -0,0 +1,37 @@
|
||||
package com.fr.third.fasterxml.jackson.annotation; |
||||
|
||||
import java.lang.annotation.ElementType; |
||||
import java.lang.annotation.Retention; |
||||
import java.lang.annotation.RetentionPolicy; |
||||
import java.lang.annotation.Target; |
||||
|
||||
/** |
||||
* Marker annotation that can be used on a property accessor |
||||
* (field, getter or setter, constructor parameter) to indicate that |
||||
* the property is to contain type id to use when including |
||||
* polymorphic type information. |
||||
* Annotation should <b>only be used</b> if the intent is to override |
||||
* generation of standard type id: if so, value of the property will be |
||||
* accessed during serialization and used as the type id. |
||||
*<p> |
||||
* On deserialization annotation has no effect, as visibility of type id |
||||
* is governed by value of {@link JsonTypeInfo#visible}; properties with |
||||
* this annotation get no special handling. |
||||
*<p> |
||||
* On serialization, this annotation will exclude property from being |
||||
* serialized along other properties; instead, its value is serialized |
||||
* as the type identifier. Since type identifier may be included in |
||||
* various places, it may still appear like 'normal' property (when using |
||||
* {@link JsonTypeInfo.As#PROPERTY}), but is more commonly embedded |
||||
* in a different place, as per inclusion rules (see {@link JsonTypeInfo} |
||||
* for details). |
||||
* |
||||
* @since 2.0 |
||||
*/ |
||||
@Target({ElementType.ANNOTATION_TYPE, ElementType.FIELD, ElementType.METHOD, ElementType.PARAMETER}) |
||||
@Retention(RetentionPolicy.RUNTIME) |
||||
@JacksonAnnotation |
||||
public @interface JsonTypeId |
||||
{ |
||||
|
||||
} |
@ -0,0 +1,277 @@
|
||||
package com.fr.third.fasterxml.jackson.annotation; |
||||
|
||||
import java.lang.annotation.*; |
||||
|
||||
/** |
||||
* Annotation used for configuring details of if and how type information is |
||||
* used with JSON serialization and deserialization, to preserve information |
||||
* about actual class of Object instances. This is necessarily for polymorphic |
||||
* types, and may also be needed to link abstract declared types and matching |
||||
* concrete implementation. |
||||
*<p> |
||||
* Some examples of typical annotations: |
||||
*<pre> |
||||
* // Include Java class name ("com.myempl.ImplClass") as JSON property "class"
|
||||
* @JsonTypeInfo(use=Id.CLASS, include=As.PROPERTY, property="class") |
||||
* |
||||
* // Include logical type name (defined in impl classes) as wrapper; 2 annotations
|
||||
* @JsonTypeInfo(use=Id.NAME, include=As.WRAPPER_OBJECT) |
||||
* @JsonSubTypes({com.myemp.Impl1.class, com.myempl.Impl2.class}) |
||||
*</pre> |
||||
* Alternatively you can also define fully customized type handling by using |
||||
* <code>@JsonTypeResolver</code> annotation (from databind package). |
||||
*<p> |
||||
* This annotation can be used both for types (classes) and properties. |
||||
* If both exist, annotation on property has precedence, as it is |
||||
* considered more specific. |
||||
*<p> |
||||
* When used for properties (fields, methods), this annotation applies |
||||
* to <b>values</b>: so when applied to structure types |
||||
* (like {@link java.util.Collection}, {@link java.util.Map}, arrays), |
||||
* will apply to contained values, not the container; |
||||
* for non-structured types there is no difference. |
||||
* This is identical to how JAXB handles type information |
||||
* annotations; and is chosen since it is the dominant use case. |
||||
* There is no per-property way to force type information to be included |
||||
* for type of container (structured type); for container types one has |
||||
* to use annotation for type declaration. |
||||
*<p> |
||||
* Note on visibility of type identifier: by default, deserialization |
||||
* (use during reading of JSON) of type identifier |
||||
* is completely handled by Jackson, and is <b>not passed to</b> |
||||
* deserializers. However, if so desired, |
||||
* it is possible to define property <code>visible = true</code> |
||||
* in which case property will be passed as-is to deserializers |
||||
* (and set via setter or field) on deserialization. |
||||
*<p> |
||||
* On serialization side, Jackson will generate type id by itself, |
||||
* except if there is a property with name that matches |
||||
* {@link #property()}, in which case value of that property is |
||||
* used instead. |
||||
*/ |
||||
@Target({ElementType.ANNOTATION_TYPE, ElementType.TYPE, |
||||
ElementType.FIELD, ElementType.METHOD, ElementType.PARAMETER}) |
||||
@Retention(RetentionPolicy.RUNTIME) |
||||
@JacksonAnnotation |
||||
public @interface JsonTypeInfo |
||||
{ |
||||
/* |
||||
/********************************************************** |
||||
/* Value enumerations used for properties |
||||
/********************************************************** |
||||
*/ |
||||
|
||||
/** |
||||
* Definition of different type identifiers that can be included in JSON |
||||
* during serialization, and used for deserialization. |
||||
*/ |
||||
public enum Id { |
||||
/** |
||||
* This means that no explicit type metadata is included, and typing is |
||||
* purely done using contextual information possibly augmented with other |
||||
* annotations. |
||||
*/ |
||||
NONE(null), |
||||
|
||||
/** |
||||
* Means that fully-qualified Java class name is used as the type identifier. |
||||
*/ |
||||
CLASS("@class"), |
||||
|
||||
/** |
||||
* Means that Java class name with minimal path is used as the type identifier. |
||||
* Minimal means that only the class name, and that part of preceding Java |
||||
* package name is included that is needed to construct fully-qualified name |
||||
* given fully-qualified name of the declared supertype; additionally a single |
||||
* leading dot ('.') must be used to indicate that partial class name is used. |
||||
* For example, for supertype "com.foobar.Base", and concrete type |
||||
* "com.foo.Impl", only ".Impl" would be included; and for "com.foo.impl.Impl2" |
||||
* only ".impl.Impl2" would be included.<br /> |
||||
* <b>NOTE</b>: leading dot ('.') MUST be used to denote partial (minimal) name; |
||||
* if it is missing, value is assumed to be fully-qualified name. Fully-qualified |
||||
* name is used in cases where subtypes are not in same package (or sub-package
|
||||
* thereof) as base class. |
||||
*<p> |
||||
* If all related classes are in the same Java package, this option can reduce |
||||
* amount of type information overhead, especially for small types. |
||||
* However, please note that using this alternative is inherently risky since it |
||||
* assumes that the |
||||
* supertype can be reliably detected. Given that it is based on declared type |
||||
* (since ultimate supertype, <code>java.lang.Object</code> would not be very |
||||
* useful reference point), this may not always work as expected. |
||||
*/ |
||||
MINIMAL_CLASS("@c"), |
||||
|
||||
/** |
||||
* Means that logical type name is used as type information; name will then need |
||||
* to be separately resolved to actual concrete type (Class). |
||||
*/ |
||||
NAME("@type"), |
||||
|
||||
/** |
||||
* Means that typing mechanism uses customized handling, with possibly |
||||
* custom configuration. This means that semantics of other properties is |
||||
* not defined by Jackson package, but by the custom implementation. |
||||
*/ |
||||
CUSTOM(null) |
||||
; |
||||
|
||||
private final String _defaultPropertyName; |
||||
|
||||
private Id(String defProp) { |
||||
_defaultPropertyName = defProp; |
||||
} |
||||
|
||||
public String getDefaultPropertyName() { return _defaultPropertyName; } |
||||
} |
||||
|
||||
/** |
||||
* Definition of standard type inclusion mechanisms for type metadata. |
||||
* Used for standard metadata types, except for {@link Id#NONE}. |
||||
* May or may not be used for custom types ({@link Id#CUSTOM}). |
||||
*/ |
||||
public enum As { |
||||
/** |
||||
* Inclusion mechanism that uses a single configurable property, included |
||||
* along with actual data (POJO properties) as a separate meta-property. |
||||
* <p> |
||||
* Default choice for inclusion. |
||||
*/ |
||||
PROPERTY, |
||||
|
||||
/** |
||||
* Inclusion mechanism that wraps typed JSON value (POJO |
||||
* serialized as JSON) in |
||||
* a JSON Object that has a single entry, |
||||
* where field name is serialized type identifier, |
||||
* and value is the actual JSON value. |
||||
*<p> |
||||
* Note: can only be used if type information can be serialized as |
||||
* String. This is true for standard type metadata types, but not |
||||
* necessarily for custom types. |
||||
*/ |
||||
WRAPPER_OBJECT, |
||||
|
||||
/** |
||||
* Inclusion mechanism that wraps typed JSON value (POJO |
||||
* serialized as JSON) in |
||||
* a 2-element JSON array: first element is the serialized |
||||
* type identifier, and second element the serialized POJO |
||||
* as JSON Object. |
||||
*/ |
||||
WRAPPER_ARRAY, |
||||
|
||||
/** |
||||
* Inclusion mechanism similar to <code>PROPERTY</code>, except that |
||||
* property is included one-level higher in hierarchy, i.e. as sibling |
||||
* property at same level as JSON Object to type. |
||||
* Note that this choice <b>can only be used for properties</b>, not |
||||
* for types (classes). Trying to use it for classes will result in |
||||
* inclusion strategy of basic <code>PROPERTY</code> instead. |
||||
*/ |
||||
EXTERNAL_PROPERTY, |
||||
|
||||
/** |
||||
* Inclusion mechanism similar to <code>PROPERTY</code> with respect |
||||
* to deserialization; but one that is produced by a "regular" accessible |
||||
* property during serialization. This means that <code>TypeSerializer</code> |
||||
* will do nothing, and expect a property with defined name to be output |
||||
* using some other mechanism (like default POJO property serialization, or |
||||
* custom serializer). |
||||
*<p> |
||||
* Note that this behavior is quite similar to that of using {@link JsonTypeId}; |
||||
* except that here <code>TypeSerializer</code> is basically suppressed; |
||||
* whereas with {@link JsonTypeId}, output of regular property is suppressed. |
||||
* This mostly matters with respect to output order; this choice is the only |
||||
* way to ensure specific placement of type id during serialization. |
||||
* |
||||
* @since 2.3.0 |
||||
*/ |
||||
EXISTING_PROPERTY |
||||
; |
||||
} |
||||
|
||||
/* |
||||
/********************************************************** |
||||
/* Annotation properties |
||||
/********************************************************** |
||||
*/ |
||||
|
||||
/** |
||||
* What kind of type metadata is to be used for serializing and deserializing |
||||
* type information for instances of annotated type (and its subtypes |
||||
* unless overridden) |
||||
*/ |
||||
public Id use(); |
||||
|
||||
/** |
||||
* What mechanism is used for including type metadata (if any; for |
||||
* {@link Id#NONE} nothing is included). Default |
||||
*<p> |
||||
* Note that for type metadata type of {@link Id#CUSTOM}, |
||||
* this setting may or may not have any effect. |
||||
*/ |
||||
public As include() default As.PROPERTY; |
||||
|
||||
/** |
||||
* Property names used when type inclusion method ({@link As#PROPERTY}) is used |
||||
* (or possibly when using type metadata of type {@link Id#CUSTOM}). |
||||
* If POJO itself has a property with same name, value of property |
||||
* will be set with type id metadata: if no such property exists, type id |
||||
* is only used for determining actual type. |
||||
*<p> |
||||
* Default property name used if this property is not explicitly defined |
||||
* (or is set to empty String) is based on |
||||
* type metadata type ({@link #use}) used. |
||||
*/ |
||||
public String property() default ""; |
||||
|
||||
/** |
||||
* Optional property that can be used to specify default implementation |
||||
* class to use if type identifier is either not present, or can not |
||||
* be mapped to a registered type (which can occur for ids, but not when |
||||
* specifying explicit class to use). |
||||
*<p> |
||||
* Note that while this property allows specification of the default |
||||
* implementation to use, it does not help with structural issues that |
||||
* may arise if type information is missing. This means that most often |
||||
* this is used with type-name -based resolution, to cover cases |
||||
* where new sub-types are added, but base type is not changed to |
||||
* reference new sub-types. |
||||
*<p> |
||||
* There are certain special values that indicate alternate behavior: |
||||
*<ul> |
||||
* <li>{@link None} means "there is no default implementation" (in which |
||||
* case an error results from unmappable type) |
||||
* <li><code>com.fr.third.fasterxml.jackson.databind.annotation.NoClass</code> means that |
||||
* objects with unmappable (or missing) type are to be mapped to null references. |
||||
* </ul> |
||||
*/ |
||||
public Class<?> defaultImpl() default None.class; |
||||
|
||||
/** |
||||
* Property that defines whether type identifier value will be passed |
||||
* as part of JSON stream to deserializer (true), or handled and |
||||
* removed by <code>TypeDeserializer</code> (false). |
||||
*<p> |
||||
* Default value is false, meaning that Jackson handles and removes |
||||
* the type identifier from JSON content that is passed to |
||||
* <code>JsonDeserializer</code>. |
||||
* |
||||
* @since 2.0 |
||||
*/ |
||||
public boolean visible() default false; |
||||
|
||||
/* |
||||
/********************************************************** |
||||
/* Helper classes |
||||
/********************************************************** |
||||
*/ |
||||
|
||||
/** |
||||
* This marker class that is only to be used with <code>defaultImpl</code> |
||||
* annotation property, to indicate that there is no default implementation |
||||
* specified. |
||||
*/ |
||||
public abstract static class None { } |
||||
} |
@ -0,0 +1,26 @@
|
||||
package com.fr.third.fasterxml.jackson.annotation; |
||||
|
||||
import java.lang.annotation.ElementType; |
||||
import java.lang.annotation.Retention; |
||||
import java.lang.annotation.RetentionPolicy; |
||||
import java.lang.annotation.Target; |
||||
|
||||
|
||||
/** |
||||
* Annotation used for binding logical name that the annotated class
|
||||
* has. Used with {@link JsonTypeInfo} (and specifically its |
||||
* {@link JsonTypeInfo#use} property) to establish relationship |
||||
* between type names and types. |
||||
* |
||||
* @author tatu |
||||
*/ |
||||
@Target({ElementType.ANNOTATION_TYPE, ElementType.TYPE}) |
||||
@Retention(RetentionPolicy.RUNTIME) |
||||
@JacksonAnnotation |
||||
public @interface JsonTypeName { |
||||
/** |
||||
* Logical type name for annotated type. If missing (or defined as Empty String), |
||||
* defaults to using non-qualified class name as the type. |
||||
*/ |
||||
public String value() default ""; |
||||
} |
@ -0,0 +1,89 @@
|
||||
package com.fr.third.fasterxml.jackson.annotation; |
||||
|
||||
import java.lang.annotation.ElementType; |
||||
import java.lang.annotation.Retention; |
||||
import java.lang.annotation.RetentionPolicy; |
||||
import java.lang.annotation.Target; |
||||
|
||||
/** |
||||
* Annotation used to indicate that a property should be serialized |
||||
* "unwrapped"; that is, if it would be serialized as JSON Object, its |
||||
* properties are instead included as properties of its containing |
||||
* Object. For example, consider case of POJO like: |
||||
* |
||||
*<pre> |
||||
* public class Parent { |
||||
* public int age; |
||||
* public Name name; |
||||
* } |
||||
* public class Name { |
||||
* public String first, last; |
||||
* } |
||||
*</pre> |
||||
* which would normally be serialized as follows (assuming @JsonUnwrapped |
||||
* had no effect): |
||||
*<pre> |
||||
* { |
||||
* "age" : 18, |
||||
* "name" : { |
||||
* "first" : "Joey", |
||||
* "last" : "Sixpack" |
||||
* } |
||||
* } |
||||
*</pre> |
||||
* can be changed to this: |
||||
*<pre> |
||||
* { |
||||
* "age" : 18, |
||||
* "first" : "Joey", |
||||
* "last" : "Sixpack" |
||||
* } |
||||
*</pre> |
||||
* by changing Parent class to: |
||||
*<pre> |
||||
* public class Parent { |
||||
* public int age; |
||||
* @JsonUnwrapped |
||||
* public Name name; |
||||
* } |
||||
*</pre> |
||||
* Annotation can only be added to properties, and not classes, as it is contextual. |
||||
*<p> |
||||
* Also note that annotation only applies if |
||||
*<ul> |
||||
* <li>Value is serialized as JSON Object (can not unwrap JSON arrays using this |
||||
* mechanism) |
||||
* </li> |
||||
* <li>Serialization is done using <code>BeanSerializer</code>, not a custom serializer |
||||
* </li> |
||||
* <li>No type information is added; if type information needs to be added, structure can |
||||
* not be altered regardless of inclusion strategy; so annotation is basically ignored. |
||||
* </li> |
||||
* </ul> |
||||
*/ |
||||
@Target({ElementType.ANNOTATION_TYPE, ElementType.FIELD, ElementType.METHOD, ElementType.PARAMETER}) |
||||
@Retention(RetentionPolicy.RUNTIME) |
||||
@JacksonAnnotation |
||||
public @interface JsonUnwrapped |
||||
{ |
||||
/** |
||||
* Property that is usually only used when overriding (masking) annotations, |
||||
* using mix-in annotations. Otherwise default value of 'true' is fine, and |
||||
* value need not be explicitly included. |
||||
*/ |
||||
boolean enabled() default true; |
||||
|
||||
/** |
||||
* Optional property that can be used to add prefix String to use in front |
||||
* of names of properties that are unwrapped: this can be done for example to prevent |
||||
* name collisions. |
||||
*/ |
||||
String prefix() default ""; |
||||
|
||||
/** |
||||
* Optional property that can be used to add suffix String to append at the end |
||||
* of names of properties that are unwrapped: this can be done for example to prevent |
||||
* name collisions. |
||||
*/ |
||||
String suffix() default ""; |
||||
} |
@ -0,0 +1,54 @@
|
||||
package com.fr.third.fasterxml.jackson.annotation; |
||||
|
||||
import java.lang.annotation.ElementType; |
||||
import java.lang.annotation.Retention; |
||||
import java.lang.annotation.RetentionPolicy; |
||||
import java.lang.annotation.Target; |
||||
|
||||
/** |
||||
* Marker annotation similar to |
||||
* {@link javax.xml.bind.annotation.XmlValue} |
||||
* that indicates that results of the annotated "getter" method |
||||
* (which means signature must be that of getters; non-void return |
||||
* type, no args) is to be used as the single value to serialize |
||||
* for the instance. Usually value will be of a simple scalar type |
||||
* (String or Number), but it can be any serializable type (Collection, |
||||
* Map or Bean). |
||||
*<p> |
||||
* At most one method of a <code>Class</code> can be annotated with this annotation; |
||||
* if more than one is found, an exception may be thrown. |
||||
* Also, if method signature is not compatible with Getters, an exception |
||||
* may be thrown (whether exception is thrown or not is an implementation detail (due |
||||
* to filtering during introspection, some annotations may be skipped) |
||||
* and applications should not rely on specific behavior). |
||||
*<p> |
||||
* A typical usage is that of annotating <code>toString()</code> |
||||
* method so that returned String value is used as the JSON serialization; |
||||
* and if deserialization is needed, there is matching constructor |
||||
* or factory method annotated with {@link JsonCreator} annotation. |
||||
*<p> |
||||
* Boolean argument is only used so that sub-classes can "disable" |
||||
* annotation if necessary. |
||||
*<p> |
||||
* NOTE: when use for Java <code>enum</code>s, one additional feature is |
||||
* that value returned by annotated method is also considered to be the |
||||
* value to deserialize from, not just JSON String to serialize as. |
||||
* This is possible since set of Enum values is constant and it is possible |
||||
* to define mapping, but can not be done in general for POJO types; as such, |
||||
* this is not used for POJO deserialization. |
||||
*/ |
||||
@Target({ElementType.ANNOTATION_TYPE, ElementType.METHOD}) |
||||
@Retention(RetentionPolicy.RUNTIME) |
||||
@JacksonAnnotation |
||||
public @interface JsonValue |
||||
{ |
||||
/** |
||||
* Optional argument that defines whether this annotation is active |
||||
* or not. The only use for value 'false' if for overriding purposes. |
||||
* Overriding may be necessary when used |
||||
* with "mix-in annotations" (aka "annotation overrides"). |
||||
* For most cases, however, default value of "true" is just fine |
||||
* and should be omitted. |
||||
*/ |
||||
boolean value() default true; |
||||
} |
@ -0,0 +1,34 @@
|
||||
package com.fr.third.fasterxml.jackson.annotation; |
||||
|
||||
import java.lang.annotation.ElementType; |
||||
import java.lang.annotation.Retention; |
||||
import java.lang.annotation.RetentionPolicy; |
||||
import java.lang.annotation.Target; |
||||
|
||||
import com.fr.third.fasterxml.jackson.annotation.JacksonAnnotation; |
||||
|
||||
/** |
||||
* Annotation used for indicating view(s) that the property |
||||
* that is defined by method or field annotated is part of. |
||||
*<p> |
||||
* An example annotation would be: |
||||
*<pre> |
||||
* @JsonView(BasicView.class) |
||||
*</pre> |
||||
* which would specify that property annotated would be included |
||||
* when processing (serializing, deserializing) View identified |
||||
* by <code>BasicView.class</code> (or its sub-class). |
||||
* If multiple View class identifiers are included, property will |
||||
* be part of all of them. |
||||
*/ |
||||
@Target({ElementType.ANNOTATION_TYPE, ElementType.METHOD, ElementType.FIELD}) |
||||
@Retention(RetentionPolicy.RUNTIME) |
||||
@JacksonAnnotation |
||||
public @interface JsonView { |
||||
/** |
||||
* View or views that annotated element is part of. Views are identified |
||||
* by classes, and use expected class inheritance relationship: child |
||||
* views contain all elements parent views have, for example. |
||||
*/ |
||||
public Class<?>[] value() default { }; |
||||
} |
@ -0,0 +1,145 @@
|
||||
package com.fr.third.fasterxml.jackson.annotation; |
||||
|
||||
/** |
||||
* Definition of API used for constructing Object Identifiers |
||||
* (as annotated using {@link JsonIdentityInfo}). |
||||
* Also defines factory methods used for creating instances |
||||
* for serialization, deserialization. |
||||
* |
||||
* @param <T> Type of Object Identifiers produced. |
||||
*/ |
||||
@SuppressWarnings("serial") |
||||
public abstract class ObjectIdGenerator<T> |
||||
implements java.io.Serializable |
||||
{ |
||||
/* |
||||
/********************************************************** |
||||
/* Accessors |
||||
/********************************************************** |
||||
*/ |
||||
|
||||
public abstract Class<?> getScope(); |
||||
|
||||
/** |
||||
* Method called to check whether this generator instance can |
||||
* be used for Object Ids of specific generator type and |
||||
* scope; determination is based by passing a configured |
||||
* "blueprint" (prototype) instance; from which the actual |
||||
* instances are created (using {@link #newForSerialization}). |
||||
* |
||||
* @return True if this instance can be used as-is; false if not |
||||
*/ |
||||
public abstract boolean canUseFor(ObjectIdGenerator<?> gen); |
||||
|
||||
/* |
||||
/********************************************************** |
||||
/* Factory methods |
||||
/********************************************************** |
||||
*/ |
||||
|
||||
/** |
||||
* Factory method to create a blueprint instance for specified |
||||
* scope. Generators that do not use scope may return 'this'. |
||||
*/ |
||||
public abstract ObjectIdGenerator<T> forScope(Class<?> scope); |
||||
|
||||
/** |
||||
* Factory method called to create a new instance to use for |
||||
* serialization: needed since generators may have state |
||||
* (next id to produce). |
||||
*<p> |
||||
* Note that actual type of 'context' is |
||||
* <code>com.fr.third.fasterxml.jackson.databind.SerializerProvider</code>, |
||||
* but can not be declared here as type itself (as well as call |
||||
* to this object) comes from databind package. |
||||
* |
||||
* @param context Serialization context object used (of type |
||||
* <code>com.fr.third.fasterxml.jackson.databind.SerializerProvider</code>; |
||||
* may be needed by more complex generators to access contextual |
||||
* information such as configuration. |
||||
*/ |
||||
public abstract ObjectIdGenerator<T> newForSerialization(Object context); |
||||
|
||||
/** |
||||
* Method for constructing key to use for ObjectId-to-POJO maps. |
||||
*/ |
||||
public abstract IdKey key(Object key); |
||||
|
||||
/* |
||||
/********************************************************** |
||||
/* Methods for serialization |
||||
/********************************************************** |
||||
*/ |
||||
|
||||
/** |
||||
* Method used for generating a new Object Identifier to serialize |
||||
* for given POJO. |
||||
* |
||||
* @param forPojo POJO for which identifier is needed |
||||
* |
||||
* @return Object Identifier to use. |
||||
*/ |
||||
public abstract T generateId(Object forPojo); |
||||
|
||||
/* |
||||
/********************************************************** |
||||
/* Helper classes |
||||
/********************************************************** |
||||
*/ |
||||
|
||||
/** |
||||
* Simple key class that can be used as a key for |
||||
* ObjectId-to-POJO mappings, when multiple ObjectId types |
||||
* and scopes are used. |
||||
*/ |
||||
public final static class IdKey |
||||
implements java.io.Serializable |
||||
{ |
||||
private static final long serialVersionUID = 1L; |
||||
|
||||
/** |
||||
* Type of {@link ObjectIdGenerator} used for generating Object Id |
||||
*/ |
||||
private final Class<?> type; |
||||
|
||||
/** |
||||
* Scope of the Object Id (may be null, to denote global) |
||||
*/ |
||||
private final Class<?> scope; |
||||
|
||||
/** |
||||
* Object for which Object Id was generated: can NOT be null. |
||||
*/ |
||||
private final Object key; |
||||
|
||||
/** |
||||
* Hash code |
||||
*/ |
||||
private final int hashCode; |
||||
|
||||
public IdKey(Class<?> type, Class<?> scope, Object key) { |
||||
this.type = type; |
||||
this.scope = scope; |
||||
this.key = key; |
||||
|
||||
int h = key.hashCode() + type.getName().hashCode(); |
||||
if (scope != null) { |
||||
h ^= scope.getName().hashCode(); |
||||
} |
||||
hashCode = h; |
||||
} |
||||
|
||||
@Override |
||||
public int hashCode() { return hashCode; } |
||||
|
||||
@Override |
||||
public boolean equals(Object o) |
||||
{ |
||||
if (o == this) return true; |
||||
if (o == null) return false; |
||||
if (o.getClass() != getClass()) return false; |
||||
IdKey other = (IdKey) o; |
||||
return (other.key.equals(key)) && (other.type == type) && (other.scope == scope); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,164 @@
|
||||
package com.fr.third.fasterxml.jackson.annotation; |
||||
|
||||
import java.util.UUID; |
||||
|
||||
/** |
||||
* Container class for standard {@link ObjectIdGenerator} implementations. |
||||
*/ |
||||
public class ObjectIdGenerators |
||||
{ |
||||
/* |
||||
/********************************************************** |
||||
/* Shared base class for concrete implementations |
||||
/********************************************************** |
||||
*/ |
||||
|
||||
/** |
||||
* Helper class for implementations contained. |
||||
*/ |
||||
@SuppressWarnings("serial") |
||||
private abstract static class Base<T> extends ObjectIdGenerator<T> |
||||
{ |
||||
protected final Class<?> _scope; |
||||
|
||||
protected Base(Class<?> scope) { |
||||
_scope = scope; |
||||
} |
||||
|
||||
@Override |
||||
public final Class<?> getScope() { |
||||
return _scope; |
||||
} |
||||
|
||||
@Override |
||||
public boolean canUseFor(ObjectIdGenerator<?> gen) { |
||||
return (gen.getClass() == getClass()) && (gen.getScope() == _scope); |
||||
} |
||||
|
||||
@Override |
||||
public abstract T generateId(Object forPojo); |
||||
} |
||||
|
||||
/* |
||||
/********************************************************** |
||||
/* Implementation classes |
||||
/********************************************************** |
||||
*/ |
||||
|
||||
/** |
||||
* Abstract marker class used to allow explicitly specifying |
||||
* that no generator is used; which also implies that no |
||||
* Object Id is to be included or used. |
||||
*/ |
||||
@SuppressWarnings("serial") |
||||
public abstract static class None extends ObjectIdGenerator<Object> { } |
||||
|
||||
/** |
||||
* Abstract place-holder class which is used to denote case |
||||
* where Object Identifier to use comes from a POJO property |
||||
* (getter method or field). If so, value is written directly |
||||
* during serialization, and used as-is during deserialization. |
||||
*<p> |
||||
* Actual implementation class is part of <code>databind</code> |
||||
* package. |
||||
*/ |
||||
public abstract static class PropertyGenerator extends Base<Object> { |
||||
private static final long serialVersionUID = 1L; |
||||
|
||||
protected PropertyGenerator(Class<?> scope) { super(scope); } |
||||
} |
||||
|
||||
/** |
||||
* Simple sequence-number based generator, which uses basic Java |
||||
* <code>int</code>s (starting with value 1) as Object Identifiers. |
||||
*/ |
||||
public final static class IntSequenceGenerator extends Base<Integer> |
||||
{ |
||||
private static final long serialVersionUID = 1L; |
||||
|
||||
protected transient int _nextValue; |
||||
|
||||
public IntSequenceGenerator() { this(Object.class, -1); } |
||||
public IntSequenceGenerator(Class<?> scope, int fv) { |
||||
super(scope); |
||||
_nextValue = fv; |
||||
} |
||||
|
||||
protected int initialValue() { return 1; } |
||||
|
||||
@Override |
||||
public ObjectIdGenerator<Integer> forScope(Class<?> scope) { |
||||
return (_scope == scope) ? this : new IntSequenceGenerator(scope, _nextValue); |
||||
} |
||||
|
||||
@Override |
||||
public ObjectIdGenerator<Integer> newForSerialization(Object context) { |
||||
return new IntSequenceGenerator(_scope, initialValue()); |
||||
} |
||||
|
||||
@Override |
||||
public IdKey key(Object key) { |
||||
return new IdKey(getClass(), _scope, key); |
||||
} |
||||
|
||||
@Override |
||||
public Integer generateId(Object forPojo) { |
||||
int id = _nextValue; |
||||
++_nextValue; |
||||
return id; |
||||
} |
||||
} |
||||
|
||||
/** |
||||
* Implementation that just uses {@link java.util.UUID}s as reliably |
||||
* unique identifiers: downside is that resulting String is |
||||
* 36 characters long. |
||||
*<p> |
||||
* One difference to other generators is that scope is always |
||||
* set as <code>Object.class</code> (regardless of arguments): this |
||||
* because UUIDs are globally unique, and scope has no meaning. |
||||
*/ |
||||
public final static class UUIDGenerator extends Base<UUID> |
||||
{ |
||||
private static final long serialVersionUID = 1L; |
||||
|
||||
public UUIDGenerator() { this(Object.class); } |
||||
private UUIDGenerator(Class<?> scope) { |
||||
super(Object.class); |
||||
} |
||||
|
||||
/** |
||||
* Can just return base instance since this is essentially scopeless |
||||
*/ |
||||
@Override |
||||
public ObjectIdGenerator<UUID> forScope(Class<?> scope) { |
||||
return this; |
||||
} |
||||
|
||||
/** |
||||
* Can just return base instance since this is essentially scopeless |
||||
*/ |
||||
@Override |
||||
public ObjectIdGenerator<UUID> newForSerialization(Object context) { |
||||
return this; |
||||
} |
||||
|
||||
@Override |
||||
public UUID generateId(Object forPojo) { |
||||
return UUID.randomUUID(); |
||||
} |
||||
|
||||
@Override |
||||
public IdKey key(Object key) { |
||||
return new IdKey(getClass(), null, key); |
||||
} |
||||
|
||||
/** |
||||
* Since UUIDs are always unique, let's fully ignore scope definition |
||||
*/ |
||||
@Override |
||||
public boolean canUseFor(ObjectIdGenerator<?> gen) { |
||||
return (gen.getClass() == getClass()); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,87 @@
|
||||
package com.fr.third.fasterxml.jackson.annotation; |
||||
|
||||
/** |
||||
* Enumeration used to define kinds of elements (called "property accessors") |
||||
* that annotations like {@link JsonAutoDetect} apply to. |
||||
*<p> |
||||
* In addition to method types (GETTER/IS_GETTER, SETTER, CREATOR) and the |
||||
* field type (FIELD), 2 pseudo-types |
||||
* are defined for convenience: <code>ALWAYS</code> and <code>NONE</code>. These |
||||
* can be used to indicate, all or none of available method types (respectively), |
||||
* for use by annotations that takes <code>JsonMethod</code> argument. |
||||
*/ |
||||
public enum PropertyAccessor |
||||
{ |
||||
/** |
||||
* Getters are methods used to get a POJO field value for serialization, |
||||
* or, under certain conditions also for de-serialization. Latter |
||||
* can be used for effectively setting Collection or Map values |
||||
* in absence of setters, iff returned value is not a copy but |
||||
* actual value of the logical property. |
||||
*<p> |
||||
* Since version 1.3, this does <b>NOT</b> include "is getters" (methods |
||||
* that return boolean and named 'isXxx' for property 'xxx'); instead, |
||||
* {@link #IS_GETTER} is used}. |
||||
*/ |
||||
GETTER, |
||||
|
||||
/** |
||||
* Setters are methods used to set a POJO value for deserialization. |
||||
*/ |
||||
SETTER, |
||||
|
||||
/** |
||||
* Creators are constructors and (static) factory methods used to |
||||
* construct POJO instances for deserialization |
||||
*/ |
||||
CREATOR, |
||||
|
||||
/** |
||||
* Field refers to fields of regular Java objects. Although |
||||
* they are not really methods, addition of optional field-discovery |
||||
* in version 1.1 meant that there was need to enable/disable |
||||
* their auto-detection, and this is the place to add it in. |
||||
*/ |
||||
FIELD, |
||||
|
||||
/** |
||||
* "Is getters" are getter-like methods that are named "isXxx" |
||||
* (instead of "getXxx" for getters) and return boolean value |
||||
* (either primitive, or {@link java.lang.Boolean}). |
||||
* |
||||
*/ |
||||
IS_GETTER, |
||||
|
||||
/** |
||||
* This pseudo-type indicates that none of accessors if affected. |
||||
*/ |
||||
NONE, |
||||
|
||||
/** |
||||
* This pseudo-type indicates that all accessors are affected. |
||||
*/ |
||||
ALL |
||||
; |
||||
|
||||
private PropertyAccessor() { } |
||||
|
||||
public boolean creatorEnabled() { |
||||
return (this == CREATOR) || (this == ALL); |
||||
} |
||||
|
||||
public boolean getterEnabled() { |
||||
return (this == GETTER) || (this == ALL); |
||||
} |
||||
|
||||
public boolean isGetterEnabled() { |
||||
return (this == IS_GETTER) || (this == ALL); |
||||
} |
||||
|
||||
public boolean setterEnabled() { |
||||
return (this == SETTER) || (this == ALL); |
||||
} |
||||
|
||||
public boolean fieldEnabled() { |
||||
return (this == FIELD) || (this == ALL); |
||||
} |
||||
} |
@ -0,0 +1,12 @@
|
||||
/** |
||||
* Public core annotations, most of which are used to configure how |
||||
* Data Mapping/Binding works. Annotations in this package can only |
||||
* have dependencies to non-annotation classes in Core package; |
||||
* annotations that have dependencies to Mapper classes are included |
||||
* in Mapper module (under <code>org.codehaus.jackson.map.annotate</code>). |
||||
* Also contains parameter types (mostly enums) needed by annotations. |
||||
*<p> |
||||
* Note that prior versions (1.x) contained these annotations within |
||||
* 'core' jar, as part of Streaming API. |
||||
*/ |
||||
package com.fr.third.fasterxml.jackson.annotation; |
@ -0,0 +1,593 @@
|
||||
/* Jackson JSON-processor. |
||||
* |
||||
* Copyright (c) 2007- Tatu Saloranta, tatu.saloranta@iki.fi |
||||
*/ |
||||
package com.fr.third.fasterxml.jackson.core; |
||||
|
||||
import java.util.Arrays; |
||||
|
||||
import com.fr.third.fasterxml.jackson.core.util.ByteArrayBuilder; |
||||
|
||||
/** |
||||
* Abstract base class used to define specific details of which |
||||
* variant of Base64 encoding/decoding is to be used. Although there is |
||||
* somewhat standard basic version (so-called "MIME Base64"), other variants |
||||
* exists, see <a href="http://en.wikipedia.org/wiki/Base64">Base64 Wikipedia entry</a> for details. |
||||
* |
||||
* @author Tatu Saloranta |
||||
*/ |
||||
public final class Base64Variant |
||||
implements java.io.Serializable |
||||
{ |
||||
private final static int INT_SPACE = 0x20; |
||||
|
||||
// We'll only serialize name
|
||||
private static final long serialVersionUID = 1L; |
||||
|
||||
/** |
||||
* Placeholder used by "no padding" variant, to be used when a character |
||||
* value is needed. |
||||
*/ |
||||
final static char PADDING_CHAR_NONE = '\0'; |
||||
|
||||
/** |
||||
* Marker used to denote ascii characters that do not correspond |
||||
* to a 6-bit value (in this variant), and is not used as a padding |
||||
* character. |
||||
*/ |
||||
public final static int BASE64_VALUE_INVALID = -1; |
||||
|
||||
/** |
||||
* Marker used to denote ascii character (in decoding table) that |
||||
* is the padding character using this variant (if any). |
||||
*/ |
||||
public final static int BASE64_VALUE_PADDING = -2; |
||||
|
||||
/* |
||||
/********************************************************** |
||||
/* Encoding/decoding tables |
||||
/********************************************************** |
||||
*/ |
||||
|
||||
/** |
||||
* Decoding table used for base 64 decoding. |
||||
*/ |
||||
private final transient int[] _asciiToBase64 = new int[128]; |
||||
|
||||
/** |
||||
* Encoding table used for base 64 decoding when output is done |
||||
* as characters. |
||||
*/ |
||||
private final transient char[] _base64ToAsciiC = new char[64]; |
||||
|
||||
/** |
||||
* Alternative encoding table used for base 64 decoding when output is done |
||||
* as ascii bytes. |
||||
*/ |
||||
private final transient byte[] _base64ToAsciiB = new byte[64]; |
||||
|
||||
/* |
||||
/********************************************************** |
||||
/* Other configuration |
||||
/********************************************************** |
||||
*/ |
||||
|
||||
/** |
||||
* Symbolic name of variant; used for diagnostics/debugging. |
||||
*<p> |
||||
* Note that this is the only non-transient field; used when reading |
||||
* back from serialized state |
||||
*/ |
||||
protected final String _name; |
||||
|
||||
/** |
||||
* Whether this variant uses padding or not. |
||||
*/ |
||||
protected final transient boolean _usesPadding; |
||||
|
||||
/** |
||||
* Characted used for padding, if any ({@link #PADDING_CHAR_NONE} if not). |
||||
*/ |
||||
protected final transient char _paddingChar; |
||||
|
||||
/** |
||||
* Maximum number of encoded base64 characters to output during encoding |
||||
* before adding a linefeed, if line length is to be limited |
||||
* ({@link java.lang.Integer#MAX_VALUE} if not limited). |
||||
*<p> |
||||
* Note: for some output modes (when writing attributes) linefeeds may |
||||
* need to be avoided, and this value ignored. |
||||
*/ |
||||
protected final transient int _maxLineLength; |
||||
|
||||
/* |
||||
/********************************************************** |
||||
/* Life-cycle |
||||
/********************************************************** |
||||
*/ |
||||
|
||||
public Base64Variant(String name, String base64Alphabet, boolean usesPadding, char paddingChar, int maxLineLength) |
||||
{ |
||||
_name = name; |
||||
_usesPadding = usesPadding; |
||||
_paddingChar = paddingChar; |
||||
_maxLineLength = maxLineLength; |
||||
|
||||
// Ok and then we need to create codec tables.
|
||||
|
||||
// First the main encoding table:
|
||||
int alphaLen = base64Alphabet.length(); |
||||
if (alphaLen != 64) { |
||||
throw new IllegalArgumentException("Base64Alphabet length must be exactly 64 (was "+alphaLen+")"); |
||||
} |
||||
|
||||
// And then secondary encoding table and decoding table:
|
||||
base64Alphabet.getChars(0, alphaLen, _base64ToAsciiC, 0); |
||||
Arrays.fill(_asciiToBase64, BASE64_VALUE_INVALID); |
||||
for (int i = 0; i < alphaLen; ++i) { |
||||
char alpha = _base64ToAsciiC[i]; |
||||
_base64ToAsciiB[i] = (byte) alpha; |
||||
_asciiToBase64[alpha] = i; |
||||
} |
||||
|
||||
// Plus if we use padding, add that in too
|
||||
if (usesPadding) { |
||||
_asciiToBase64[(int) paddingChar] = BASE64_VALUE_PADDING; |
||||
} |
||||
} |
||||
|
||||
/** |
||||
* "Copy constructor" that can be used when the base alphabet is identical |
||||
* to one used by another variant except for the maximum line length |
||||
* (and obviously, name). |
||||
*/ |
||||
public Base64Variant(Base64Variant base, String name, int maxLineLength) |
||||
{ |
||||
this(base, name, base._usesPadding, base._paddingChar, maxLineLength); |
||||
} |
||||
|
||||
/** |
||||
* "Copy constructor" that can be used when the base alphabet is identical |
||||
* to one used by another variant, but other details (padding, maximum |
||||
* line length) differ |
||||
*/ |
||||
public Base64Variant(Base64Variant base, String name, boolean usesPadding, char paddingChar, int maxLineLength) |
||||
{ |
||||
_name = name; |
||||
byte[] srcB = base._base64ToAsciiB; |
||||
System.arraycopy(srcB, 0, this._base64ToAsciiB, 0, srcB.length); |
||||
char[] srcC = base._base64ToAsciiC; |
||||
System.arraycopy(srcC, 0, this._base64ToAsciiC, 0, srcC.length); |
||||
int[] srcV = base._asciiToBase64; |
||||
System.arraycopy(srcV, 0, this._asciiToBase64, 0, srcV.length); |
||||
|
||||
_usesPadding = usesPadding; |
||||
_paddingChar = paddingChar; |
||||
_maxLineLength = maxLineLength; |
||||
} |
||||
|
||||
/* |
||||
/********************************************************** |
||||
/* Serializable overrides |
||||
/********************************************************** |
||||
*/ |
||||
|
||||
/** |
||||
* Method used to "demote" deserialized instances back to |
||||
* canonical ones |
||||
*/ |
||||
protected Object readResolve() { |
||||
return Base64Variants.valueOf(_name); |
||||
} |
||||
|
||||
/* |
||||
/********************************************************** |
||||
/* Public accessors |
||||
/********************************************************** |
||||
*/ |
||||
|
||||
public String getName() { return _name; } |
||||
|
||||
public boolean usesPadding() { return _usesPadding; } |
||||
public boolean usesPaddingChar(char c) { return c == _paddingChar; } |
||||
public boolean usesPaddingChar(int ch) { return ch == (int) _paddingChar; } |
||||
public char getPaddingChar() { return _paddingChar; } |
||||
public byte getPaddingByte() { return (byte)_paddingChar; } |
||||
|
||||
public int getMaxLineLength() { return _maxLineLength; } |
||||
|
||||
/* |
||||
/********************************************************** |
||||
/* Decoding support |
||||
/********************************************************** |
||||
*/ |
||||
|
||||
/** |
||||
* @return 6-bit decoded value, if valid character; |
||||
*/ |
||||
public int decodeBase64Char(char c) |
||||
{ |
||||
int ch = (int) c; |
||||
return (ch <= 127) ? _asciiToBase64[ch] : BASE64_VALUE_INVALID; |
||||
} |
||||
|
||||
public int decodeBase64Char(int ch) |
||||
{ |
||||
return (ch <= 127) ? _asciiToBase64[ch] : BASE64_VALUE_INVALID; |
||||
} |
||||
|
||||
public int decodeBase64Byte(byte b) |
||||
{ |
||||
int ch = (int) b; |
||||
return (ch <= 127) ? _asciiToBase64[ch] : BASE64_VALUE_INVALID; |
||||
} |
||||
|
||||
/* |
||||
/********************************************************** |
||||
/* Encoding support |
||||
/********************************************************** |
||||
*/ |
||||
|
||||
public char encodeBase64BitsAsChar(int value) |
||||
{ |
||||
/* Let's assume caller has done necessary checks; this |
||||
* method must be fast and inlinable |
||||
*/ |
||||
return _base64ToAsciiC[value]; |
||||
} |
||||
|
||||
/** |
||||
* Method that encodes given right-aligned (LSB) 24-bit value |
||||
* into 4 base64 characters, stored in given result buffer. |
||||
*/ |
||||
public int encodeBase64Chunk(int b24, char[] buffer, int ptr) |
||||
{ |
||||
buffer[ptr++] = _base64ToAsciiC[(b24 >> 18) & 0x3F]; |
||||
buffer[ptr++] = _base64ToAsciiC[(b24 >> 12) & 0x3F]; |
||||
buffer[ptr++] = _base64ToAsciiC[(b24 >> 6) & 0x3F]; |
||||
buffer[ptr++] = _base64ToAsciiC[b24 & 0x3F]; |
||||
return ptr; |
||||
} |
||||
|
||||
public void encodeBase64Chunk(StringBuilder sb, int b24) |
||||
{ |
||||
sb.append(_base64ToAsciiC[(b24 >> 18) & 0x3F]); |
||||
sb.append(_base64ToAsciiC[(b24 >> 12) & 0x3F]); |
||||
sb.append(_base64ToAsciiC[(b24 >> 6) & 0x3F]); |
||||
sb.append(_base64ToAsciiC[b24 & 0x3F]); |
||||
} |
||||
|
||||
/** |
||||
* Method that outputs partial chunk (which only encodes one |
||||
* or two bytes of data). Data given is still aligned same as if |
||||
* it as full data; that is, missing data is at the "right end" |
||||
* (LSB) of int. |
||||
* |
||||
* @param outputBytes Number of encoded bytes included (either 1 or 2) |
||||
*/ |
||||
public int encodeBase64Partial(int bits, int outputBytes, char[] buffer, int outPtr) |
||||
{ |
||||
buffer[outPtr++] = _base64ToAsciiC[(bits >> 18) & 0x3F]; |
||||
buffer[outPtr++] = _base64ToAsciiC[(bits >> 12) & 0x3F]; |
||||
if (_usesPadding) { |
||||
buffer[outPtr++] = (outputBytes == 2) ? |
||||
_base64ToAsciiC[(bits >> 6) & 0x3F] : _paddingChar; |
||||
buffer[outPtr++] = _paddingChar; |
||||
} else { |
||||
if (outputBytes == 2) { |
||||
buffer[outPtr++] = _base64ToAsciiC[(bits >> 6) & 0x3F]; |
||||
} |
||||
} |
||||
return outPtr; |
||||
} |
||||
|
||||
public void encodeBase64Partial(StringBuilder sb, int bits, int outputBytes) |
||||
{ |
||||
sb.append(_base64ToAsciiC[(bits >> 18) & 0x3F]); |
||||
sb.append(_base64ToAsciiC[(bits >> 12) & 0x3F]); |
||||
if (_usesPadding) { |
||||
sb.append((outputBytes == 2) ? |
||||
_base64ToAsciiC[(bits >> 6) & 0x3F] : _paddingChar); |
||||
sb.append(_paddingChar); |
||||
} else { |
||||
if (outputBytes == 2) { |
||||
sb.append(_base64ToAsciiC[(bits >> 6) & 0x3F]); |
||||
} |
||||
} |
||||
} |
||||
|
||||
public byte encodeBase64BitsAsByte(int value) |
||||
{ |
||||
// As with above, assuming it is 6-bit value
|
||||
return _base64ToAsciiB[value]; |
||||
} |
||||
|
||||
/** |
||||
* Method that encodes given right-aligned (LSB) 24-bit value |
||||
* into 4 base64 bytes (ascii), stored in given result buffer. |
||||
*/ |
||||
public int encodeBase64Chunk(int b24, byte[] buffer, int ptr) |
||||
{ |
||||
buffer[ptr++] = _base64ToAsciiB[(b24 >> 18) & 0x3F]; |
||||
buffer[ptr++] = _base64ToAsciiB[(b24 >> 12) & 0x3F]; |
||||
buffer[ptr++] = _base64ToAsciiB[(b24 >> 6) & 0x3F]; |
||||
buffer[ptr++] = _base64ToAsciiB[b24 & 0x3F]; |
||||
return ptr; |
||||
} |
||||
|
||||
/** |
||||
* Method that outputs partial chunk (which only encodes one |
||||
* or two bytes of data). Data given is still aligned same as if |
||||
* it as full data; that is, missing data is at the "right end" |
||||
* (LSB) of int. |
||||
* |
||||
* @param outputBytes Number of encoded bytes included (either 1 or 2) |
||||
*/ |
||||
public int encodeBase64Partial(int bits, int outputBytes, byte[] buffer, int outPtr) |
||||
{ |
||||
buffer[outPtr++] = _base64ToAsciiB[(bits >> 18) & 0x3F]; |
||||
buffer[outPtr++] = _base64ToAsciiB[(bits >> 12) & 0x3F]; |
||||
if (_usesPadding) { |
||||
byte pb = (byte) _paddingChar; |
||||
buffer[outPtr++] = (outputBytes == 2) ? |
||||
_base64ToAsciiB[(bits >> 6) & 0x3F] : pb; |
||||
buffer[outPtr++] = pb; |
||||
} else { |
||||
if (outputBytes == 2) { |
||||
buffer[outPtr++] = _base64ToAsciiB[(bits >> 6) & 0x3F]; |
||||
} |
||||
} |
||||
return outPtr; |
||||
} |
||||
|
||||
/* |
||||
/********************************************************** |
||||
/* Convenience conversion methods for String to/from bytes |
||||
/* use case. |
||||
/********************************************************** |
||||
*/ |
||||
|
||||
/** |
||||
* Convenience method for converting given byte array as base64 encoded |
||||
* String using this variant's settings. |
||||
* Resulting value is "raw", that is, not enclosed in double-quotes. |
||||
* |
||||
* @param input Byte array to encode |
||||
*/ |
||||
public String encode(byte[] input) |
||||
{ |
||||
return encode(input, false); |
||||
} |
||||
|
||||
/** |
||||
* Convenience method for converting given byte array as base64 encoded String |
||||
* using this variant's settings, |
||||
* optionally enclosed in double-quotes. |
||||
* |
||||
* @param input Byte array to encode |
||||
* @param addQuotes Whether to surround resulting value in double quotes or not |
||||
*/ |
||||
public String encode(byte[] input, boolean addQuotes) |
||||
{ |
||||
int inputEnd = input.length; |
||||
StringBuilder sb; |
||||
{ |
||||
// let's approximate... 33% overhead, ~= 3/8 (0.375)
|
||||
int outputLen = inputEnd + (inputEnd >> 2) + (inputEnd >> 3); |
||||
sb = new StringBuilder(outputLen); |
||||
} |
||||
if (addQuotes) { |
||||
sb.append('"'); |
||||
} |
||||
|
||||
int chunksBeforeLF = getMaxLineLength() >> 2; |
||||
|
||||
// Ok, first we loop through all full triplets of data:
|
||||
int inputPtr = 0; |
||||
int safeInputEnd = inputEnd-3; // to get only full triplets
|
||||
|
||||
while (inputPtr <= safeInputEnd) { |
||||
// First, mash 3 bytes into lsb of 32-bit int
|
||||
int b24 = ((int) input[inputPtr++]) << 8; |
||||
b24 |= ((int) input[inputPtr++]) & 0xFF; |
||||
b24 = (b24 << 8) | (((int) input[inputPtr++]) & 0xFF); |
||||
encodeBase64Chunk(sb, b24); |
||||
if (--chunksBeforeLF <= 0) { |
||||
// note: must quote in JSON value, so not really useful...
|
||||
sb.append('\\'); |
||||
sb.append('n'); |
||||
chunksBeforeLF = getMaxLineLength() >> 2; |
||||
} |
||||
} |
||||
|
||||
// And then we may have 1 or 2 leftover bytes to encode
|
||||
int inputLeft = inputEnd - inputPtr; // 0, 1 or 2
|
||||
if (inputLeft > 0) { // yes, but do we have room for output?
|
||||
int b24 = ((int) input[inputPtr++]) << 16; |
||||
if (inputLeft == 2) { |
||||
b24 |= (((int) input[inputPtr++]) & 0xFF) << 8; |
||||
} |
||||
encodeBase64Partial(sb, b24, inputLeft); |
||||
} |
||||
|
||||
if (addQuotes) { |
||||
sb.append('"'); |
||||
} |
||||
return sb.toString(); |
||||
} |
||||
|
||||
/** |
||||
* Convenience method for decoding contents of a Base64-encoded String, |
||||
* using this variant's settings. |
||||
* |
||||
* @param input |
||||
* |
||||
* @since 2.2.3 |
||||
* |
||||
* @throws IllegalArgumentException if input is not valid base64 encoded data |
||||
*/ |
||||
@SuppressWarnings("resource") |
||||
public byte[] decode(String input) throws IllegalArgumentException |
||||
{ |
||||
ByteArrayBuilder b = new ByteArrayBuilder(); |
||||
decode(input, b); |
||||
return b.toByteArray(); |
||||
} |
||||
|
||||
/** |
||||
* Convenience method for decoding contents of a Base64-encoded String, |
||||
* using this variant's settings |
||||
* and appending decoded binary data using provided {@link ByteArrayBuilder}. |
||||
*<p> |
||||
* NOTE: builder will NOT be reset before decoding (nor cleared afterwards); |
||||
* assumption is that caller will ensure it is given in proper state, and |
||||
* used as appropriate afterwards. |
||||
* |
||||
* @since 2.2.3 |
||||
* |
||||
* @throws IllegalArgumentException if input is not valid base64 encoded data |
||||
*/ |
||||
public void decode(String str, ByteArrayBuilder builder) throws IllegalArgumentException |
||||
{ |
||||
int ptr = 0; |
||||
int len = str.length(); |
||||
|
||||
main_loop: |
||||
while (ptr < len) { |
||||
// first, we'll skip preceding white space, if any
|
||||
char ch; |
||||
do { |
||||
ch = str.charAt(ptr++); |
||||
if (ptr >= len) { |
||||
break main_loop; |
||||
} |
||||
} while (ch <= INT_SPACE); |
||||
int bits = decodeBase64Char(ch); |
||||
if (bits < 0) { |
||||
_reportInvalidBase64(ch, 0, null); |
||||
} |
||||
int decodedData = bits; |
||||
// then second base64 char; can't get padding yet, nor ws
|
||||
if (ptr >= len) { |
||||
_reportBase64EOF(); |
||||
} |
||||
ch = str.charAt(ptr++); |
||||
bits = decodeBase64Char(ch); |
||||
if (bits < 0) { |
||||
_reportInvalidBase64(ch, 1, null); |
||||
} |
||||
decodedData = (decodedData << 6) | bits; |
||||
// third base64 char; can be padding, but not ws
|
||||
if (ptr >= len) { |
||||
// but as per [JACKSON-631] can be end-of-input, iff not using padding
|
||||
if (!usesPadding()) { |
||||
decodedData >>= 4; |
||||
builder.append(decodedData); |
||||
break; |
||||
} |
||||
_reportBase64EOF(); |
||||
} |
||||
ch = str.charAt(ptr++); |
||||
bits = decodeBase64Char(ch); |
||||
|
||||
// First branch: can get padding (-> 1 byte)
|
||||
if (bits < 0) { |
||||
if (bits != Base64Variant.BASE64_VALUE_PADDING) { |
||||
_reportInvalidBase64(ch, 2, null); |
||||
} |
||||
// Ok, must get padding
|
||||
if (ptr >= len) { |
||||
_reportBase64EOF(); |
||||
} |
||||
ch = str.charAt(ptr++); |
||||
if (!usesPaddingChar(ch)) { |
||||
_reportInvalidBase64(ch, 3, "expected padding character '"+getPaddingChar()+"'"); |
||||
} |
||||
// Got 12 bits, only need 8, need to shift
|
||||
decodedData >>= 4; |
||||
builder.append(decodedData); |
||||
continue; |
||||
} |
||||
// Nope, 2 or 3 bytes
|
||||
decodedData = (decodedData << 6) | bits; |
||||
// fourth and last base64 char; can be padding, but not ws
|
||||
if (ptr >= len) { |
||||
// but as per [JACKSON-631] can be end-of-input, iff not using padding
|
||||
if (!usesPadding()) { |
||||
decodedData >>= 2; |
||||
builder.appendTwoBytes(decodedData); |
||||
break; |
||||
} |
||||
_reportBase64EOF(); |
||||
} |
||||
ch = str.charAt(ptr++); |
||||
bits = decodeBase64Char(ch); |
||||
if (bits < 0) { |
||||
if (bits != Base64Variant.BASE64_VALUE_PADDING) { |
||||
_reportInvalidBase64(ch, 3, null); |
||||
} |
||||
decodedData >>= 2; |
||||
builder.appendTwoBytes(decodedData); |
||||
} else { |
||||
// otherwise, our triple is now complete
|
||||
decodedData = (decodedData << 6) | bits; |
||||
builder.appendThreeBytes(decodedData); |
||||
} |
||||
} |
||||
} |
||||
|
||||
/* |
||||
/********************************************************** |
||||
/* Overridden standard methods |
||||
/********************************************************** |
||||
*/ |
||||
|
||||
@Override |
||||
public String toString() { return _name; } |
||||
|
||||
@Override |
||||
public boolean equals(Object o) { |
||||
// identity comparison should be dine
|
||||
return (o == this); |
||||
} |
||||
|
||||
@Override |
||||
public int hashCode() { |
||||
return _name.hashCode(); |
||||
} |
||||
|
||||
/* |
||||
/********************************************************** |
||||
/* Internal helper methods |
||||
/********************************************************** |
||||
*/ |
||||
|
||||
/** |
||||
* @param bindex Relative index within base64 character unit; between 0 |
||||
* and 3 (as unit has exactly 4 characters) |
||||
*/ |
||||
protected void _reportInvalidBase64(char ch, int bindex, String msg) |
||||
throws IllegalArgumentException |
||||
{ |
||||
String base; |
||||
if (ch <= INT_SPACE) { |
||||
base = "Illegal white space character (code 0x"+Integer.toHexString(ch)+") as character #"+(bindex+1)+" of 4-char base64 unit: can only used between units"; |
||||
} else if (usesPaddingChar(ch)) { |
||||
base = "Unexpected padding character ('"+getPaddingChar()+"') as character #"+(bindex+1)+" of 4-char base64 unit: padding only legal as 3rd or 4th character"; |
||||
} else if (!Character.isDefined(ch) || Character.isISOControl(ch)) { |
||||
// Not sure if we can really get here... ? (most illegal xml chars are caught at lower level)
|
||||
base = "Illegal character (code 0x"+Integer.toHexString(ch)+") in base64 content"; |
||||
} else { |
||||
base = "Illegal character '"+ch+"' (code 0x"+Integer.toHexString(ch)+") in base64 content"; |
||||
} |
||||
if (msg != null) { |
||||
base = base + ": " + msg; |
||||
} |
||||
throw new IllegalArgumentException(base); |
||||
} |
||||
|
||||
protected void _reportBase64EOF() throws IllegalArgumentException { |
||||
throw new IllegalArgumentException("Unexpected end-of-String in base64 content"); |
||||
} |
||||
} |
||||
|
@ -0,0 +1,111 @@
|
||||
/* Jackson JSON-processor. |
||||
* |
||||
* Copyright (c) 2007- Tatu Saloranta, tatu.saloranta@iki.fi |
||||
*/ |
||||
package com.fr.third.fasterxml.jackson.core; |
||||
|
||||
/** |
||||
* Container for commonly used Base64 variants: |
||||
*<ul> |
||||
* <li> {@link #MIME} |
||||
* <li> {@link #MIME_NO_LINEFEEDS} |
||||
* <li> {@link #PEM} |
||||
* <li> {@link #MODIFIED_FOR_URL} |
||||
* </ul> |
||||
* |
||||
* @author Tatu Saloranta |
||||
*/ |
||||
public final class Base64Variants |
||||
{ |
||||
final static String STD_BASE64_ALPHABET = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; |
||||
|
||||
/** |
||||
* This variant is what most people would think of "the standard" |
||||
* Base64 encoding. |
||||
*<p> |
||||
* See <a href="">wikipedia Base64 entry</a> for details. |
||||
*<p> |
||||
* Note that although this can be thought of as the standard variant, |
||||
* it is <b>not</b> the default for Jackson: no-linefeeds alternative |
||||
* is because of JSON requirement of escaping all linefeeds. |
||||
*/ |
||||
public final static Base64Variant MIME; |
||||
static { |
||||
MIME = new Base64Variant("MIME", STD_BASE64_ALPHABET, true, '=', 76); |
||||
} |
||||
|
||||
/** |
||||
* Slightly non-standard modification of {@link #MIME} which does not |
||||
* use linefeeds (max line length set to infinite). Useful when linefeeds |
||||
* wouldn't work well (possibly in attributes), or for minor space savings |
||||
* (save 1 linefeed per 76 data chars, ie. ~1.4% savings). |
||||
*/ |
||||
public final static Base64Variant MIME_NO_LINEFEEDS; |
||||
static { |
||||
MIME_NO_LINEFEEDS = new Base64Variant(MIME, "MIME-NO-LINEFEEDS", Integer.MAX_VALUE); |
||||
} |
||||
|
||||
/** |
||||
* This variant is the one that predates {@link #MIME}: it is otherwise |
||||
* identical, except that it mandates shorter line length. |
||||
*/ |
||||
public final static Base64Variant PEM = new Base64Variant(MIME, "PEM", true, '=', 64); |
||||
|
||||
/** |
||||
* This non-standard variant is usually used when encoded data needs to be |
||||
* passed via URLs (such as part of GET request). It differs from the |
||||
* base {@link #MIME} variant in multiple ways. |
||||
* First, no padding is used: this also means that it generally can not |
||||
* be written in multiple separate but adjacent chunks (which would not |
||||
* be the usual use case in any case). Also, no linefeeds are used (max |
||||
* line length set to infinite). And finally, two characters (plus and |
||||
* slash) that would need quoting in URLs are replaced with more |
||||
* optimal alternatives (hyphen and underscore, respectively). |
||||
*/ |
||||
public final static Base64Variant MODIFIED_FOR_URL; |
||||
static { |
||||
StringBuffer sb = new StringBuffer(STD_BASE64_ALPHABET); |
||||
// Replace plus with hyphen, slash with underscore (and no padding)
|
||||
sb.setCharAt(sb.indexOf("+"), '-'); |
||||
sb.setCharAt(sb.indexOf("/"), '_'); |
||||
/* And finally, let's not split lines either, wouldn't work too |
||||
* well with URLs |
||||
*/ |
||||
MODIFIED_FOR_URL = new Base64Variant("MODIFIED-FOR-URL", sb.toString(), false, Base64Variant.PADDING_CHAR_NONE, Integer.MAX_VALUE); |
||||
} |
||||
|
||||
/** |
||||
* Method used to get the default variant ("MIME_NO_LINEFEEDS") for cases |
||||
* where caller does not explicitly specify the variant. |
||||
* We will prefer no-linefeed version because linefeeds in JSON values |
||||
* must be escaped, making linefeed-containing variants sub-optimal. |
||||
*/ |
||||
public static Base64Variant getDefaultVariant() { |
||||
return MIME_NO_LINEFEEDS; |
||||
} |
||||
|
||||
/** |
||||
* @since 2.1 |
||||
*/ |
||||
public static Base64Variant valueOf(String name) throws IllegalArgumentException |
||||
{ |
||||
if (MIME._name.equals(name)) { |
||||
return MIME; |
||||
} |
||||
if (MIME_NO_LINEFEEDS._name.equals(name)) { |
||||
return MIME_NO_LINEFEEDS; |
||||
} |
||||
if (PEM._name.equals(name)) { |
||||
return PEM; |
||||
} |
||||
if (MODIFIED_FOR_URL._name.equals(name)) { |
||||
return MODIFIED_FOR_URL; |
||||
} |
||||
if (name == null) { |
||||
name = "<null>"; |
||||
} else { |
||||
name = "'"+name+"'"; |
||||
} |
||||
throw new IllegalArgumentException("No Base64Variant with name "+name); |
||||
} |
||||
} |
@ -0,0 +1,32 @@
|
||||
/* Jackson JSON-processor. |
||||
* |
||||
* Copyright (c) 2007- Tatu Saloranta, tatu.saloranta@iki.fi |
||||
*/ |
||||
|
||||
package com.fr.third.fasterxml.jackson.core; |
||||
|
||||
/** |
||||
* Simple tag interface used to mark schema objects that are used by some |
||||
* {@link JsonParser} and {@link JsonGenerator} implementations to further |
||||
* specify structure of expected format. |
||||
* Basic JSON-based parsers and generators do not use schemas, but some data |
||||
* formats (like many binary data formats like Thrift, protobuf) mandate |
||||
* use of schemas. |
||||
*<p> |
||||
* Since there is little commonality between schemas for different data formats, |
||||
* this interface does not define much meaningful functionality for accessing |
||||
* schema details; rather, specific parser and generator implementations need |
||||
* to cast to schema implementations they use. This marker interface is mostly |
||||
* used for tagging "some kind of schema" -- instead of passing opaque |
||||
* {@link java.lang.Object} -- for documentation purposes. |
||||
*/ |
||||
public interface FormatSchema |
||||
{ |
||||
/** |
||||
* Method that can be used to get an identifier that can be used for diagnostics |
||||
* purposes, to indicate what kind of data format this schema is used for: typically |
||||
* it is a short name of format itself, but it can also contain additional information |
||||
* in cases where data format supports multiple types of schemas. |
||||
*/ |
||||
String getSchemaType(); |
||||
} |
@ -0,0 +1,57 @@
|
||||
/* Jackson JSON-processor. |
||||
* |
||||
* Copyright (c) 2007- Tatu Saloranta, tatu.saloranta@iki.fi |
||||
*/ |
||||
|
||||
package com.fr.third.fasterxml.jackson.core; |
||||
|
||||
/** |
||||
* Enumeration that defines legal encodings that can be used |
||||
* for JSON content, based on list of allowed encodings from |
||||
* <a href="http://www.ietf.org/rfc/rfc4627.txt">JSON specification</a>. |
||||
*<p> |
||||
* Note: if application want to explicitly disregard Encoding |
||||
* limitations (to read in JSON encoded using an encoding not |
||||
* listed as allowed), they can use {@link java.io.Reader} / |
||||
* {@link java.io.Writer} instances as input |
||||
*/ |
||||
public enum JsonEncoding { |
||||
UTF8("UTF-8", false, 8), // N/A for big-endian, really
|
||||
UTF16_BE("UTF-16BE", true, 16), |
||||
UTF16_LE("UTF-16LE", false, 16), |
||||
UTF32_BE("UTF-32BE", true, 32), |
||||
UTF32_LE("UTF-32LE", false, 32) |
||||
; |
||||
|
||||
protected final String _javaName; |
||||
|
||||
protected final boolean _bigEndian; |
||||
|
||||
protected final int _bits; |
||||
|
||||
JsonEncoding(String javaName, boolean bigEndian, int bits) |
||||
{ |
||||
_javaName = javaName; |
||||
_bigEndian = bigEndian; |
||||
_bits = bits; |
||||
} |
||||
|
||||
/** |
||||
* Method for accessing encoding name that JDK will support. |
||||
* |
||||
* @return Matching encoding name that JDK will support. |
||||
*/ |
||||
public String getJavaName() { return _javaName; } |
||||
|
||||
/** |
||||
* Whether encoding is big-endian (if encoding supports such |
||||
* notion). If no such distinction is made (as is the case for |
||||
* {@link #UTF8}), return value is undefined. |
||||
* |
||||
* @return True for big-endian encodings; false for little-endian |
||||
* (or if not applicable) |
||||
*/ |
||||
public boolean isBigEndian() { return _bigEndian; } |
||||
|
||||
public int bits() { return _bits; } |
||||
} |
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,32 @@
|
||||
/* Jackson JSON-processor. |
||||
* |
||||
* Copyright (c) 2007- Tatu Saloranta, tatu.saloranta@iki.fi |
||||
*/ |
||||
|
||||
package com.fr.third.fasterxml.jackson.core; |
||||
|
||||
/** |
||||
* Exception type for exceptions during JSON writing, such as trying |
||||
* to output content in wrong context (non-matching end-array or end-object, |
||||
* for example). |
||||
*/ |
||||
public class JsonGenerationException |
||||
extends JsonProcessingException |
||||
{ |
||||
private final static long serialVersionUID = 123; // Stupid eclipse...
|
||||
|
||||
public JsonGenerationException(Throwable rootCause) |
||||
{ |
||||
super(rootCause); |
||||
} |
||||
|
||||
public JsonGenerationException(String msg) |
||||
{ |
||||
super(msg, (JsonLocation)null); |
||||
} |
||||
|
||||
public JsonGenerationException(String msg, Throwable rootCause) |
||||
{ |
||||
super(msg, (JsonLocation)null, rootCause); |
||||
} |
||||
} |
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,139 @@
|
||||
/* Jackson JSON-processor. |
||||
* |
||||
* Copyright (c) 2007- Tatu Saloranta, tatu.saloranta@iki.fi |
||||
*/ |
||||
|
||||
package com.fr.third.fasterxml.jackson.core; |
||||
|
||||
/** |
||||
* Object that encapsulates Location information used for reporting |
||||
* parsing (or potentially generation) errors, as well as current location |
||||
* within input streams. |
||||
*/ |
||||
public class JsonLocation |
||||
implements java.io.Serializable // as per [JACKSON-168]
|
||||
{ |
||||
private static final long serialVersionUID = 1L; |
||||
|
||||
/** |
||||
* Shared immutable "N/A location" that can be returned to indicate |
||||
* that no location information is available |
||||
*/ |
||||
public final static JsonLocation NA = new JsonLocation("N/A", -1L, -1L, -1, -1); |
||||
|
||||
final long _totalBytes; |
||||
final long _totalChars; |
||||
|
||||
final int _lineNr; |
||||
final int _columnNr; |
||||
|
||||
/** |
||||
* Displayable description for input source: file path, URL. |
||||
*<p> |
||||
* NOTE: <code>transient</code> since 2.2 so that Location itself is Serializable. |
||||
*/ |
||||
final transient Object _sourceRef; |
||||
|
||||
public JsonLocation(Object srcRef, long totalChars, int lineNr, int colNr) |
||||
{ |
||||
/* Unfortunately, none of legal encodings are straight single-byte |
||||
* encodings. Could determine offset for UTF-16/UTF-32, but the |
||||
* most important one is UTF-8... |
||||
* so for now, we'll just not report any real byte count |
||||
*/ |
||||
this(srcRef, -1L, totalChars, lineNr, colNr); |
||||
} |
||||
|
||||
public JsonLocation(Object sourceRef, long totalBytes, long totalChars, |
||||
int lineNr, int columnNr) |
||||
{ |
||||
_sourceRef = sourceRef; |
||||
_totalBytes = totalBytes; |
||||
_totalChars = totalChars; |
||||
_lineNr = lineNr; |
||||
_columnNr = columnNr; |
||||
} |
||||
|
||||
/** |
||||
* Reference to the original resource being read, if one available. |
||||
* For example, when a parser has been constructed by passing |
||||
* a {@link java.io.File} instance, this method would return |
||||
* that File. Will return null if no such reference is available, |
||||
* for example when {@link java.io.InputStream} was used to |
||||
* construct the parser instance. |
||||
*/ |
||||
public Object getSourceRef() { return _sourceRef; } |
||||
|
||||
/** |
||||
* @return Line number of the location (1-based) |
||||
*/ |
||||
public int getLineNr() { return _lineNr; } |
||||
|
||||
/** |
||||
* @return Column number of the location (1-based) |
||||
*/ |
||||
public int getColumnNr() { return _columnNr; } |
||||
|
||||
/** |
||||
* @return Character offset within underlying stream, reader or writer, |
||||
* if available; -1 if not. |
||||
*/ |
||||
public long getCharOffset() { return _totalChars; } |
||||
|
||||
/** |
||||
* @return Byte offset within underlying stream, reader or writer, |
||||
* if available; -1 if not. |
||||
*/ |
||||
public long getByteOffset() |
||||
{ |
||||
return _totalBytes; |
||||
} |
||||
|
||||
@Override |
||||
public String toString() |
||||
{ |
||||
StringBuilder sb = new StringBuilder(80); |
||||
sb.append("[Source: "); |
||||
if (_sourceRef == null) { |
||||
sb.append("UNKNOWN"); |
||||
} else { |
||||
sb.append(_sourceRef.toString()); |
||||
} |
||||
sb.append("; line: "); |
||||
sb.append(_lineNr); |
||||
sb.append(", column: "); |
||||
sb.append(_columnNr); |
||||
sb.append(']'); |
||||
return sb.toString(); |
||||
} |
||||
|
||||
@Override |
||||
public int hashCode() |
||||
{ |
||||
int hash = (_sourceRef == null) ? 1 : _sourceRef.hashCode(); |
||||
hash ^= _lineNr; |
||||
hash += _columnNr; |
||||
hash ^= (int) _totalChars; |
||||
hash += (int) _totalBytes; |
||||
return hash; |
||||
} |
||||
|
||||
@Override |
||||
public boolean equals(Object other) |
||||
{ |
||||
if (other == this) return true; |
||||
if (other == null) return false; |
||||
if (!(other instanceof JsonLocation)) return false; |
||||
JsonLocation otherLoc = (JsonLocation) other; |
||||
|
||||
if (_sourceRef == null) { |
||||
if (otherLoc._sourceRef != null) return false; |
||||
} else if (!_sourceRef.equals(otherLoc._sourceRef)) return false; |
||||
|
||||
return (_lineNr == otherLoc._lineNr) |
||||
&& (_columnNr == otherLoc._columnNr) |
||||
&& (_totalChars == otherLoc._totalChars) |
||||
&& (getByteOffset() == otherLoc.getByteOffset()) |
||||
; |
||||
} |
||||
} |
@ -0,0 +1,27 @@
|
||||
/* Jackson JSON-processor. |
||||
* |
||||
* Copyright (c) 2007- Tatu Saloranta, tatu.saloranta@iki.fi |
||||
*/ |
||||
|
||||
package com.fr.third.fasterxml.jackson.core; |
||||
|
||||
/** |
||||
* Exception type for parsing problems, used when non-well-formed content |
||||
* (content that does not conform to JSON syntax as per specification) |
||||
* is encountered. |
||||
*/ |
||||
public class JsonParseException |
||||
extends JsonProcessingException |
||||
{ |
||||
private static final long serialVersionUID = 1L; |
||||
|
||||
public JsonParseException(String msg, JsonLocation loc) |
||||
{ |
||||
super(msg, loc); |
||||
} |
||||
|
||||
public JsonParseException(String msg, JsonLocation loc, Throwable root) |
||||
{ |
||||
super(msg, loc, root); |
||||
} |
||||
} |
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,269 @@
|
||||
package com.fr.third.fasterxml.jackson.core; |
||||
|
||||
import com.fr.third.fasterxml.jackson.core.io.NumberInput; |
||||
|
||||
/** |
||||
* Implementation of |
||||
* <a href="http://tools.ietf.org/html/draft-ietf-appsawg-json-pointer-03">JSON Pointer</a> |
||||
* specification. |
||||
* Pointer instances can be used to locate logical JSON nodes for things like |
||||
* tree traversal (see {@link TreeNode#at}). |
||||
* It may be used in future for filtering of streaming JSON content |
||||
* as well (not implemented yet for 2.3). |
||||
*<p> |
||||
* Instances are fully immutable and can be shared, cached. |
||||
* |
||||
* @author Tatu Saloranta |
||||
* |
||||
* @since 2.3 |
||||
*/ |
||||
public class JsonPointer |
||||
{ |
||||
/** |
||||
* Marker instance used to represent segment that matches current |
||||
* node or position. |
||||
*/ |
||||
protected final static JsonPointer EMPTY = new JsonPointer(); |
||||
|
||||
/** |
||||
* Reference to rest of the pointer beyond currently matching |
||||
* segment (if any); null if this pointer refers to a matching |
||||
* segment. |
||||
*/ |
||||
protected final JsonPointer _nextSegment; |
||||
|
||||
/** |
||||
* We will retain representation of the pointer, as a String, |
||||
* so that {@link #toString} should be as efficient as possible. |
||||
*/ |
||||
protected final String _asString; |
||||
|
||||
protected final String _matchingPropertyName; |
||||
|
||||
protected final int _matchingElementIndex; |
||||
|
||||
/* |
||||
/********************************************************** |
||||
/* Cosntruction |
||||
/********************************************************** |
||||
*/ |
||||
|
||||
/** |
||||
* Constructor used for creating "empty" instance, used to represent |
||||
* state that matches current node. |
||||
*/ |
||||
protected JsonPointer() { |
||||
_nextSegment = null; |
||||
_matchingPropertyName = ""; |
||||
_matchingElementIndex = -1; |
||||
_asString = ""; |
||||
} |
||||
|
||||
/** |
||||
* Constructor used for creating non-empty Segments |
||||
*/ |
||||
protected JsonPointer(String fullString, String segment, JsonPointer next) { |
||||
_asString = fullString; |
||||
_nextSegment = next; |
||||
// Ok; may always be a property
|
||||
_matchingPropertyName = segment; |
||||
_matchingElementIndex = _parseIndex(segment); |
||||
} |
||||
|
||||
/* |
||||
/********************************************************** |
||||
/* Factory methods |
||||
/********************************************************** |
||||
*/ |
||||
|
||||
/** |
||||
* Factory method that parses given input and construct matching pointer |
||||
* instance, if it represents a valid JSON Pointer: if not, a |
||||
* {@link IllegalArgumentException} is thrown. |
||||
* |
||||
* @throws IllegalArgumentException Thrown if the input does not present a valid JSON Pointer |
||||
* expression: currently the only such expression is one that does NOT start with |
||||
* a slash ('/'). |
||||
*/ |
||||
public static JsonPointer compile(String input) throws IllegalArgumentException |
||||
{ |
||||
// First quick checks for well-known 'empty' pointer
|
||||
if ((input == null) || input.length() == 0) { |
||||
return EMPTY; |
||||
} |
||||
// And then quick validity check:
|
||||
if (input.charAt(0) != '/') { |
||||
throw new IllegalArgumentException("Invalid input: JSON Pointer expression must start with '/': "+"\""+input+"\""); |
||||
} |
||||
return _parseTail(input); |
||||
} |
||||
|
||||
/** |
||||
* Alias for {@link #compile}; added to make instances automatically |
||||
* deserializable by Jackson databind. |
||||
*/ |
||||
public static JsonPointer valueOf(String input) { return compile(input); } |
||||
|
||||
/* Factory method that composes a pointer instance, given a set |
||||
* of 'raw' segments: raw meaning that no processing will be done, |
||||
* no escaping may is present. |
||||
* |
||||
* @param segments |
||||
* |
||||
* @return Constructed path instance |
||||
*/ |
||||
/* TODO! |
||||
public static JsonPointer fromSegment(String... segments) |
||||
{ |
||||
if (segments.length == 0) { |
||||
return EMPTY; |
||||
} |
||||
JsonPointer prev = null; |
||||
|
||||
for (String segment : segments) { |
||||
JsonPointer next = new JsonPointer() |
||||
} |
||||
} |
||||
*/ |
||||
|
||||
/* |
||||
/********************************************************** |
||||
/* Public API |
||||
/********************************************************** |
||||
*/ |
||||
|
||||
public boolean matches() { return _nextSegment == null; } |
||||
public String getMatchingProperty() { return _matchingPropertyName; } |
||||
public int getMatchingIndex() { return _matchingElementIndex; } |
||||
public boolean mayMatchProperty() { return _matchingPropertyName != null; } |
||||
public boolean mayMatchElement() { return _matchingElementIndex >= 0; } |
||||
|
||||
public JsonPointer matchProperty(String name) { |
||||
if (_nextSegment == null || !_matchingPropertyName.equals(name)) { |
||||
return null; |
||||
} |
||||
return _nextSegment; |
||||
} |
||||
|
||||
public JsonPointer matchElement (int index) { |
||||
if ((index != _matchingElementIndex) || (index < 0)) { |
||||
return null; |
||||
} |
||||
return _nextSegment; |
||||
} |
||||
|
||||
/** |
||||
* Accessor for getting a "sub-pointer", instance where current segment |
||||
* has been removed and pointer includes rest of segments; |
||||
*/ |
||||
public JsonPointer tail() { |
||||
return _nextSegment; |
||||
} |
||||
|
||||
/* |
||||
/********************************************************** |
||||
/* Standard method overrides |
||||
/********************************************************** |
||||
*/ |
||||
|
||||
@Override public String toString() { return _asString; } |
||||
@Override public int hashCode() { return _asString.hashCode(); } |
||||
|
||||
@Override public boolean equals(Object o) { |
||||
if (o == this) return true; |
||||
if (o == null) return false; |
||||
if (!(o instanceof JsonPointer)) return false; |
||||
return _asString.equals(((JsonPointer) o)._asString); |
||||
} |
||||
|
||||
/* |
||||
/********************************************************** |
||||
/* Internal methods |
||||
/********************************************************** |
||||
*/ |
||||
|
||||
private final static int _parseIndex(String str) { |
||||
final int len = str.length(); |
||||
// [Issue#133]: beware of super long indexes; assume we never
|
||||
// have arrays over 2 billion entries so ints are fine.
|
||||
if (len == 0 || len > 10) { |
||||
return -1; |
||||
} |
||||
for (int i = 0; i < len; ++i) { |
||||
char c = str.charAt(i++); |
||||
if (c > '9' || c < '0') { |
||||
return -1; |
||||
} |
||||
} |
||||
if (len == 10) { |
||||
long l = NumberInput.parseLong(str); |
||||
if (l > Integer.MAX_VALUE) { |
||||
return -1; |
||||
} |
||||
} |
||||
return NumberInput.parseInt(str); |
||||
} |
||||
|
||||
protected static JsonPointer _parseTail(String input) { |
||||
final int end = input.length(); |
||||
|
||||
// first char is the contextual slash, skip
|
||||
for (int i = 1; i < end; ) { |
||||
char c = input.charAt(i); |
||||
if (c == '/') { // common case, got a segment
|
||||
return new JsonPointer(input, input.substring(1, i), |
||||
_parseTail(input.substring(i))); |
||||
} |
||||
++i; |
||||
// quoting is different; offline this case
|
||||
if (c == '~' && i < end) { // possibly, quote
|
||||
return _parseQuotedTail(input, i); |
||||
} |
||||
// otherwise, loop on
|
||||
} |
||||
// end of the road, no escapes
|
||||
return new JsonPointer(input, input.substring(1), EMPTY); |
||||
} |
||||
|
||||
/** |
||||
* Method called to parse tail of pointer path, when a potentially |
||||
* escaped character has been seen. |
||||
* |
||||
* @param input Full input for the tail being parsed |
||||
* @param i Offset to character after tilde |
||||
*/ |
||||
protected static JsonPointer _parseQuotedTail(String input, int i) { |
||||
final int end = input.length(); |
||||
StringBuilder sb = new StringBuilder(Math.max(16, end)); |
||||
if (i > 2) { |
||||
sb.append(input, 1, i-1); |
||||
} |
||||
_appendEscape(sb, input.charAt(i++)); |
||||
while (i < end) { |
||||
char c = input.charAt(i); |
||||
if (c == '/') { // end is nigh!
|
||||
return new JsonPointer(input, sb.toString(), |
||||
_parseTail(input.substring(i))); // need to push back slash
|
||||
} |
||||
++i; |
||||
if (c == '~' && i < end) { |
||||
_appendEscape(sb, input.charAt(i++)); |
||||
continue; |
||||
} |
||||
sb.append(c); |
||||
} |
||||
// end of the road, last segment
|
||||
return new JsonPointer(input, sb.toString(), EMPTY); |
||||
} |
||||
|
||||
private static void _appendEscape(StringBuilder sb, char c) { |
||||
if (c == '0') { |
||||
c = '~'; |
||||
} else if (c == '1') { |
||||
c = '/'; |
||||
} else { |
||||
sb.append('~'); |
||||
} |
||||
sb.append(c); |
||||
} |
||||
} |
@ -0,0 +1,130 @@
|
||||
/* Jackson JSON-processor. |
||||
* |
||||
* Copyright (c) 2007- Tatu Saloranta, tatu.saloranta@iki.fi |
||||
*/ |
||||
|
||||
package com.fr.third.fasterxml.jackson.core; |
||||
|
||||
/** |
||||
* Intermediate base class for all problems encountered when |
||||
* processing (parsing, generating) JSON content |
||||
* that are not pure I/O problems. |
||||
* Regular {@link java.io.IOException}s will be passed through as is. |
||||
* Sub-class of {@link java.io.IOException} for convenience. |
||||
*/ |
||||
public class JsonProcessingException |
||||
extends java.io.IOException |
||||
{ |
||||
final static long serialVersionUID = 123; // Stupid eclipse...
|
||||
|
||||
protected JsonLocation _location; |
||||
|
||||
protected JsonProcessingException(String msg, JsonLocation loc, Throwable rootCause) |
||||
{ |
||||
/* Argh. IOException(Throwable,String) is only available starting |
||||
* with JDK 1.6... |
||||
*/ |
||||
super(msg); |
||||
if (rootCause != null) { |
||||
initCause(rootCause); |
||||
} |
||||
_location = loc; |
||||
} |
||||
|
||||
protected JsonProcessingException(String msg) |
||||
{ |
||||
super(msg); |
||||
} |
||||
|
||||
protected JsonProcessingException(String msg, JsonLocation loc) |
||||
{ |
||||
this(msg, loc, null); |
||||
} |
||||
|
||||
protected JsonProcessingException(String msg, Throwable rootCause) |
||||
{ |
||||
this(msg, null, rootCause); |
||||
} |
||||
|
||||
protected JsonProcessingException(Throwable rootCause) |
||||
{ |
||||
this(null, null, rootCause); |
||||
} |
||||
|
||||
public JsonLocation getLocation() { |
||||
return _location; |
||||
} |
||||
|
||||
/* |
||||
/********************************************************** |
||||
/* Extended API |
||||
/********************************************************** |
||||
*/ |
||||
|
||||
/** |
||||
* Method that allows accessing the original "message" argument, |
||||
* without additional decorations (like location information) |
||||
* that overridden {@link #getMessage} adds. |
||||
* |
||||
* @since 2.1 |
||||
*/ |
||||
public String getOriginalMessage() |
||||
{ |
||||
return super.getMessage(); |
||||
} |
||||
|
||||
/* |
||||
/********************************************************** |
||||
/* Methods for sub-classes to use, override |
||||
/********************************************************** |
||||
*/ |
||||
|
||||
/** |
||||
* Accessor that sub-classes can override to append additional |
||||
* information right after the main message, but before |
||||
* source location information. |
||||
*/ |
||||
protected String getMessageSuffix() { |
||||
return null; |
||||
} |
||||
|
||||
/* |
||||
/********************************************************** |
||||
/* Overrides of standard methods |
||||
/********************************************************** |
||||
*/ |
||||
|
||||
/** |
||||
* Default method overridden so that we can add location information |
||||
*/ |
||||
@Override |
||||
public String getMessage() |
||||
{ |
||||
String msg = super.getMessage(); |
||||
if (msg == null) { |
||||
msg = "N/A"; |
||||
} |
||||
JsonLocation loc = getLocation(); |
||||
String suffix = getMessageSuffix(); |
||||
// mild optimization, if nothing extra is needed:
|
||||
if (loc != null || suffix != null) { |
||||
StringBuilder sb = new StringBuilder(100); |
||||
sb.append(msg); |
||||
if (suffix != null) { |
||||
sb.append(suffix); |
||||
} |
||||
if (loc != null) { |
||||
sb.append('\n'); |
||||
sb.append(" at "); |
||||
sb.append(loc.toString()); |
||||
} |
||||
msg = sb.toString(); |
||||
} |
||||
return msg; |
||||
} |
||||
|
||||
@Override |
||||
public String toString() { |
||||
return getClass().getName()+": "+getMessage(); |
||||
} |
||||
} |
@ -0,0 +1,112 @@
|
||||
/* Jackson JSON-processor. |
||||
* |
||||
* Copyright (c) 2007- Tatu Saloranta, tatu.saloranta@iki.fi |
||||
*/ |
||||
|
||||
package com.fr.third.fasterxml.jackson.core; |
||||
|
||||
/** |
||||
* Shared base class for streaming processing contexts used during |
||||
* reading and writing of Json content using Streaming API. |
||||
* This context is also exposed to applications: |
||||
* context object can be used by applications to get an idea of |
||||
* relative position of the parser/generator within json content |
||||
* being processed. This allows for some contextual processing: for |
||||
* example, output within Array context can differ from that of |
||||
* Object context. |
||||
*/ |
||||
public abstract class JsonStreamContext |
||||
{ |
||||
// // // Type constants used internally
|
||||
|
||||
protected final static int TYPE_ROOT = 0; |
||||
protected final static int TYPE_ARRAY = 1; |
||||
protected final static int TYPE_OBJECT = 2; |
||||
|
||||
protected int _type; |
||||
|
||||
/** |
||||
* Index of the currently processed entry. Starts with -1 to signal |
||||
* that no entries have been started, and gets advanced each |
||||
* time a new entry is started, either by encountering an expected |
||||
* separator, or with new values if no separators are expected |
||||
* (the case for root context). |
||||
*/ |
||||
protected int _index; |
||||
|
||||
/* |
||||
/********************************************************** |
||||
/* Life-cycle |
||||
/********************************************************** |
||||
*/ |
||||
|
||||
protected JsonStreamContext() { } |
||||
|
||||
/* |
||||
/********************************************************** |
||||
/* Public API, accessors |
||||
/********************************************************** |
||||
*/ |
||||
|
||||
/** |
||||
* Accessor for finding parent context of this context; will |
||||
* return null for root context. |
||||
*/ |
||||
public abstract JsonStreamContext getParent(); |
||||
|
||||
/** |
||||
* Method that returns true if this context is an Array context; |
||||
* that is, content is being read from or written to a Json Array. |
||||
*/ |
||||
public final boolean inArray() { return _type == TYPE_ARRAY; } |
||||
|
||||
/** |
||||
* Method that returns true if this context is a Root context; |
||||
* that is, content is being read from or written to without |
||||
* enclosing array or object structure. |
||||
*/ |
||||
public final boolean inRoot() { return _type == TYPE_ROOT; } |
||||
|
||||
/** |
||||
* Method that returns true if this context is an Object context; |
||||
* that is, content is being read from or written to a Json Object. |
||||
*/ |
||||
public final boolean inObject() { return _type == TYPE_OBJECT; } |
||||
|
||||
/** |
||||
* Method for accessing simple type description of current context; |
||||
* either ROOT (for root-level values), OBJECT (for field names and |
||||
* values of JSON Objects) or ARRAY (for values of JSON Arrays) |
||||
*/ |
||||
public final String getTypeDesc() { |
||||
switch (_type) { |
||||
case TYPE_ROOT: return "ROOT"; |
||||
case TYPE_ARRAY: return "ARRAY"; |
||||
case TYPE_OBJECT: return "OBJECT"; |
||||
} |
||||
return "?"; |
||||
} |
||||
|
||||
/** |
||||
* @return Number of entries that are complete and started. |
||||
*/ |
||||
public final int getEntryCount() |
||||
{ |
||||
return _index + 1; |
||||
} |
||||
|
||||
/** |
||||
* @return Index of the currently processed entry, if any |
||||
*/ |
||||
public final int getCurrentIndex() |
||||
{ |
||||
return (_index < 0) ? 0 : _index; |
||||
} |
||||
|
||||
/** |
||||
* Method for accessing name associated with the current location. |
||||
* Non-null for <code>FIELD_NAME</code> and value events that directly |
||||
* follow field names; null for root level and array values. |
||||
*/ |
||||
public abstract String getCurrentName(); |
||||
} |
@ -0,0 +1,212 @@
|
||||
/* Jackson JSON-processor. |
||||
* |
||||
* Copyright (c) 2007- Tatu Saloranta, tatu.saloranta@iki.fi |
||||
*/ |
||||
|
||||
package com.fr.third.fasterxml.jackson.core; |
||||
|
||||
/** |
||||
* Enumeration for basic token types used for returning results |
||||
* of parsing JSON content. |
||||
*/ |
||||
public enum JsonToken |
||||
{ |
||||
/* Some notes on implementation: |
||||
* |
||||
* - Entries are to be ordered such that start/end array/object |
||||
* markers come first, then field name marker (if any), and |
||||
* finally scalar value tokens. This is assumed by some |
||||
* typing checks. |
||||
*/ |
||||
|
||||
/** |
||||
* NOT_AVAILABLE can be returned if {@link JsonParser} |
||||
* implementation can not currently return the requested |
||||
* token (usually next one), or even if any will be |
||||
* available, but that may be able to determine this in |
||||
* future. This is the case with non-blocking parsers -- |
||||
* they can not block to wait for more data to parse and |
||||
* must return something. |
||||
*/ |
||||
NOT_AVAILABLE(null, JsonTokenId.ID_NOT_AVAILABLE), |
||||
|
||||
/** |
||||
* START_OBJECT is returned when encountering '{' |
||||
* which signals starting of an Object value. |
||||
*/ |
||||
START_OBJECT("{", JsonTokenId.ID_START_OBJECT), |
||||
|
||||
/** |
||||
* END_OBJECT is returned when encountering '}' |
||||
* which signals ending of an Object value |
||||
*/ |
||||
END_OBJECT("}", JsonTokenId.ID_END_OBJECT), |
||||
|
||||
/** |
||||
* START_ARRAY is returned when encountering '[' |
||||
* which signals starting of an Array value |
||||
*/ |
||||
START_ARRAY("[", JsonTokenId.ID_START_ARRAY), |
||||
|
||||
/** |
||||
* END_ARRAY is returned when encountering ']' |
||||
* which signals ending of an Array value |
||||
*/ |
||||
END_ARRAY("]", JsonTokenId.ID_END_ARRAY), |
||||
|
||||
/** |
||||
* FIELD_NAME is returned when a String token is encountered |
||||
* as a field name (same lexical value, different function) |
||||
*/ |
||||
FIELD_NAME(null, JsonTokenId.ID_FIELD_NAME), |
||||
|
||||
/** |
||||
* Placeholder token returned when the input source has a concept |
||||
* of embedded Object that are not accessible as usual structure |
||||
* (of starting with {@link #START_OBJECT}, having values, ending with |
||||
* {@link #END_OBJECT}), but as "raw" objects. |
||||
*<p> |
||||
* Note: this token is never returned by regular JSON readers, but |
||||
* only by readers that expose other kinds of source (like |
||||
* <code>JsonNode</code>-based JSON trees, Maps, Lists and such). |
||||
*/ |
||||
VALUE_EMBEDDED_OBJECT(null, JsonTokenId.ID_EMBEDDED_OBJECT), |
||||
|
||||
/** |
||||
* VALUE_STRING is returned when a String token is encountered |
||||
* in value context (array element, field value, or root-level |
||||
* stand-alone value) |
||||
*/ |
||||
VALUE_STRING(null, JsonTokenId.ID_STRING), |
||||
|
||||
/** |
||||
* VALUE_NUMBER_INT is returned when an integer numeric token is |
||||
* encountered in value context: that is, a number that does |
||||
* not have floating point or exponent marker in it (consists |
||||
* only of an optional sign, followed by one or more digits) |
||||
*/ |
||||
VALUE_NUMBER_INT(null, JsonTokenId.ID_NUMBER_INT), |
||||
|
||||
/** |
||||
* VALUE_NUMBER_INT is returned when a numeric token other |
||||
* that is not an integer is encountered: that is, a number that does |
||||
* have floating point or exponent marker in it, in addition |
||||
* to one or more digits. |
||||
*/ |
||||
VALUE_NUMBER_FLOAT(null, JsonTokenId.ID_NUMBER_FLOAT), |
||||
|
||||
/** |
||||
* VALUE_TRUE is returned when encountering literal "true" in |
||||
* value context |
||||
*/ |
||||
VALUE_TRUE("true", JsonTokenId.ID_TRUE), |
||||
|
||||
/** |
||||
* VALUE_FALSE is returned when encountering literal "false" in |
||||
* value context |
||||
*/ |
||||
VALUE_FALSE("false", JsonTokenId.ID_FALSE), |
||||
|
||||
/** |
||||
* VALUE_NULL is returned when encountering literal "null" in |
||||
* value context |
||||
*/ |
||||
VALUE_NULL("null", JsonTokenId.ID_NULL), |
||||
; |
||||
|
||||
final String _serialized; |
||||
|
||||
final char[] _serializedChars; |
||||
|
||||
final byte[] _serializedBytes; |
||||
|
||||
final int _id; |
||||
|
||||
final boolean _isStructStart, _isStructEnd; |
||||
|
||||
final boolean _isNumber; |
||||
|
||||
final boolean _isBoolean; |
||||
|
||||
final boolean _isScalar; |
||||
|
||||
/** |
||||
* @param token representation for this token, if there is a |
||||
* single static representation; null otherwise |
||||
*/ |
||||
JsonToken(String token, int id) |
||||
{ |
||||
if (token == null) { |
||||
_serialized = null; |
||||
_serializedChars = null; |
||||
_serializedBytes = null; |
||||
} else { |
||||
_serialized = token; |
||||
_serializedChars = token.toCharArray(); |
||||
// It's all in ascii, can just case...
|
||||
int len = _serializedChars.length; |
||||
_serializedBytes = new byte[len]; |
||||
for (int i = 0; i < len; ++i) { |
||||
_serializedBytes[i] = (byte) _serializedChars[i]; |
||||
} |
||||
} |
||||
_id = id; |
||||
|
||||
_isBoolean = (id == JsonTokenId.ID_FALSE || id == JsonTokenId.ID_TRUE); |
||||
_isNumber = (id == JsonTokenId.ID_NUMBER_INT || id == JsonTokenId.ID_NUMBER_FLOAT); |
||||
|
||||
_isStructStart = (id == JsonTokenId.ID_START_OBJECT || id == JsonTokenId.ID_START_ARRAY); |
||||
_isStructEnd = (id == JsonTokenId.ID_END_OBJECT || id == JsonTokenId.ID_END_ARRAY); |
||||
|
||||
_isScalar = !_isStructStart && !_isStructEnd |
||||
&& (id != JsonTokenId.ID_FIELD_NAME) |
||||
&& (id != JsonTokenId.ID_NOT_AVAILABLE); |
||||
} |
||||
|
||||
public final int id() { return _id; } |
||||
|
||||
public final String asString() { return _serialized; } |
||||
public final char[] asCharArray() { return _serializedChars; } |
||||
public final byte[] asByteArray() { return _serializedBytes; } |
||||
|
||||
public final boolean isNumeric() { |
||||
return _isNumber; |
||||
} |
||||
|
||||
/** |
||||
* Accessor that is functionally equivalent to: |
||||
* <code> |
||||
* this == JsonToken.START_OBJECT || this == JsonToken.START_ARRAY |
||||
* </code> |
||||
* |
||||
* @since 2.3 |
||||
*/ |
||||
public final boolean isStructStart() { |
||||
return _isStructStart; |
||||
} |
||||
|
||||
/** |
||||
* Accessor that is functionally equivalent to: |
||||
* <code> |
||||
* this == JsonToken.END_OBJECT || this == JsonToken.END_ARRAY |
||||
* </code> |
||||
* |
||||
* @since 2.3 |
||||
*/ |
||||
public final boolean isStructEnd() { |
||||
return _isStructEnd; |
||||
} |
||||
|
||||
/** |
||||
* Method that can be used to check whether this token represents |
||||
* a valid non-structured value. This means all tokens other than |
||||
* Object/Array start/end markers all field names. |
||||
*/ |
||||
public final boolean isScalarValue() { |
||||
return _isScalar; |
||||
} |
||||
|
||||
public final boolean isBoolean() { |
||||
return _isBoolean; |
||||
} |
||||
} |
@ -0,0 +1,87 @@
|
||||
package com.fr.third.fasterxml.jackson.core; |
||||
|
||||
/** |
||||
* Interface defined to contain ids accessible with {@link JsonToken#id()}. |
||||
* Needed because it is impossible to define these constants in |
||||
* {@link JsonToken} itself, as static constants (oddity of how Enums |
||||
* are implemented by JVM). |
||||
* |
||||
* @since 2.3 |
||||
*/ |
||||
public interface JsonTokenId |
||||
{ |
||||
/** |
||||
* Id used to represent {@link JsonToken#NOT_AVAILABLE}, used in |
||||
* cases where a token may become available when more input |
||||
* is available: this occurs in non-blocking use cases. |
||||
*/ |
||||
public final static int ID_NOT_AVAILABLE = -1; |
||||
|
||||
/** |
||||
* Id used to represent the case where no {@link JsonToken} |
||||
* is available: either because {@link JsonParser} has not been |
||||
* advanced to first token, or because no more tokens will be |
||||
* available (end-of-input or explicit closing of parser}. |
||||
*/ |
||||
public final static int ID_NO_TOKEN = 0; |
||||
|
||||
/** |
||||
* Id used to represent {@link JsonToken#START_OBJECT} |
||||
*/ |
||||
public final static int ID_START_OBJECT = 1; |
||||
|
||||
/** |
||||
* Id used to represent {@link JsonToken#END_OBJECT} |
||||
*/ |
||||
public final static int ID_END_OBJECT = 2; |
||||
|
||||
/** |
||||
* Id used to represent {@link JsonToken#START_ARRAY} |
||||
*/ |
||||
public final static int ID_START_ARRAY = 3; |
||||
|
||||
/** |
||||
* Id used to represent {@link JsonToken#END_ARRAY} |
||||
*/ |
||||
public final static int ID_END_ARRAY = 4; |
||||
|
||||
/** |
||||
* Id used to represent {@link JsonToken#FIELD_NAME} |
||||
*/ |
||||
public final static int ID_FIELD_NAME = 5; |
||||
|
||||
/** |
||||
* Id used to represent {@link JsonToken#VALUE_STRING} |
||||
*/ |
||||
public final static int ID_STRING = 6; |
||||
|
||||
/** |
||||
* Id used to represent {@link JsonToken#VALUE_NUMBER_INT} |
||||
*/ |
||||
public final static int ID_NUMBER_INT = 7; |
||||
|
||||
/** |
||||
* Id used to represent {@link JsonToken#VALUE_NUMBER_FLOAT} |
||||
*/ |
||||
public final static int ID_NUMBER_FLOAT = 8; |
||||
|
||||
/** |
||||
* Id used to represent {@link JsonToken#VALUE_TRUE} |
||||
*/ |
||||
public final static int ID_TRUE = 9; |
||||
|
||||
/** |
||||
* Id used to represent {@link JsonToken#VALUE_FALSE} |
||||
*/ |
||||
public final static int ID_FALSE = 10; |
||||
/** |
||||
* Id used to represent {@link JsonToken#VALUE_NULL} |
||||
*/ |
||||
|
||||
public final static int ID_NULL = 11; |
||||
|
||||
/** |
||||
* Id used to represent {@link JsonToken#VALUE_EMBEDDED_OBJECT} |
||||
*/ |
||||
public final static int ID_EMBEDDED_OBJECT = 12; |
||||
} |
@ -0,0 +1,185 @@
|
||||
/* Jackson JSON-processor. |
||||
* |
||||
* Copyright (c) 2007- Tatu Saloranta, tatu.saloranta@iki.fi |
||||
*/ |
||||
|
||||
package com.fr.third.fasterxml.jackson.core; |
||||
|
||||
import java.io.IOException; |
||||
import java.util.Iterator; |
||||
|
||||
import com.fr.third.fasterxml.jackson.core.type.ResolvedType; |
||||
import com.fr.third.fasterxml.jackson.core.type.TypeReference; |
||||
|
||||
/** |
||||
* Abstract class that defines the interface that {@link JsonParser} and |
||||
* {@link JsonGenerator} use to serialize and deserialize regular |
||||
* Java objects (POJOs aka Beans). |
||||
*<p> |
||||
* The standard implementation of this class is |
||||
* <code>com.fr.third.fasterxml.jackson.databind.ObjectMapper</code>, |
||||
* defined in the "jackson-databind". |
||||
*/ |
||||
public abstract class ObjectCodec |
||||
extends TreeCodec // since 2.3
|
||||
implements Versioned // since 2.3
|
||||
{ |
||||
protected ObjectCodec() { } |
||||
|
||||
// Since 2.3: need baseline implementation to avoid backwards compatibility
|
||||
@Override |
||||
public Version version() { |
||||
return Version.unknownVersion(); |
||||
} |
||||
|
||||
/* |
||||
/********************************************************** |
||||
/* API for de-serialization (JSON-to-Object) |
||||
/********************************************************** |
||||
*/ |
||||
|
||||
/** |
||||
* Method to deserialize JSON content into a non-container |
||||
* type (it can be an array type, however): typically a bean, array |
||||
* or a wrapper type (like {@link java.lang.Boolean}). |
||||
*<p> |
||||
* Note: this method should NOT be used if the result type is a |
||||
* container ({@link java.util.Collection} or {@link java.util.Map}. |
||||
* The reason is that due to type erasure, key and value types |
||||
* can not be introspected when using this method. |
||||
*/ |
||||
public abstract <T> T readValue(JsonParser jp, Class<T> valueType) |
||||
throws IOException, JsonProcessingException; |
||||
|
||||
/** |
||||
* Method to deserialize JSON content into a Java type, reference |
||||
* to which is passed as argument. Type is passed using so-called |
||||
* "super type token" |
||||
* and specifically needs to be used if the root type is a |
||||
* parameterized (generic) container type. |
||||
*/ |
||||
public abstract <T> T readValue(JsonParser jp, TypeReference<?> valueTypeRef) |
||||
throws IOException, JsonProcessingException; |
||||
|
||||
/** |
||||
* Method to deserialize JSON content into a POJO, type specified |
||||
* with fully resolved type object (so it can be a generic type, |
||||
* including containers like {@link java.util.Collection} and |
||||
* {@link java.util.Map}). |
||||
*/ |
||||
public abstract <T> T readValue(JsonParser jp, ResolvedType valueType) |
||||
throws IOException, JsonProcessingException; |
||||
|
||||
/** |
||||
* Method for reading sequence of Objects from parser stream, |
||||
* all with same specified value type. |
||||
*/ |
||||
public abstract <T> Iterator<T> readValues(JsonParser jp, Class<T> valueType) |
||||
throws IOException, JsonProcessingException; |
||||
|
||||
/** |
||||
* Method for reading sequence of Objects from parser stream, |
||||
* all with same specified value type. |
||||
*/ |
||||
public abstract <T> Iterator<T> readValues(JsonParser jp, TypeReference<?> valueTypeRef) |
||||
throws IOException, JsonProcessingException; |
||||
|
||||
/** |
||||
* Method for reading sequence of Objects from parser stream, |
||||
* all with same specified value type. |
||||
*/ |
||||
public abstract <T> Iterator<T> readValues(JsonParser jp, ResolvedType valueType) |
||||
throws IOException, JsonProcessingException; |
||||
|
||||
/* |
||||
/********************************************************** |
||||
/* API for serialization (Object-to-JSON) |
||||
/********************************************************** |
||||
*/ |
||||
|
||||
/** |
||||
* Method to serialize given Java Object, using generator |
||||
* provided. |
||||
*/ |
||||
public abstract void writeValue(JsonGenerator jgen, Object value) |
||||
throws IOException, JsonProcessingException; |
||||
|
||||
/* |
||||
/********************************************************** |
||||
/* TreeCodec pass-through methods |
||||
/********************************************************** |
||||
*/ |
||||
|
||||
/** |
||||
* Method to deserialize JSON content as tree expressed |
||||
* using set of {@link TreeNode} instances. Returns |
||||
* root of the resulting tree (where root can consist |
||||
* of just a single node if the current event is a |
||||
* value event, not container). |
||||
*/ |
||||
@Override |
||||
public abstract <T extends TreeNode> T readTree(JsonParser jp) |
||||
throws IOException, JsonProcessingException; |
||||
|
||||
@Override |
||||
public abstract void writeTree(JsonGenerator jg, TreeNode tree) |
||||
throws IOException, JsonProcessingException; |
||||
|
||||
/** |
||||
* Method for construct root level Object nodes |
||||
* for Tree Model instances. |
||||
*/ |
||||
@Override |
||||
public abstract TreeNode createObjectNode(); |
||||
|
||||
/** |
||||
* Method for construct root level Array nodes |
||||
* for Tree Model instances. |
||||
*/ |
||||
@Override |
||||
public abstract TreeNode createArrayNode(); |
||||
|
||||
/** |
||||
* Method for constructing a {@link JsonParser} for reading |
||||
* contents of a JSON tree, as if it was external serialized |
||||
* JSON content. |
||||
*/ |
||||
@Override |
||||
public abstract JsonParser treeAsTokens(TreeNode n); |
||||
|
||||
/* |
||||
/********************************************************** |
||||
/* Extended tree conversions beyond TreeCodec |
||||
/********************************************************** |
||||
*/ |
||||
|
||||
/** |
||||
* Convenience method for converting given JSON tree into instance of specified |
||||
* value type. This is equivalent to first constructing a {@link JsonParser} to |
||||
* iterate over contents of the tree, and using that parser for data binding. |
||||
*/ |
||||
public abstract <T> T treeToValue(TreeNode n, Class<T> valueType) |
||||
throws JsonProcessingException; |
||||
|
||||
/* |
||||
/********************************************************** |
||||
/* Basic accessors |
||||
/********************************************************** |
||||
*/ |
||||
|
||||
/** |
||||
* @deprecated Since 2.1: Use {@link #getFactory} instead. |
||||
*/ |
||||
@Deprecated |
||||
public abstract JsonFactory getJsonFactory(); |
||||
|
||||
/** |
||||
* Accessor for finding underlying data format factory |
||||
* ({@link JsonFactory}) codec will use for data binding. |
||||
* |
||||
* @since 2.1 |
||||
*/ |
||||
public JsonFactory getFactory() { |
||||
return getJsonFactory(); |
||||
} |
||||
} |
@ -0,0 +1,177 @@
|
||||
/* Jackson JSON-processor. |
||||
* |
||||
* Copyright (c) 2007- Tatu Saloranta, tatu.saloranta@iki.fi |
||||
*/ |
||||
|
||||
package com.fr.third.fasterxml.jackson.core; |
||||
|
||||
import java.io.IOException; |
||||
|
||||
/** |
||||
* Interface for objects that implement pretty printer functionality, such |
||||
* as indentation. |
||||
* Pretty printers are used to add white space in output JSON content, |
||||
* to make results more human readable. Usually this means things like adding |
||||
* linefeeds and indentation. |
||||
*<p> |
||||
* Note: since Jackson 2.1, stateful implementations MUST implement |
||||
* {@link com.fr.third.fasterxml.jackson.core.util.Instantiatable} interface, |
||||
* to allow for constructing per-generation instances and avoid |
||||
* state corruption (see [JACKSON-851] for details). |
||||
* Stateless implementations need not do this; but those are less common. |
||||
*/ |
||||
public interface PrettyPrinter |
||||
{ |
||||
/* |
||||
/********************************************************** |
||||
/* First methods that act both as events, and expect |
||||
/* output for correct functioning (i.e something gets |
||||
/* output even when not pretty-printing) |
||||
/********************************************************** |
||||
*/ |
||||
|
||||
// // // Root-level handling:
|
||||
|
||||
/** |
||||
* Method called after a root-level value has been completely |
||||
* output, and before another value is to be output. |
||||
*<p> |
||||
* Default |
||||
* handling (without pretty-printing) will output a space, to |
||||
* allow values to be parsed correctly. Pretty-printer is |
||||
* to output some other suitable and nice-looking separator |
||||
* (tab(s), space(s), linefeed(s) or any combination thereof). |
||||
*/ |
||||
void writeRootValueSeparator(JsonGenerator jg) |
||||
throws IOException, JsonGenerationException; |
||||
|
||||
// // Object handling
|
||||
|
||||
/** |
||||
* Method called when an Object value is to be output, before |
||||
* any fields are output. |
||||
*<p> |
||||
* Default handling (without pretty-printing) will output |
||||
* the opening curly bracket. |
||||
* Pretty-printer is |
||||
* to output a curly bracket as well, but can surround that |
||||
* with other (white-space) decoration. |
||||
*/ |
||||
void writeStartObject(JsonGenerator jg) |
||||
throws IOException, JsonGenerationException; |
||||
|
||||
/** |
||||
* Method called after an Object value has been completely output |
||||
* (minus closing curly bracket). |
||||
*<p> |
||||
* Default handling (without pretty-printing) will output |
||||
* the closing curly bracket. |
||||
* Pretty-printer is |
||||
* to output a curly bracket as well, but can surround that |
||||
* with other (white-space) decoration. |
||||
* |
||||
* @param nrOfEntries Number of direct members of the array that |
||||
* have been output |
||||
*/ |
||||
void writeEndObject(JsonGenerator jg, int nrOfEntries) |
||||
throws IOException, JsonGenerationException; |
||||
|
||||
/** |
||||
* Method called after an object entry (field:value) has been completely |
||||
* output, and before another value is to be output. |
||||
*<p> |
||||
* Default handling (without pretty-printing) will output a single |
||||
* comma to separate the two. Pretty-printer is |
||||
* to output a comma as well, but can surround that with other |
||||
* (white-space) decoration. |
||||
*/ |
||||
void writeObjectEntrySeparator(JsonGenerator jg) |
||||
throws IOException, JsonGenerationException; |
||||
|
||||
/** |
||||
* Method called after an object field has been output, but |
||||
* before the value is output. |
||||
*<p> |
||||
* Default handling (without pretty-printing) will output a single |
||||
* colon to separate the two. Pretty-printer is |
||||
* to output a colon as well, but can surround that with other |
||||
* (white-space) decoration. |
||||
*/ |
||||
void writeObjectFieldValueSeparator(JsonGenerator jg) |
||||
throws IOException, JsonGenerationException; |
||||
|
||||
// // // Array handling
|
||||
|
||||
/** |
||||
* Method called when an Array value is to be output, before |
||||
* any member/child values are output. |
||||
*<p> |
||||
* Default handling (without pretty-printing) will output |
||||
* the opening bracket. |
||||
* Pretty-printer is |
||||
* to output a bracket as well, but can surround that |
||||
* with other (white-space) decoration. |
||||
*/ |
||||
void writeStartArray(JsonGenerator jg) |
||||
throws IOException, JsonGenerationException; |
||||
|
||||
/** |
||||
* Method called after an Array value has been completely output |
||||
* (minus closing bracket). |
||||
*<p> |
||||
* Default handling (without pretty-printing) will output |
||||
* the closing bracket. |
||||
* Pretty-printer is |
||||
* to output a bracket as well, but can surround that |
||||
* with other (white-space) decoration. |
||||
* |
||||
* @param nrOfValues Number of direct members of the array that |
||||
* have been output |
||||
*/ |
||||
void writeEndArray(JsonGenerator jg, int nrOfValues) |
||||
throws IOException, JsonGenerationException; |
||||
|
||||
/** |
||||
* Method called after an array value has been completely |
||||
* output, and before another value is to be output. |
||||
*<p> |
||||
* Default handling (without pretty-printing) will output a single |
||||
* comma to separate the two. Pretty-printer is |
||||
* to output a comma as well, but can surround that with other |
||||
* (white-space) decoration. |
||||
*/ |
||||
void writeArrayValueSeparator(JsonGenerator jg) |
||||
throws IOException, JsonGenerationException; |
||||
|
||||
/* |
||||
/********************************************************** |
||||
/* Then events that by default do not produce any output |
||||
/* but that are often overridden to add white space |
||||
/* in pretty-printing mode |
||||
/********************************************************** |
||||
*/ |
||||
|
||||
/** |
||||
* Method called after array start marker has been output, |
||||
* and right before the first value is to be output. |
||||
* It is <b>not</b> called for arrays with no values. |
||||
*<p> |
||||
* Default handling does not output anything, but pretty-printer |
||||
* is free to add any white space decoration. |
||||
*/ |
||||
void beforeArrayValues(JsonGenerator jg) |
||||
throws IOException, JsonGenerationException; |
||||
|
||||
/** |
||||
* Method called after object start marker has been output, |
||||
* and right before the field name of the first entry is |
||||
* to be output. |
||||
* It is <b>not</b> called for objects without entries. |
||||
*<p> |
||||
* Default handling does not output anything, but pretty-printer |
||||
* is free to add any white space decoration. |
||||
*/ |
||||
void beforeObjectEntries(JsonGenerator jg) |
||||
throws IOException, JsonGenerationException; |
||||
} |
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in new issue