16 | * Since there is little commonality between schemas for different data formats,
17 | * this interface does not define much meaningful functionality for accessing
18 | * schema details; rather, specific parser and generator implementations need
19 | * to cast to schema implementations they use. This marker interface is mostly
20 | * used for tagging "some kind of schema" -- instead of passing opaque
21 | * {@link java.lang.Object} -- for documentation purposes.
22 | */
23 | public interface FormatSchema
24 | {
25 | /**
26 | * Method that can be used to get an identifier that can be used for diagnostics
27 | * purposes, to indicate what kind of data format this schema is used for: typically
28 | * it is a short name of format itself, but it can also contain additional information
29 | * in cases where data format supports multiple types of schemas.
30 | */
31 | String getSchemaType();
32 | }
33 |
--------------------------------------------------------------------------------
/src/com/fasterxml/jackson/core/JsonEncoding.java:
--------------------------------------------------------------------------------
1 | /* Jackson JSON-processor.
2 | *
3 | * Copyright (c) 2007- Tatu Saloranta, tatu.saloranta@iki.fi
4 | */
5 |
6 | package com.fasterxml.jackson.core;
7 |
8 | /**
9 | * Enumeration that defines legal encodings that can be used
10 | * for JSON content, based on list of allowed encodings from
11 | * JSON specification.
12 | *
13 | * Note: if application want to explicitly disregard Encoding
14 | * limitations (to read in JSON encoded using an encoding not
15 | * listed as allowed), they can use {@link java.io.Reader} /
16 | * {@link java.io.Writer} instances as input
17 | */
18 | public enum JsonEncoding {
19 | UTF8("UTF-8", false, 8), // N/A for big-endian, really
20 | UTF16_BE("UTF-16BE", true, 16),
21 | UTF16_LE("UTF-16LE", false, 16),
22 | UTF32_BE("UTF-32BE", true, 32),
23 | UTF32_LE("UTF-32LE", false, 32)
24 | ;
25 |
26 | protected final String _javaName;
27 |
28 | protected final boolean _bigEndian;
29 |
30 | protected final int _bits;
31 |
32 | JsonEncoding(String javaName, boolean bigEndian, int bits)
33 | {
34 | _javaName = javaName;
35 | _bigEndian = bigEndian;
36 | _bits = bits;
37 | }
38 |
39 | /**
40 | * Method for accessing encoding name that JDK will support.
41 | *
42 | * @return Matching encoding name that JDK will support.
43 | */
44 | public String getJavaName() { return _javaName; }
45 |
46 | /**
47 | * Whether encoding is big-endian (if encoding supports such
48 | * notion). If no such distinction is made (as is the case for
49 | * {@link #UTF8}), return value is undefined.
50 | *
51 | * @return True for big-endian encodings; false for little-endian
52 | * (or if not applicable)
53 | */
54 | public boolean isBigEndian() { return _bigEndian; }
55 |
56 | public int bits() { return _bits; }
57 | }
58 |
--------------------------------------------------------------------------------
/src/com/fasterxml/jackson/core/JsonGenerationException.java:
--------------------------------------------------------------------------------
1 | /* Jackson JSON-processor.
2 | *
3 | * Copyright (c) 2007- Tatu Saloranta, tatu.saloranta@iki.fi
4 | */
5 |
6 | package com.fasterxml.jackson.core;
7 |
8 | /**
9 | * Exception type for exceptions during JSON writing, such as trying
10 | * to output content in wrong context (non-matching end-array or end-object,
11 | * for example).
12 | */
13 | public class JsonGenerationException
14 | extends JsonProcessingException
15 | {
16 | private final static long serialVersionUID = 123; // Stupid eclipse...
17 |
18 | public JsonGenerationException(Throwable rootCause)
19 | {
20 | super(rootCause);
21 | }
22 |
23 | public JsonGenerationException(String msg)
24 | {
25 | super(msg, (JsonLocation)null);
26 | }
27 |
28 | public JsonGenerationException(String msg, Throwable rootCause)
29 | {
30 | super(msg, (JsonLocation)null, rootCause);
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/src/com/fasterxml/jackson/core/JsonParseException.java:
--------------------------------------------------------------------------------
1 | /* Jackson JSON-processor.
2 | *
3 | * Copyright (c) 2007- Tatu Saloranta, tatu.saloranta@iki.fi
4 | */
5 |
6 | package com.fasterxml.jackson.core;
7 |
8 | /**
9 | * Exception type for parsing problems, used when non-well-formed content
10 | * (content that does not conform to JSON syntax as per specification)
11 | * is encountered.
12 | */
13 | public class JsonParseException
14 | extends JsonProcessingException
15 | {
16 | private static final long serialVersionUID = 1L;
17 |
18 | public JsonParseException(String msg, JsonLocation loc)
19 | {
20 | super(msg, loc);
21 | }
22 |
23 | public JsonParseException(String msg, JsonLocation loc, Throwable root)
24 | {
25 | super(msg, loc, root);
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/src/com/fasterxml/jackson/core/TreeCodec.java:
--------------------------------------------------------------------------------
1 | package com.fasterxml.jackson.core;
2 |
3 | import java.io.IOException;
4 |
5 | /**
6 | * Interface that defines objects that can read and write
7 | * {@link TreeNode} instances using Streaming API.
8 | *
9 | * @since 2.3
10 | */
11 | public abstract class TreeCodec
12 | {
13 | public abstract T readTree(JsonParser jp)
14 | throws IOException, JsonProcessingException;
15 |
16 | public abstract void writeTree(JsonGenerator jg, TreeNode tree)
17 | throws IOException, JsonProcessingException;
18 |
19 | public abstract TreeNode createArrayNode();
20 | public abstract TreeNode createObjectNode();
21 |
22 | public abstract JsonParser treeAsTokens(TreeNode node);
23 | }
24 |
--------------------------------------------------------------------------------
/src/com/fasterxml/jackson/core/Versioned.java:
--------------------------------------------------------------------------------
1 | /* Jackson JSON-processor.
2 | *
3 | * Copyright (c) 2007- Tatu Saloranta, tatu.saloranta@iki.fi
4 | */
5 |
6 | package com.fasterxml.jackson.core;
7 |
8 | /**
9 | * Interface that those Jackson components that are explicitly versioned will implement.
10 | * Intention is to allow both plug-in components (custom extensions) and applications and
11 | * frameworks that use Jackson to detect exact version of Jackson in use.
12 | * This may be useful for example for ensuring that proper Jackson version is deployed
13 | * (beyond mechanisms that deployment system may have), as well as for possible
14 | * workarounds.
15 | */
16 | public interface Versioned {
17 | /**
18 | * Method called to detect version of the component that implements this interface;
19 | * returned version should never be null, but may return specific "not available"
20 | * instance (see {@link Version} for details).
21 | */
22 | Version version();
23 | }
24 |
--------------------------------------------------------------------------------
/src/com/fasterxml/jackson/core/base/package-info.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Base classes used by concrete Parser and Generator implementations;
3 | * contain functionality that is not specific to JSON or input
4 | * abstraction (byte vs char).
5 | * Most formats extend these types, although it is also possible to
6 | * directly extend {@link com.fasterxml.jackson.core.JsonParser} or
7 | * {@link com.fasterxml.jackson.core.JsonGenerator}.
8 | */
9 | package com.fasterxml.jackson.core.base;
10 |
--------------------------------------------------------------------------------
/src/com/fasterxml/jackson/core/format/package-info.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Package that contains interfaces needed for dynamic, pluggable
3 | * format (auto)detection; as well as basic utility classes for
4 | * simple format detection functionality.
5 | */
6 | package com.fasterxml.jackson.core.format;
7 |
--------------------------------------------------------------------------------
/src/com/fasterxml/jackson/core/io/OutputDecorator.java:
--------------------------------------------------------------------------------
1 | package com.fasterxml.jackson.core.io;
2 |
3 | import java.io.*;
4 |
5 | /**
6 | * Handler class that can be used to decorate output destinations.
7 | * Typical use is to use a filter abstraction (filtered output stream,
8 | * writer) around original output destination, and apply additional
9 | * processing during write operations.
10 | */
11 | public abstract class OutputDecorator
12 | implements java.io.Serializable // since 2.1
13 | {
14 | private static final long serialVersionUID = 1L;
15 |
16 | /**
17 | * Method called by {@link com.fasterxml.jackson.core.JsonFactory} instance when
18 | * creating generator for given {@link OutputStream}, when this decorator
19 | * has been registered.
20 | *
21 | * @param ctxt IO context in use (provides access to declared encoding)
22 | * @param out Original output destination
23 | *
24 | * @return OutputStream to use; either passed in argument, or something that
25 | * calls it
26 | */
27 | public abstract OutputStream decorate(IOContext ctxt, OutputStream out)
28 | throws IOException;
29 |
30 | /**
31 | * Method called by {@link com.fasterxml.jackson.core.JsonFactory} instance when
32 | * creating generator for given {@link Writer}, when this decorator
33 | * has been registered.
34 | *
35 | * @param ctxt IO context in use (provides access to declared encoding)
36 | * @param w Original output writer
37 | *
38 | * @return Writer to use; either passed in argument, or something that calls it
39 | */
40 | public abstract Writer decorate(IOContext ctxt, Writer w) throws IOException;
41 | }
42 |
--------------------------------------------------------------------------------
/src/com/fasterxml/jackson/core/json/PackageVersion.java:
--------------------------------------------------------------------------------
1 | package com.fasterxml.jackson.core.json;
2 |
3 | import com.fasterxml.jackson.core.Version;
4 | import com.fasterxml.jackson.core.Versioned;
5 | import com.fasterxml.jackson.core.util.VersionUtil;
6 |
7 | /**
8 | * Automatically generated from PackageVersion.java.in during
9 | * packageVersion-generate execution of maven-replacer-plugin in
10 | * pom.xml.
11 | */
12 | public final class PackageVersion implements Versioned {
13 | public final static Version VERSION = VersionUtil.parseVersion(
14 | "2.3.5", "com.fasterxml.jackson.core", "jackson-core");
15 |
16 | @Override
17 | public Version version() {
18 | return VERSION;
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/src/com/fasterxml/jackson/core/json/PackageVersion.java.in:
--------------------------------------------------------------------------------
1 | package @package@;
2 |
3 | import com.fasterxml.jackson.core.Version;
4 | import com.fasterxml.jackson.core.Versioned;
5 | import com.fasterxml.jackson.core.util.VersionUtil;
6 |
7 | /**
8 | * Automatically generated from PackageVersion.java.in during
9 | * packageVersion-generate execution of maven-replacer-plugin in
10 | * pom.xml.
11 | */
12 | public final class PackageVersion implements Versioned {
13 | public final static Version VERSION = VersionUtil.parseVersion(
14 | "@projectversion@", "@projectgroupid@", "@projectartifactid@");
15 |
16 | @Override
17 | public Version version() {
18 | return VERSION;
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/src/com/fasterxml/jackson/core/json/package-info.java:
--------------------------------------------------------------------------------
1 | /**
2 | * JSON-specific parser and generator implementation classes that
3 | * Jackson defines and uses.
4 | * Application code should not (need to) use contents of this package;
5 | * nor are these implementations likely to be of use for sub-classing.
6 | */
7 | package com.fasterxml.jackson.core.json;
8 |
--------------------------------------------------------------------------------
/src/com/fasterxml/jackson/core/package-info.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Main public API classes of the core streaming JSON
3 | * processor: most importantly {@link com.fasterxml.jackson.core.JsonFactory}
4 | * used for constructing
5 | * JSON parser ({@link com.fasterxml.jackson.core.JsonParser})
6 | * and generator
7 | * ({@link com.fasterxml.jackson.core.JsonParser})
8 | * instances.
9 | *
10 | * Public API of the higher-level mapping interfaces ("Mapping API")
11 | * is found from the "jackson-databind" bundle, except for following
12 | * base interfaces that are defined here:
13 | *
14 | *
{@link com.fasterxml.jackson.core.TreeNode} is included
15 | *within Streaming API to support integration of the Tree Model
16 | *(which is based on JsonNode) with the basic
17 | *parsers and generators (iff using mapping-supporting factory: which
18 | *is part of Mapping API, not core)
19 | *
20 | *
{@link com.fasterxml.jackson.core.ObjectCodec} is included so that
21 | * reference to the object capable of serializing/deserializing
22 | * Objects to/from JSON (usually, com.fasterxml.jackson.databind.ObjectMapper)
23 | * can be exposed, without adding direct dependency to implementation.
24 | *
25 | *
26 | */
27 |
28 | package com.fasterxml.jackson.core;
29 |
--------------------------------------------------------------------------------
/src/com/fasterxml/jackson/core/sym/Name.java:
--------------------------------------------------------------------------------
1 | package com.fasterxml.jackson.core.sym;
2 |
3 | /**
4 | * Base class for tokenized names (key strings in objects) that have
5 | * been tokenized from byte-based input sources (like
6 | * {@link java.io.InputStream}.
7 | *
8 | * @author Tatu Saloranta
9 | */
10 | public abstract class Name
11 | {
12 | protected final String _name;
13 |
14 | protected final int _hashCode;
15 |
16 | protected Name(String name, int hashCode) {
17 | _name = name;
18 | _hashCode = hashCode;
19 | }
20 |
21 | public String getName() { return _name; }
22 |
23 | /*
24 | /**********************************************************
25 | /* Methods for package/core parser
26 | /**********************************************************
27 | */
28 |
29 | public abstract boolean equals(int quad1);
30 |
31 | public abstract boolean equals(int quad1, int quad2);
32 |
33 | public abstract boolean equals(int[] quads, int qlen);
34 |
35 | /*
36 | /**********************************************************
37 | /* Overridden standard methods
38 | /**********************************************************
39 | */
40 |
41 | @Override public String toString() { return _name; }
42 |
43 | @Override public final int hashCode() { return _hashCode; }
44 |
45 | @Override public boolean equals(Object o)
46 | {
47 | // Canonical instances, can usually just do identity comparison
48 | return (o == this);
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/src/com/fasterxml/jackson/core/sym/Name1.java:
--------------------------------------------------------------------------------
1 | package com.fasterxml.jackson.core.sym;
2 |
3 | /**
4 | * Specialized implementation of PName: can be used for short Strings
5 | * that consists of at most 4 bytes. Usually this means short
6 | * ascii-only names.
7 | *
8 | * The reason for such specialized classes is mostly space efficiency;
9 | * and to a lesser degree performance. Both are achieved for short
10 | * Strings by avoiding another level of indirection (via quad arrays)
11 | */
12 | public final class Name1
13 | extends Name
14 | {
15 | final static Name1 sEmptyName = new Name1("", 0, 0);
16 |
17 | final int mQuad;
18 |
19 | Name1(String name, int hash, int quad)
20 | {
21 | super(name, hash);
22 | mQuad = quad;
23 | }
24 |
25 | static Name1 getEmptyName() { return sEmptyName; }
26 |
27 | @Override
28 | public boolean equals(int quad)
29 | {
30 | return (quad == mQuad);
31 | }
32 |
33 | @Override
34 | public boolean equals(int quad1, int quad2)
35 | {
36 | return (quad1 == mQuad) && (quad2 == 0);
37 | }
38 |
39 | @Override
40 | public boolean equals(int[] quads, int qlen)
41 | {
42 | return (qlen == 1 && quads[0] == mQuad);
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/src/com/fasterxml/jackson/core/sym/Name2.java:
--------------------------------------------------------------------------------
1 | package com.fasterxml.jackson.core.sym;
2 |
3 | /**
4 | * Specialized implementation of PName: can be used for short Strings
5 | * that consists of 5 to 8 bytes. Usually this means relatively short
6 | * ascii-only names.
7 | *
8 | * The reason for such specialized classes is mostly space efficiency;
9 | * and to a lesser degree performance. Both are achieved for short
10 | * Strings by avoiding another level of indirection (via quad arrays)
11 | */
12 | public final class Name2
13 | extends Name
14 | {
15 | final int mQuad1;
16 |
17 | final int mQuad2;
18 |
19 | Name2(String name, int hash, int quad1, int quad2)
20 | {
21 | super(name, hash);
22 | mQuad1 = quad1;
23 | mQuad2 = quad2;
24 | }
25 |
26 | @Override
27 | public boolean equals(int quad) { return false; }
28 |
29 | @Override
30 | public boolean equals(int quad1, int quad2)
31 | {
32 | return (quad1 == mQuad1) && (quad2 == mQuad2);
33 | }
34 |
35 | @Override
36 | public boolean equals(int[] quads, int qlen)
37 | {
38 | return (qlen == 2 && quads[0] == mQuad1 && quads[1] == mQuad2);
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/src/com/fasterxml/jackson/core/sym/Name3.java:
--------------------------------------------------------------------------------
1 | package com.fasterxml.jackson.core.sym;
2 |
3 | /**
4 | * Specialized implementation of PName: can be used for short Strings
5 | * that consists of 9 to 12 bytes. It's the longest special purpose
6 | * implementaion; longer ones are expressed using {@link NameN}.
7 | */
8 | public final class Name3
9 | extends Name
10 | {
11 | final int mQuad1;
12 | final int mQuad2;
13 | final int mQuad3;
14 |
15 | Name3(String name, int hash, int q1, int q2, int q3)
16 | {
17 | super(name, hash);
18 | mQuad1 = q1;
19 | mQuad2 = q2;
20 | mQuad3 = q3;
21 | }
22 |
23 | // Implies quad length == 1, never matches
24 | @Override
25 | public boolean equals(int quad) { return false; }
26 |
27 | // Implies quad length == 2, never matches
28 | @Override
29 | public boolean equals(int quad1, int quad2) { return false; }
30 |
31 | @Override
32 | public boolean equals(int[] quads, int qlen)
33 | {
34 | return (qlen == 3)
35 | && (quads[0] == mQuad1)
36 | && (quads[1] == mQuad2)
37 | && (quads[2] == mQuad3);
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/src/com/fasterxml/jackson/core/sym/NameN.java:
--------------------------------------------------------------------------------
1 | package com.fasterxml.jackson.core.sym;
2 |
3 | /**
4 | * Generic implementation of PName used for "long" names, where long
5 | * means that its byte (UTF-8) representation is 13 bytes or more.
6 | */
7 | public final class NameN
8 | extends Name
9 | {
10 | final int[] mQuads;
11 | final int mQuadLen;
12 |
13 | NameN(String name, int hash, int[] quads, int quadLen)
14 | {
15 | super(name, hash);
16 | /* We have specialized implementations for shorter
17 | * names, so let's not allow runt instances here
18 | */
19 | if (quadLen < 3) {
20 | throw new IllegalArgumentException("Qlen must >= 3");
21 | }
22 | mQuads = quads;
23 | mQuadLen = quadLen;
24 | }
25 |
26 | // Implies quad length == 1, never matches
27 | @Override
28 | public boolean equals(int quad) { return false; }
29 |
30 | // Implies quad length == 2, never matches
31 | @Override
32 | public boolean equals(int quad1, int quad2) { return false; }
33 |
34 | @Override
35 | public boolean equals(int[] quads, int qlen)
36 | {
37 | if (qlen != mQuadLen) {
38 | return false;
39 | }
40 |
41 | /* 26-Nov-2008, tatus: Strange, but it does look like
42 | * unrolling here is counter-productive, reducing
43 | * speed. Perhaps it prevents inlining by HotSpot or
44 | * something...
45 | */
46 | // Will always have >= 3 quads, can unroll
47 | /*
48 | if (quads[0] == mQuads[0]
49 | && quads[1] == mQuads[1]
50 | && quads[2] == mQuads[2]) {
51 | for (int i = 3; i < qlen; ++i) {
52 | if (quads[i] != mQuads[i]) {
53 | return false;
54 | }
55 | }
56 | return true;
57 | }
58 | */
59 |
60 | // or simpler way without unrolling:
61 | for (int i = 0; i < qlen; ++i) {
62 | if (quads[i] != mQuads[i]) {
63 | return false;
64 | }
65 | }
66 | return true;
67 | }
68 | }
69 |
--------------------------------------------------------------------------------
/src/com/fasterxml/jackson/core/sym/package-info.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Internal implementation classes for efficient handling of
3 | * of symbols in JSON (field names in Objects)
4 | */
5 | package com.fasterxml.jackson.core.sym;
6 |
--------------------------------------------------------------------------------
/src/com/fasterxml/jackson/core/type/package-info.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Contains classes needed for type introspection, mostly used by data binding
3 | * functionality. Most of this functionality is needed to properly handled
4 | * generic types, and to simplify and unify processing of things Jackson needs
5 | * to determine how contained types (of {@link java.util.Collection} and
6 | * {@link java.util.Map} classes) are to be handled.
7 | */
8 | package com.fasterxml.jackson.core.type;
9 |
--------------------------------------------------------------------------------
/src/com/fasterxml/jackson/core/util/Instantiatable.java:
--------------------------------------------------------------------------------
1 | package com.fasterxml.jackson.core.util;
2 |
3 | /**
4 | * Add-on interface used to indicate things that may be "blueprint" objects
5 | * which can not be used as is, but are used for creating usable per-process
6 | * (serialization, deserialization) instances, using
7 | * {@link #createInstance} method.
8 | *
9 | * Note that some implementations may choose to implement {@link #createInstance}
10 | * by simply returning 'this': this is acceptable if instances are stateless.
11 | *
12 | * @see DefaultPrettyPrinter
13 | *
14 | * @since 2.1
15 | */
16 | public interface Instantiatable
17 | {
18 | /**
19 | * Method called to ensure that we have a non-blueprint object to use;
20 | * it is either this object (if stateless), or a newly created object
21 | * with separate state.
22 | */
23 | T createInstance();
24 | }
25 |
--------------------------------------------------------------------------------
/src/com/fasterxml/jackson/core/util/package-info.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Utility classes used by Jackson Core functionality.
3 | */
4 | package com.fasterxml.jackson.core.util;
5 |
--------------------------------------------------------------------------------
/src/com/fasterxml/jackson/dataformat/smile/PackageVersion.java:
--------------------------------------------------------------------------------
1 | package com.fasterxml.jackson.dataformat.smile;
2 |
3 | import com.fasterxml.jackson.core.Version;
4 | import com.fasterxml.jackson.core.Versioned;
5 | import com.fasterxml.jackson.core.util.VersionUtil;
6 |
7 | /**
8 | * Automatically generated from PackageVersion.java.in during
9 | * packageVersion-generate execution of maven-replacer-plugin in
10 | * pom.xml.
11 | */
12 | public final class PackageVersion implements Versioned {
13 | public final static Version VERSION = VersionUtil.parseVersion(
14 | "2.3.5.1", "com.fasterxml.jackson.dataformat", "jackson-dataformat-smile");
15 |
16 | @Override
17 | public Version version() {
18 | return VERSION;
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/src/com/fasterxml/jackson/dataformat/smile/SmileBufferRecycler.java:
--------------------------------------------------------------------------------
1 | package com.fasterxml.jackson.dataformat.smile;
2 |
3 | /**
4 | * Simple helper class used for implementing simple reuse system for Smile-specific
5 | * buffers that are used.
6 | *
7 | * @param Type of name entries stored in arrays to recycle
8 | */
9 | public class SmileBufferRecycler
10 | {
11 | public final static int DEFAULT_NAME_BUFFER_LENGTH = 64;
12 |
13 | public final static int DEFAULT_STRING_VALUE_BUFFER_LENGTH = 64;
14 |
15 | protected T[] _seenNamesBuffer;
16 |
17 | protected T[] _seenStringValuesBuffer;
18 |
19 | public SmileBufferRecycler() { }
20 |
21 | public T[] allocSeenNamesBuffer()
22 | {
23 | // 11-Feb-2011, tatu: Used to alloc here; but due to generics, can't easily any more
24 | T[] result = _seenNamesBuffer;
25 | if (result != null) {
26 | // let's ensure we don't retain it here, unless returned
27 | _seenNamesBuffer = null;
28 | // note: caller must have cleaned it up before returning
29 | }
30 | return result;
31 | }
32 |
33 | public T[] allocSeenStringValuesBuffer()
34 | {
35 | // 11-Feb-2011, tatu: Used to alloc here; but due to generics, can't easily any more
36 | T[] result = _seenStringValuesBuffer;
37 | if (result != null) {
38 | _seenStringValuesBuffer = null;
39 | // note: caller must have cleaned it up before returning
40 | }
41 | return result;
42 | }
43 |
44 | public void releaseSeenNamesBuffer(T[] buffer) {
45 | _seenNamesBuffer = buffer;
46 | }
47 |
48 | public void releaseSeenStringValuesBuffer(T[] buffer) {
49 | _seenStringValuesBuffer = buffer;
50 | }
51 | }
52 |
--------------------------------------------------------------------------------
/src/com/fasterxml/jackson/dataformat/smile/SmileUtil.java:
--------------------------------------------------------------------------------
1 | package com.fasterxml.jackson.dataformat.smile;
2 |
3 | /**
4 | * Class for miscellaneous helper methods.
5 | */
6 | public class SmileUtil
7 | {
8 | public static int zigzagEncode(int input) {
9 | // Canonical version:
10 | //return (input << 1) ^ (input >> 31);
11 | // but this is even better
12 | if (input < 0) {
13 | return (input << 1) ^ -1;
14 | }
15 | return (input << 1);
16 | }
17 |
18 | public static int zigzagDecode(int encoded) {
19 | // canonical:
20 | //return (encoded >>> 1) ^ (-(encoded & 1));
21 | if ((encoded & 1) == 0) { // positive
22 | return (encoded >>> 1);
23 | }
24 | // negative
25 | return (encoded >>> 1) ^ -1;
26 | }
27 |
28 | public static long zigzagEncode(long input) {
29 | // Canonical version
30 | //return (input << 1) ^ (input >> 63);
31 | if (input < 0L) {
32 | return (input << 1) ^ -1L;
33 | }
34 | return (input << 1);
35 | }
36 |
37 | public static long zigzagDecode(long encoded) {
38 | // canonical:
39 | //return (encoded >>> 1) ^ (-(encoded & 1));
40 | if ((encoded & 1) == 0) { // positive
41 | return (encoded >>> 1);
42 | }
43 | // negative
44 | return (encoded >>> 1) ^ -1L;
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/src/com/fasterxml/jackson/dataformat/smile/async/NonBlockingInputFeeder.java:
--------------------------------------------------------------------------------
1 | package com.fasterxml.jackson.dataformat.smile.async;
2 |
3 | import java.io.IOException;
4 |
5 | /**
6 | * Interface used by non-blocking {@link com.fasterxml.jackson.core.JsonParser}
7 | * to get more input to parse.
8 | * It is accessed by entity that feeds content to parse; at any given point
9 | * only one chunk of content can be processed so caller has to take care to
10 | * only feed more content when existing content has been parsed (which occurs
11 | * when parser's nextToken is called). Once application using
12 | * non-blocking parser has no more data to feed it should call
13 | * {@link #endOfInput} to indicate end of logical input stream.
14 | *
15 | * @author Tatu Saloranta
16 | */
17 | public interface NonBlockingInputFeeder
18 | {
19 | /**
20 | * Method called to check whether it is ok to feed more data: parser returns true
21 | * if it has no more content to parse (and it is ok to feed more); otherwise false
22 | * (and no data should yet be fed).
23 | */
24 | public boolean needMoreInput();
25 |
26 | /**
27 | * Method that can be called to feed more data, if (and only if)
28 | * {@link #needMoreInput} returns true.
29 | *
30 | * @param data Byte array that contains data to feed: caller must ensure data remains
31 | * stable until it is fully processed (which is true when {@link #needMoreInput}
32 | * returns true)
33 | * @param offset Offset within array where input data to process starts
34 | * @param len Length of input data within array to process.
35 | *
36 | * @throws IOException if the state is such that this method should not be called
37 | * (has not yet consumed existing input data, or has been marked as closed)
38 | */
39 | public void feedInput(byte[] data, int offset, int len) throws IOException;
40 |
41 | /**
42 | * Method that should be called after last chunk of data to parse has been fed
43 | * (with {@link #feedInput}); can be called regardless of what {@link #needMoreInput}
44 | * returns. After calling this method, no more data can be fed; and parser assumes
45 | * no more data will be available.
46 | */
47 | public void endOfInput();
48 | }
49 |
--------------------------------------------------------------------------------
/src/com/fasterxml/jackson/dataformat/smile/async/NonBlockingParser.java:
--------------------------------------------------------------------------------
1 | package com.fasterxml.jackson.dataformat.smile.async;
2 |
3 | import java.io.IOException;
4 |
5 | import com.fasterxml.jackson.core.JsonParseException;
6 | import com.fasterxml.jackson.core.JsonToken;
7 |
8 | /**
9 | * Mix-in interface used with {@link com.fasterxml.jackson.core.JsonParser},
10 | * extending it with features needed to process data in non-blocking
11 | * ("asynchronous")
12 | */
13 | public interface NonBlockingParser
14 | extends NonBlockingInputFeeder
15 | {
16 | /**
17 | * Method that can be called when current token is not yet
18 | * available via {@link com.fasterxml.jackson.core.JsonParser#getCurrentToken},
19 | * to try to figure out what kind of token will be eventually returned
20 | * once the whole token is decoded, if known.
21 | * Note that this may return {@link com.fasterxml.jackson.core.JsonToken#NOT_AVAILABLE}:
22 | * this occurs either if current token is known (and thus no more
23 | * parsing can be done yet), or if not enough content is available
24 | * to even determine next token type (typically we only need a single
25 | * byte, but in boundaries zero bytes is available).
26 | *
27 | * @return Token that will eventually be returned with
28 | * a call to {@link com.fasterxml.jackson.core.JsonParser#nextToken}, if known
29 | */
30 | public JsonToken peekNextToken() throws IOException, JsonParseException;
31 | }
32 |
--------------------------------------------------------------------------------
/src/com/fasterxml/jackson/dataformat/smile/async/package-info.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Package that contains experimental non-blocking ("asynchronous")
3 | * implementation of reader-part of Jackson streaming API,
4 | * working on Smile format.
5 | */
6 | package com.fasterxml.jackson.dataformat.smile.async;
7 |
--------------------------------------------------------------------------------
/src/com/fasterxml/jackson/dataformat/smile/package-info.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Package that contains implementation of Jackson Streaming API that works
3 | * with Smile data format (see Smile format specification),
4 | * and can be used with standard Jackson data binding functionality to deal with
5 | * Smile encoded data.
6 | */
7 | package com.fasterxml.jackson.dataformat.smile;
8 |
--------------------------------------------------------------------------------
/src/com/google/protobuf/BlockingRpcChannel.java:
--------------------------------------------------------------------------------
1 | // Protocol Buffers - Google's data interchange format
2 | // Copyright 2008 Google Inc. All rights reserved.
3 | // http://code.google.com/p/protobuf/
4 | //
5 | // Redistribution and use in source and binary forms, with or without
6 | // modification, are permitted provided that the following conditions are
7 | // met:
8 | //
9 | // * Redistributions of source code must retain the above copyright
10 | // notice, this list of conditions and the following disclaimer.
11 | // * Redistributions in binary form must reproduce the above
12 | // copyright notice, this list of conditions and the following disclaimer
13 | // in the documentation and/or other materials provided with the
14 | // distribution.
15 | // * Neither the name of Google Inc. nor the names of its
16 | // contributors may be used to endorse or promote products derived from
17 | // this software without specific prior written permission.
18 | //
19 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
22 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
23 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
25 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 | package com.google.protobuf;
31 |
32 | /**
33 | *
34 | * Abstract interface for a blocking RPC channel. {@code BlockingRpcChannel} is
35 | * the blocking equivalent to {@link RpcChannel}.
36 | *
37 | * @author kenton@google.com Kenton Varda
38 | * @author cpovirk@google.com Chris Povirk
39 | */
40 | public interface BlockingRpcChannel
41 | {
42 |
43 | /**
44 | * Call the given method of the remote service and blocks until it returns.
45 | * {@code callBlockingMethod()} is the blocking equivalent to
46 | * {@link RpcChannel#callMethod}.
47 | */
48 | Message callBlockingMethod (
49 | Descriptors.MethodDescriptor method,
50 | RpcController controller,
51 | Message request,
52 | Message responsePrototype) throws ServiceException;
53 | }
54 |
--------------------------------------------------------------------------------
/src/com/google/protobuf/ProtocolMessageEnum.java:
--------------------------------------------------------------------------------
1 | // Protocol Buffers - Google's data interchange format
2 | // Copyright 2008 Google Inc. All rights reserved.
3 | // http://code.google.com/p/protobuf/
4 | //
5 | // Redistribution and use in source and binary forms, with or without
6 | // modification, are permitted provided that the following conditions are
7 | // met:
8 | //
9 | // * Redistributions of source code must retain the above copyright
10 | // notice, this list of conditions and the following disclaimer.
11 | // * Redistributions in binary form must reproduce the above
12 | // copyright notice, this list of conditions and the following disclaimer
13 | // in the documentation and/or other materials provided with the
14 | // distribution.
15 | // * Neither the name of Google Inc. nor the names of its
16 | // contributors may be used to endorse or promote products derived from
17 | // this software without specific prior written permission.
18 | //
19 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
22 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
23 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
25 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 | package com.google.protobuf;
31 |
32 | import com.google.protobuf.Descriptors.EnumDescriptor;
33 | import com.google.protobuf.Descriptors.EnumValueDescriptor;
34 |
35 | /**
36 | * Interface of useful methods added to all enums generated by the protocol
37 | * compiler.
38 | */
39 | public interface ProtocolMessageEnum extends Internal.EnumLite
40 | {
41 |
42 | /**
43 | * Return the value's numeric value as defined in the .proto file.
44 | */
45 | int getNumber ();
46 |
47 | /**
48 | * Return the value's descriptor, which contains information such as value
49 | * name, number, and type.
50 | */
51 | EnumValueDescriptor getValueDescriptor ();
52 |
53 | /**
54 | * Return the enum type's descriptor, which contains information about each
55 | * defined value, etc.
56 | */
57 | EnumDescriptor getDescriptorForType ();
58 | }
59 |
--------------------------------------------------------------------------------
/src/com/google/protobuf/ProtocolStringList.java:
--------------------------------------------------------------------------------
1 | // Protocol Buffers - Google's data interchange format
2 | // Copyright 2008 Google Inc. All rights reserved.
3 | // http://code.google.com/p/protobuf/
4 | //
5 | // Redistribution and use in source and binary forms, with or without
6 | // modification, are permitted provided that the following conditions are
7 | // met:
8 | //
9 | // * Redistributions of source code must retain the above copyright
10 | // notice, this list of conditions and the following disclaimer.
11 | // * Redistributions in binary form must reproduce the above
12 | // copyright notice, this list of conditions and the following disclaimer
13 | // in the documentation and/or other materials provided with the
14 | // distribution.
15 | // * Neither the name of Google Inc. nor the names of its
16 | // contributors may be used to endorse or promote products derived from
17 | // this software without specific prior written permission.
18 | //
19 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
22 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
23 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
25 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 | package com.google.protobuf;
31 |
32 | import java.util.List;
33 |
34 | /**
35 | * An interface extending {@code List} used for repeated string fields
36 | * to provide optional access to the data as a list of ByteStrings. The
37 | * underlying implementation stores values as either ByteStrings or Strings (see
38 | * {@link LazyStringArrayList}) depending on how the value was initialized or
39 | * last read, and it is often more efficient to deal with lists of ByteStrings
40 | * when handling protos that have been deserialized from bytes.
41 | */
42 | public interface ProtocolStringList extends List
43 | {
44 |
45 | /**
46 | * Returns a view of the data as a list of ByteStrings.
47 | */
48 | List asByteStringList ();
49 |
50 | }
51 |
--------------------------------------------------------------------------------
/src/com/google/protobuf/RpcCallback.java:
--------------------------------------------------------------------------------
1 | // Protocol Buffers - Google's data interchange format
2 | // Copyright 2008 Google Inc. All rights reserved.
3 | // http://code.google.com/p/protobuf/
4 | //
5 | // Redistribution and use in source and binary forms, with or without
6 | // modification, are permitted provided that the following conditions are
7 | // met:
8 | //
9 | // * Redistributions of source code must retain the above copyright
10 | // notice, this list of conditions and the following disclaimer.
11 | // * Redistributions in binary form must reproduce the above
12 | // copyright notice, this list of conditions and the following disclaimer
13 | // in the documentation and/or other materials provided with the
14 | // distribution.
15 | // * Neither the name of Google Inc. nor the names of its
16 | // contributors may be used to endorse or promote products derived from
17 | // this software without specific prior written permission.
18 | //
19 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
22 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
23 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
25 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 | package com.google.protobuf;
31 |
32 | /**
33 | * Interface for an RPC callback, normally called when an RPC completes.
34 | * {@code ParameterType} is normally the method's response message type.
35 | *
36 | *
37 | * Starting with version 2.3.0, RPC implementations should not try to build on
38 | * this, but should instead provide code generator plugins which generate code
39 | * specific to the particular RPC implementation. This way the generated code
40 | * can be more appropriate for the implementation in use and can avoid
41 | * unnecessary layers of indirection.
42 | *
43 | * @author kenton@google.com Kenton Varda
44 | */
45 | public interface RpcCallback
46 | {
47 |
48 | void run (ParameterType parameter);
49 | }
50 |
--------------------------------------------------------------------------------
/src/com/google/protobuf/ServiceException.java:
--------------------------------------------------------------------------------
1 | // Protocol Buffers - Google's data interchange format
2 | // Copyright 2008 Google Inc. All rights reserved.
3 | // http://code.google.com/p/protobuf/
4 | //
5 | // Redistribution and use in source and binary forms, with or without
6 | // modification, are permitted provided that the following conditions are
7 | // met:
8 | //
9 | // * Redistributions of source code must retain the above copyright
10 | // notice, this list of conditions and the following disclaimer.
11 | // * Redistributions in binary form must reproduce the above
12 | // copyright notice, this list of conditions and the following disclaimer
13 | // in the documentation and/or other materials provided with the
14 | // distribution.
15 | // * Neither the name of Google Inc. nor the names of its
16 | // contributors may be used to endorse or promote products derived from
17 | // this software without specific prior written permission.
18 | //
19 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
22 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
23 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
25 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 | package com.google.protobuf;
31 |
32 | /**
33 | * Thrown by blocking RPC methods when a failure occurs.
34 | *
35 | * @author cpovirk@google.com (Chris Povirk)
36 | */
37 | public class ServiceException extends Exception
38 | {
39 |
40 | private static final long serialVersionUID = -1219262335729891920L;
41 |
42 | public ServiceException (final String message) {
43 | super (message);
44 | }
45 |
46 | public ServiceException (final Throwable cause) {
47 | super (cause);
48 | }
49 |
50 | public ServiceException (final String message, final Throwable cause) {
51 | super (message, cause);
52 | }
53 | }
54 |
--------------------------------------------------------------------------------
/src/com/jcraft/jhttptunnel/Bound.java:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright (c) 2004 ymnk, JCraft,Inc. All rights reserved.
3 |
4 | Redistribution and use in source and binary forms, with or without
5 | modification, are permitted provided that the following conditions are met:
6 |
7 | 1. Redistributions of source code must retain the above copyright notice,
8 | this list of conditions and the following disclaimer.
9 |
10 | 2. Redistributions in binary form must reproduce the above copyright
11 | notice, this list of conditions and the following disclaimer in
12 | the documentation and/or other materials provided with the distribution.
13 |
14 | 3. The names of the authors may not be used to endorse or promote products
15 | derived from this software without specific prior written permission.
16 |
17 | THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
18 | INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
19 | FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT,
20 | INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT,
21 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
23 | OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
24 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
25 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
26 | EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 | */
28 | package com.jcraft.jhttptunnel;
29 |
30 | import java.io.IOException;
31 |
32 | abstract class Bound
33 | {
34 |
35 | private String host = null;
36 | private int port = 80;
37 | protected int forwardPort;
38 |
39 | public Bound (int forwardPort) {
40 | this.forwardPort = forwardPort;
41 | }
42 |
43 | public void setHost (String host) {
44 | this.host = host;
45 | }
46 |
47 | public void setPort (int port) {
48 | this.port = port;
49 | }
50 |
51 | protected String getHost () {
52 | return host;
53 | }
54 |
55 | protected int getPort () {
56 | return port;
57 | }
58 |
59 | public int getForwardPort () {
60 | return forwardPort;
61 | }
62 |
63 | public void setForwardPort (int forwardPort) {
64 | this.forwardPort = forwardPort;
65 | }
66 |
67 | public abstract void connect () throws IOException;
68 |
69 | public abstract void close () throws IOException;
70 |
71 | }
72 |
--------------------------------------------------------------------------------
/src/com/jcraft/jhttptunnel/InBound.java:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright (c) 2004 ymnk, JCraft,Inc. All rights reserved.
3 |
4 | Redistribution and use in source and binary forms, with or without
5 | modification, are permitted provided that the following conditions are met:
6 |
7 | 1. Redistributions of source code must retain the above copyright notice,
8 | this list of conditions and the following disclaimer.
9 |
10 | 2. Redistributions in binary form must reproduce the above copyright
11 | notice, this list of conditions and the following disclaimer in
12 | the documentation and/or other materials provided with the distribution.
13 |
14 | 3. The names of the authors may not be used to endorse or promote products
15 | derived from this software without specific prior written permission.
16 |
17 | THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
18 | INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
19 | FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT,
20 | INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT,
21 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
23 | OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
24 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
25 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
26 | EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 | */
28 | package com.jcraft.jhttptunnel;
29 |
30 | import java.io.IOException;
31 |
32 | public abstract class InBound extends Bound
33 | {
34 |
35 | public InBound (int forwardPort) {
36 | super (forwardPort);
37 | }
38 |
39 | public abstract int receiveData (byte[] buf, int s, int l) throws IOException;
40 |
41 | public abstract void resetBackoffTime ();
42 |
43 | }
44 |
--------------------------------------------------------------------------------
/src/com/jcraft/jhttptunnel/JHttpTunnel.java:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright (c) 2004 ymnk, JCraft,Inc. All rights reserved.
3 |
4 | Redistribution and use in source and binary forms, with or without
5 | modification, are permitted provided that the following conditions are met:
6 |
7 | 1. Redistributions of source code must retain the above copyright notice,
8 | this list of conditions and the following disclaimer.
9 |
10 | 2. Redistributions in binary form must reproduce the above copyright
11 | notice, this list of conditions and the following disclaimer in
12 | the documentation and/or other materials provided with the distribution.
13 |
14 | 3. The names of the authors may not be used to endorse or promote products
15 | derived from this software without specific prior written permission.
16 |
17 | THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
18 | INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
19 | FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT,
20 | INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT,
21 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
23 | OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
24 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
25 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
26 | EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 | */
28 | package com.jcraft.jhttptunnel;
29 |
30 | public interface JHttpTunnel
31 | {
32 |
33 | public static final byte TUNNEL_OPEN = 1;
34 | public static final byte TUNNEL_DATA = 2;
35 | public static final byte TUNNEL_PADDING = 3;
36 | public static final byte TUNNEL_ERROR = 4;
37 | public static final byte TUNNEL_SIMPLE = 0x40;
38 | public static final byte TUNNEL_PAD1 = 5 | TUNNEL_SIMPLE;
39 | public static final byte TUNNEL_CLOSE = 6 | TUNNEL_SIMPLE;
40 | public static final byte TUNNEL_DISCONNECT = 7 | TUNNEL_SIMPLE;
41 | public static final byte TUNNEL_NEXT_READ = 10;
42 |
43 | }
44 |
--------------------------------------------------------------------------------
/src/com/jcraft/jhttptunnel/JHttpTunnelException.java:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright (c) 2004 ymnk, JCraft,Inc. All rights reserved.
3 |
4 | Redistribution and use in source and binary forms, with or without
5 | modification, are permitted provided that the following conditions are met:
6 |
7 | 1. Redistributions of source code must retain the above copyright notice,
8 | this list of conditions and the following disclaimer.
9 |
10 | 2. Redistributions in binary form must reproduce the above copyright
11 | notice, this list of conditions and the following disclaimer in
12 | the documentation and/or other materials provided with the distribution.
13 |
14 | 3. The names of the authors may not be used to endorse or promote products
15 | derived from this software without specific prior written permission.
16 |
17 | THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
18 | INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
19 | FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT,
20 | INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT,
21 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
23 | OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
24 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
25 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
26 | EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 | */
28 | package com.jcraft.jhttptunnel;
29 |
30 | import java.io.IOException;
31 |
32 | public class JHttpTunnelException extends IOException
33 | {
34 |
35 | public JHttpTunnelException () {
36 | }
37 |
38 | public JHttpTunnelException (String message) {
39 | super (message);
40 | }
41 |
42 | }
43 |
--------------------------------------------------------------------------------
/src/com/jcraft/jhttptunnel/OutBound.java:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright (c) 2004 ymnk, JCraft,Inc. All rights reserved.
3 |
4 | Redistribution and use in source and binary forms, with or without
5 | modification, are permitted provided that the following conditions are met:
6 |
7 | 1. Redistributions of source code must retain the above copyright notice,
8 | this list of conditions and the following disclaimer.
9 |
10 | 2. Redistributions in binary form must reproduce the above copyright
11 | notice, this list of conditions and the following disclaimer in
12 | the documentation and/or other materials provided with the distribution.
13 |
14 | 3. The names of the authors may not be used to endorse or promote products
15 | derived from this software without specific prior written permission.
16 |
17 | THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
18 | INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
19 | FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT,
20 | INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT,
21 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
23 | OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
24 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
25 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
26 | EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 | */
28 | package com.jcraft.jhttptunnel;
29 |
30 | import java.io.IOException;
31 |
32 | public abstract class OutBound extends Bound
33 | {
34 |
35 | private static final int CONTENT_LENGTH = 1024;
36 | private int content_length = CONTENT_LENGTH;
37 | protected int sendCount;
38 |
39 | public OutBound (int forwardPort) {
40 | super (forwardPort);
41 | }
42 |
43 | protected void setContentLength (int content_length) {
44 | this.content_length = content_length;
45 | }
46 |
47 | protected int getContentLength () {
48 | return content_length;
49 | }
50 |
51 | public abstract void sendData (byte[] foo, int s, int l, boolean flush) throws IOException;
52 |
53 | }
54 |
--------------------------------------------------------------------------------
/src/io/protostuff/CustomSchema.java:
--------------------------------------------------------------------------------
1 | //========================================================================
2 | //Copyright 2007-2010 David Yu dyuproject@gmail.com
3 | //------------------------------------------------------------------------
4 | //Licensed under the Apache License, Version 2.0 (the "License");
5 | //you may not use this file except in compliance with the License.
6 | //You may obtain a copy of the License at
7 | //http://www.apache.org/licenses/LICENSE-2.0
8 | //Unless required by applicable law or agreed to in writing, software
9 | //distributed under the License is distributed on an "AS IS" BASIS,
10 | //WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 | //See the License for the specific language governing permissions and
12 | //limitations under the License.
13 | //========================================================================
14 |
15 | package io.protostuff;
16 |
17 | import java.io.IOException;
18 |
19 | /**
20 | * A schema (helper class) that wraps another schema and allows its subclasses to override certain methods for more
21 | * customization.
22 | *
23 | * @author David Yu
24 | * @created May 28, 2010
25 | */
26 | public abstract class CustomSchema implements Schema
27 | {
28 |
29 | protected final Schema schema;
30 |
31 | public CustomSchema(Schema schema)
32 | {
33 | this.schema = schema;
34 | }
35 |
36 | @Override
37 | public String getFieldName(int number)
38 | {
39 | return schema.getFieldName(number);
40 | }
41 |
42 | @Override
43 | public int getFieldNumber(String name)
44 | {
45 | return schema.getFieldNumber(name);
46 | }
47 |
48 | @Override
49 | public boolean isInitialized(T message)
50 | {
51 | return schema.isInitialized(message);
52 | }
53 |
54 | @Override
55 | public void mergeFrom(Input input, T message) throws IOException
56 | {
57 | schema.mergeFrom(input, message);
58 | }
59 |
60 | @Override
61 | public String messageFullName()
62 | {
63 | return schema.messageFullName();
64 | }
65 |
66 | @Override
67 | public String messageName()
68 | {
69 | return schema.messageName();
70 | }
71 |
72 | @Override
73 | public T newMessage()
74 | {
75 | return schema.newMessage();
76 | }
77 |
78 | @Override
79 | public Class super T> typeClass()
80 | {
81 | return schema.typeClass();
82 | }
83 |
84 | @Override
85 | public void writeTo(Output output, T message) throws IOException
86 | {
87 | schema.writeTo(output, message);
88 | }
89 |
90 | }
91 |
--------------------------------------------------------------------------------
/src/io/protostuff/Exclude.java:
--------------------------------------------------------------------------------
1 | //================================================================================
2 | //Copyright (c) 2012, David Yu
3 | //All rights reserved.
4 | //--------------------------------------------------------------------------------
5 | // Redistribution and use in source and binary forms, with or without
6 | // modification, are permitted provided that the following conditions are met:
7 | // 1. Redistributions of source code must retain the above copyright notice,
8 | // this list of conditions and the following disclaimer.
9 | // 2. Redistributions in binary form must reproduce the above copyright notice,
10 | // this list of conditions and the following disclaimer in the documentation
11 | // and/or other materials provided with the distribution.
12 | // 3. Neither the name of protostuff nor the names of its contributors may be used
13 | // to endorse or promote products derived from this software without
14 | // specific prior written permission.
15 | //
16 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
17 | // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 | // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19 | // ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
20 | // LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
21 | // CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22 | // SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
23 | // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
24 | // CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
25 | // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
26 | // POSSIBILITY OF SUCH DAMAGE.
27 | //================================================================================
28 |
29 | package io.protostuff;
30 |
31 | import java.lang.annotation.ElementType;
32 | import java.lang.annotation.Retention;
33 | import java.lang.annotation.RetentionPolicy;
34 | import java.lang.annotation.Target;
35 |
36 | /**
37 | * A field annotation to configure the field ignored.
38 | *
39 | * @author Johannes Elgh
40 | * @created Jul 30, 2014
41 | */
42 | @Retention(RetentionPolicy.RUNTIME)
43 | @Target(ElementType.FIELD)
44 | public @interface Exclude
45 | {
46 |
47 | }
48 |
--------------------------------------------------------------------------------
/src/io/protostuff/GraphInput.java:
--------------------------------------------------------------------------------
1 | //========================================================================
2 | //Copyright 2007-2011 David Yu dyuproject@gmail.com
3 | //------------------------------------------------------------------------
4 | //Licensed under the Apache License, Version 2.0 (the "License");
5 | //you may not use this file except in compliance with the License.
6 | //You may obtain a copy of the License at
7 | //http://www.apache.org/licenses/LICENSE-2.0
8 | //Unless required by applicable law or agreed to in writing, software
9 | //distributed under the License is distributed on an "AS IS" BASIS,
10 | //WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 | //See the License for the specific language governing permissions and
12 | //limitations under the License.
13 | //========================================================================
14 |
15 | package io.protostuff;
16 |
17 | /**
18 | * An input that is stateful and keeps track of the references. This is useful for updating the reference of the last
19 | * message (polymorphic) deserialized.
20 | *
21 | * @author David Yu
22 | * @created Jan 19, 2011
23 | */
24 | public interface GraphInput extends Input
25 | {
26 |
27 | /**
28 | * Updates the last reference (the tip/end of the index) kept if the {@code lastMessage} was indeed the last
29 | * message.
30 | */
31 | public void updateLast(Object morphedMessage, Object lastMessage);
32 |
33 | /**
34 | * Returns true if the last message was read as a reference.
35 | */
36 | public boolean isCurrentMessageReference();
37 |
38 | }
39 |
--------------------------------------------------------------------------------
/src/io/protostuff/JsonInputException.java:
--------------------------------------------------------------------------------
1 | //========================================================================
2 | //Copyright 2007-2010 David Yu dyuproject@gmail.com
3 | //------------------------------------------------------------------------
4 | //Licensed under the Apache License, Version 2.0 (the "License");
5 | //you may not use this file except in compliance with the License.
6 | //You may obtain a copy of the License at
7 | //http://www.apache.org/licenses/LICENSE-2.0
8 | //Unless required by applicable law or agreed to in writing, software
9 | //distributed under the License is distributed on an "AS IS" BASIS,
10 | //WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 | //See the License for the specific language governing permissions and
12 | //limitations under the License.
13 | //========================================================================
14 |
15 | package io.protostuff;
16 |
17 | /**
18 | * Thrown when a json-encoded protobuf message being parsed is invalid in some way.
19 | *
20 | * @author David Yu
21 | * @created May 10, 2010
22 | */
23 | public class JsonInputException extends ProtostuffException
24 | {
25 |
26 | private static final long serialVersionUID = 8137903301860116023L;
27 |
28 | public JsonInputException(String description)
29 | {
30 | super(description);
31 | }
32 |
33 | }
34 |
--------------------------------------------------------------------------------
/src/io/protostuff/Message.java:
--------------------------------------------------------------------------------
1 | //========================================================================
2 | //Copyright 2007-2009 David Yu dyuproject@gmail.com
3 | //------------------------------------------------------------------------
4 | //Licensed under the Apache License, Version 2.0 (the "License");
5 | //you may not use this file except in compliance with the License.
6 | //You may obtain a copy of the License at
7 | //http://www.apache.org/licenses/LICENSE-2.0
8 | //Unless required by applicable law or agreed to in writing, software
9 | //distributed under the License is distributed on an "AS IS" BASIS,
10 | //WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 | //See the License for the specific language governing permissions and
12 | //limitations under the License.
13 | //========================================================================
14 |
15 | package io.protostuff;
16 |
17 | /**
18 | * The serializable object where its {@link Schema schema} handles its serialization and deserialization.
19 | *
20 | * @author David Yu
21 | * @created Nov 9, 2009
22 | */
23 | public interface Message
24 | {
25 |
26 | /**
27 | * Gets the cached schema of this message.
28 | */
29 | public Schema cachedSchema();
30 |
31 | }
32 |
--------------------------------------------------------------------------------
/src/io/protostuff/Morph.java:
--------------------------------------------------------------------------------
1 | //================================================================================
2 | //Copyright (c) 2012, David Yu
3 | //All rights reserved.
4 | //--------------------------------------------------------------------------------
5 | // Redistribution and use in source and binary forms, with or without
6 | // modification, are permitted provided that the following conditions are met:
7 | // 1. Redistributions of source code must retain the above copyright notice,
8 | // this list of conditions and the following disclaimer.
9 | // 2. Redistributions in binary form must reproduce the above copyright notice,
10 | // this list of conditions and the following disclaimer in the documentation
11 | // and/or other materials provided with the distribution.
12 | // 3. Neither the name of protostuff nor the names of its contributors may be used
13 | // to endorse or promote products derived from this software without
14 | // specific prior written permission.
15 | //
16 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
17 | // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 | // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19 | // ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
20 | // LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
21 | // CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22 | // SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
23 | // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
24 | // CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
25 | // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
26 | // POSSIBILITY OF SUCH DAMAGE.
27 | //================================================================================
28 |
29 | package io.protostuff;
30 |
31 | import java.lang.annotation.ElementType;
32 | import java.lang.annotation.Retention;
33 | import java.lang.annotation.RetentionPolicy;
34 | import java.lang.annotation.Target;
35 |
36 | /**
37 | * Used to configure non-final pojos, map interfaces and collection interfaces.
38 | *
39 | * @author David Yu
40 | * @created Apr 30, 2012
41 | */
42 | @Retention(RetentionPolicy.RUNTIME)
43 | @Target(ElementType.FIELD)
44 | public @interface Morph
45 | {
46 | boolean value() default true;
47 | }
48 |
--------------------------------------------------------------------------------
/src/io/protostuff/ProtostuffException.java:
--------------------------------------------------------------------------------
1 | //========================================================================
2 | //Copyright 2007-2010 David Yu dyuproject@gmail.com
3 | //------------------------------------------------------------------------
4 | //Licensed under the Apache License, Version 2.0 (the "License");
5 | //you may not use this file except in compliance with the License.
6 | //You may obtain a copy of the License at
7 | //http://www.apache.org/licenses/LICENSE-2.0
8 | //Unless required by applicable law or agreed to in writing, software
9 | //distributed under the License is distributed on an "AS IS" BASIS,
10 | //WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 | //See the License for the specific language governing permissions and
12 | //limitations under the License.
13 | //========================================================================
14 |
15 | package io.protostuff;
16 |
17 | import java.io.IOException;
18 |
19 | /**
20 | * The base io exception for all formats (protobuf/json/xml).
21 | *
22 | * @author David Yu
23 | * @created May 25, 2010
24 | */
25 | public class ProtostuffException extends IOException
26 | {
27 |
28 | private static final long serialVersionUID = 3969366848110070516L;
29 |
30 | public ProtostuffException()
31 | {
32 | super();
33 | }
34 |
35 | public ProtostuffException(String message)
36 | {
37 | super(message);
38 | }
39 |
40 | public ProtostuffException(String message, Throwable cause)
41 | {
42 | super(message, cause);
43 | }
44 |
45 | public ProtostuffException(Throwable cause)
46 | {
47 | super(cause);
48 | }
49 |
50 | }
51 |
--------------------------------------------------------------------------------
/src/io/protostuff/Request.java:
--------------------------------------------------------------------------------
1 | package io.protostuff;
2 |
3 | import java.lang.annotation.Documented;
4 | import java.lang.annotation.Retention;
5 | import java.lang.annotation.Target;
6 |
7 | import static java.lang.annotation.ElementType.METHOD;
8 | import static java.lang.annotation.RetentionPolicy.RUNTIME;
9 |
10 | /**
11 | * Specify rpc request qualifier.
12 | *
13 | * @author Kostiantyn Shchepanovskyi
14 | */
15 | @Documented
16 | @Target(METHOD)
17 | @Retention(RUNTIME)
18 | public @interface Request
19 | {
20 | String value();
21 | }
22 |
--------------------------------------------------------------------------------
/src/io/protostuff/Response.java:
--------------------------------------------------------------------------------
1 | package io.protostuff;
2 |
3 | import java.lang.annotation.Documented;
4 | import java.lang.annotation.Retention;
5 | import java.lang.annotation.Target;
6 |
7 | import static java.lang.annotation.ElementType.METHOD;
8 | import static java.lang.annotation.RetentionPolicy.RUNTIME;
9 |
10 | /**
11 | * Specify rpc response qualifier.
12 | *
13 | * @author Kostiantyn Shchepanovskyi
14 | */
15 | @Documented
16 | @Target(METHOD)
17 | @Retention(RUNTIME)
18 | public @interface Response
19 | {
20 | String value();
21 | }
22 |
--------------------------------------------------------------------------------
/src/io/protostuff/Rpc.java:
--------------------------------------------------------------------------------
1 | package io.protostuff;
2 |
3 | import java.lang.annotation.Retention;
4 | import java.lang.annotation.Target;
5 |
6 | import static java.lang.annotation.ElementType.METHOD;
7 | import static java.lang.annotation.RetentionPolicy.RUNTIME;
8 |
9 | /**
10 | * Marker annotation, indicates that an annotated method is a rpc service method.
11 | * Other annotations can be used for request/response qualifiers customization -
12 | * {@link Request}, {@link Response}.
13 | *
14 | * @author Kostiantyn Shchepanovskyi
15 | */
16 | @Retention(RUNTIME)
17 | @Target(METHOD)
18 | public @interface Rpc
19 | {
20 |
21 | }
22 |
--------------------------------------------------------------------------------
/src/io/protostuff/Service.java:
--------------------------------------------------------------------------------
1 | package io.protostuff;
2 |
3 | import java.lang.annotation.Retention;
4 | import java.lang.annotation.Target;
5 |
6 | import static java.lang.annotation.ElementType.TYPE;
7 | import static java.lang.annotation.RetentionPolicy.RUNTIME;
8 |
9 | /**
10 | * Rpc service annotation, specifies service namespace.
11 | *
12 | * https://github.com/protostuff/protostuff/wiki/Rpc-Services
13 | *
14 | *
23 | * By default, service namespace is formed as a package + '.' + service name.
24 | * In the example above, service namespace is "foo.Bar".
25 | *
26 | * Request and response qualifiers are generated using rpc method name.
27 | * Request qualifier is formed as service namespace + '/' + method name + 'Request'.
28 | * Response qualifier is formed as service namespace + '/' + method name + 'Response'.
29 | * In the example above, request/response qualifiers are "foo.Bar/DoWorkRequest" and
30 | * "foo.Bar/DoWorkResponse".
31 | *
32 | * @author Kostiantyn Shchepanovskyi
33 | */
34 | @Retention(RUNTIME)
35 | @Target(TYPE)
36 | public @interface Service
37 | {
38 |
39 | /**
40 | * Service namespace.
41 | */
42 | String value();
43 | }
44 |
--------------------------------------------------------------------------------
/src/io/protostuff/StatefulOutput.java:
--------------------------------------------------------------------------------
1 | //========================================================================
2 | //Copyright 2007-2011 David Yu dyuproject@gmail.com
3 | //------------------------------------------------------------------------
4 | //Licensed under the Apache License, Version 2.0 (the "License");
5 | //you may not use this file except in compliance with the License.
6 | //You may obtain a copy of the License at
7 | //http://www.apache.org/licenses/LICENSE-2.0
8 | //Unless required by applicable law or agreed to in writing, software
9 | //distributed under the License is distributed on an "AS IS" BASIS,
10 | //WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 | //See the License for the specific language governing permissions and
12 | //limitations under the License.
13 | //========================================================================
14 |
15 | package io.protostuff;
16 |
17 | /**
18 | * An output that keeps the state of the schema being used.
19 | *
20 | * @author David Yu
21 | * @created Jan 24, 2011
22 | */
23 | public interface StatefulOutput extends Output
24 | {
25 |
26 | /**
27 | * Updates the schema if {@code lastSchema} was indeed the last schema used.
28 | */
29 | public void updateLast(Schema> schema, Schema> lastSchema);
30 |
31 | }
32 |
--------------------------------------------------------------------------------
/src/io/protostuff/runtime/Field.java:
--------------------------------------------------------------------------------
1 | package io.protostuff.runtime;
2 |
3 | import java.io.IOException;
4 |
5 | import io.protostuff.Input;
6 | import io.protostuff.Output;
7 | import io.protostuff.Pipe;
8 | import io.protostuff.Tag;
9 | import io.protostuff.WireFormat;
10 |
11 | /**
12 | * Represents a field of a message/pojo.
13 | */
14 | public abstract class Field
15 | {
16 | public final WireFormat.FieldType type;
17 | public final int number;
18 | public final String name;
19 | public final boolean repeated;
20 | public final int groupFilter;
21 |
22 | // public final Tag tag;
23 |
24 | public Field(WireFormat.FieldType type, int number, String name, boolean repeated,
25 | Tag tag)
26 | {
27 | this.type = type;
28 | this.number = number;
29 | this.name = name;
30 | this.repeated = repeated;
31 | this.groupFilter = tag == null ? 0 : tag.groupFilter();
32 | // this.tag = tag;
33 | }
34 |
35 | public Field(WireFormat.FieldType type, int number, String name, Tag tag)
36 | {
37 | this(type, number, name, false, tag);
38 | }
39 |
40 | /**
41 | * Writes the value of a field to the {@code output}.
42 | */
43 | protected abstract void writeTo(Output output, T message)
44 | throws IOException;
45 |
46 | /**
47 | * Reads the field value into the {@code message}.
48 | */
49 | protected abstract void mergeFrom(Input input, T message)
50 | throws IOException;
51 |
52 | /**
53 | * Transfer the input field to the output field.
54 | */
55 | protected abstract void transfer(Pipe pipe, Input input, Output output,
56 | boolean repeated) throws IOException;
57 | }
58 |
--------------------------------------------------------------------------------
/src/io/protostuff/runtime/FieldMap.java:
--------------------------------------------------------------------------------
1 | package io.protostuff.runtime;
2 |
3 | import java.util.List;
4 |
5 | /**
6 | * Interface for map of fields - defines how to you get field by name or number (tag).
7 | *
8 | * @author Kostiantyn Shchepanovskyi
9 | */
10 | interface FieldMap
11 | {
12 |
13 | Field getFieldByNumber(int n);
14 |
15 | Field getFieldByName(String fieldName);
16 |
17 | int getFieldCount();
18 |
19 | List> getFields();
20 | }
21 |
--------------------------------------------------------------------------------
/src/io/protostuff/runtime/HasDelegate.java:
--------------------------------------------------------------------------------
1 | //========================================================================
2 | //Copyright 2012 David Yu
3 | //------------------------------------------------------------------------
4 | //Licensed under the Apache License, Version 2.0 (the "License");
5 | //you may not use this file except in compliance with the License.
6 | //You may obtain a copy of the License at
7 | //http://www.apache.org/licenses/LICENSE-2.0
8 | //Unless required by applicable law or agreed to in writing, software
9 | //distributed under the License is distributed on an "AS IS" BASIS,
10 | //WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 | //See the License for the specific language governing permissions and
12 | //limitations under the License.
13 | //========================================================================
14 |
15 | package io.protostuff.runtime;
16 |
17 | import io.protostuff.runtime.PolymorphicSchema.Handler;
18 |
19 | /**
20 | * Wraps a delegate.
21 | *
22 | * @author David Yu
23 | * @created Dec 5, 2012
24 | */
25 | public class HasDelegate implements PolymorphicSchema.Factory
26 | {
27 |
28 | public final Delegate delegate;
29 |
30 | public final ArraySchemas.Base genericElementSchema;
31 |
32 | @SuppressWarnings("unchecked")
33 | public HasDelegate(Delegate delegate)
34 | {
35 | this.delegate = delegate;
36 |
37 | genericElementSchema = new ArraySchemas.DelegateArray(null,
38 | (Delegate