wms-xstream-1.4.7

16:54:41.455 INFO  jd.cli.Main - Decompiling wms-xstream-1.4.7.jar
package com.thoughtworks.xstream;

import com.thoughtworks.xstream.converters.ConverterLookup;
import com.thoughtworks.xstream.converters.DataHolder;
import com.thoughtworks.xstream.io.HierarchicalStreamReader;
import com.thoughtworks.xstream.io.HierarchicalStreamWriter;
import com.thoughtworks.xstream.mapper.Mapper;

public abstract interface MarshallingStrategy
{
  public abstract Object unmarshal(Object paramObject, HierarchicalStreamReader paramHierarchicalStreamReader, DataHolder paramDataHolder, ConverterLookup paramConverterLookup, Mapper paramMapper);
  
  public abstract void marshal(HierarchicalStreamWriter paramHierarchicalStreamWriter, Object paramObject, ConverterLookup paramConverterLookup, Mapper paramMapper, DataHolder paramDataHolder);
}

/* Location:
 * Qualified Name:     com.thoughtworks.xstream.MarshallingStrategy
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package com.thoughtworks.xstream.io.copy;

import com.thoughtworks.xstream.io.HierarchicalStreamReader;
import com.thoughtworks.xstream.io.HierarchicalStreamWriter;

public class HierarchicalStreamCopier
{
  public void copy(HierarchicalStreamReader source, HierarchicalStreamWriter destination)
  {
    destination.startNode(source.getNodeName());
    int attributeCount = source.getAttributeCount();
    for (int i = 0; i < attributeCount; i++) {
      destination.addAttribute(source.getAttributeName(i), source.getAttribute(i));
    }
    String value = source.getValue();
    if ((value != null) && (value.length() > 0)) {
      destination.setValue(value);
    }
    while (source.hasMoreChildren())
    {
      source.moveDown();
      copy(source, destination);
      source.moveUp();
    }
    destination.endNode();
  }
}

/* Location:
 * Qualified Name:     com.thoughtworks.xstream.io.copy.HierarchicalStreamCopier
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package com.thoughtworks.xstream.io;

public abstract class WriterWrapper
  implements ExtendedHierarchicalStreamWriter
{
  protected HierarchicalStreamWriter wrapped;
  
  protected WriterWrapper(HierarchicalStreamWriter wrapped)
  {
    this.wrapped = wrapped;
  }
  
  public void startNode(String name)
  {
    wrapped.startNode(name);
  }
  
  public void startNode(String name, Class clazz)
  {
    ((ExtendedHierarchicalStreamWriter)wrapped).startNode(name, clazz);
  }
  
  public void endNode()
  {
    wrapped.endNode();
  }
  
  public void addAttribute(String key, String value)
  {
    wrapped.addAttribute(key, value);
  }
  
  public void setValue(String text)
  {
    wrapped.setValue(text);
  }
  
  public void flush()
  {
    wrapped.flush();
  }
  
  public void close()
  {
    wrapped.close();
  }
  
  public HierarchicalStreamWriter underlyingWriter()
  {
    return wrapped.underlyingWriter();
  }
}

/* Location:
 * Qualified Name:     com.thoughtworks.xstream.io.WriterWrapper
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package com.thoughtworks.xstream.io;

public abstract interface HierarchicalStreamWriter
{
  public abstract void startNode(String paramString);
  
  public abstract void addAttribute(String paramString1, String paramString2);
  
  public abstract void setValue(String paramString);
  
  public abstract void endNode();
  
  public abstract void flush();
  
  public abstract void close();
  
  public abstract HierarchicalStreamWriter underlyingWriter();
}

/* Location:
 * Qualified Name:     com.thoughtworks.xstream.io.HierarchicalStreamWriter
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package com.thoughtworks.xstream.io;

public abstract interface ExtendedHierarchicalStreamReader
  extends HierarchicalStreamReader
{
  public abstract String peekNextChild();
}

/* Location:
 * Qualified Name:     com.thoughtworks.xstream.io.ExtendedHierarchicalStreamReader
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package com.thoughtworks.xstream.io;

import java.io.File;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.Reader;
import java.io.Writer;
import java.net.URL;

public abstract interface HierarchicalStreamDriver
{
  public abstract HierarchicalStreamReader createReader(Reader paramReader);
  
  public abstract HierarchicalStreamReader createReader(InputStream paramInputStream);
  
  public abstract HierarchicalStreamReader createReader(URL paramURL);
  
  public abstract HierarchicalStreamReader createReader(File paramFile);
  
  public abstract HierarchicalStreamWriter createWriter(Writer paramWriter);
  
  public abstract HierarchicalStreamWriter createWriter(OutputStream paramOutputStream);
}

/* Location:
 * Qualified Name:     com.thoughtworks.xstream.io.HierarchicalStreamDriver
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package com.thoughtworks.xstream.io;

import com.thoughtworks.xstream.core.util.Cloneables;
import com.thoughtworks.xstream.io.naming.NameCoder;
import com.thoughtworks.xstream.io.naming.NoNameCoder;

public abstract class AbstractWriter
  implements ExtendedHierarchicalStreamWriter
{
  private NameCoder nameCoder;
  
  protected AbstractWriter()
  {
    this(new NoNameCoder());
  }
  
  protected AbstractWriter(NameCoder nameCoder)
  {
    this.nameCoder = ((NameCoder)Cloneables.cloneIfPossible(nameCoder));
  }
  
  public void startNode(String name, Class clazz)
  {
    startNode(name);
  }
  
  public HierarchicalStreamWriter underlyingWriter()
  {
    return this;
  }
  
  public String encodeNode(String name)
  {
    return nameCoder.encodeNode(name);
  }
  
  public String encodeAttribute(String name)
  {
    return nameCoder.encodeAttribute(name);
  }
}

/* Location:
 * Qualified Name:     com.thoughtworks.xstream.io.AbstractWriter
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package com.thoughtworks.xstream.io;

public class ExtendedHierarchicalStreamWriterHelper
{
  public static void startNode(HierarchicalStreamWriter writer, String name, Class clazz)
  {
    if ((writer instanceof ExtendedHierarchicalStreamWriter)) {
      ((ExtendedHierarchicalStreamWriter)writer).startNode(name, clazz);
    } else {
      writer.startNode(name);
    }
  }
}

/* Location:
 * Qualified Name:     com.thoughtworks.xstream.io.ExtendedHierarchicalStreamWriterHelper
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package com.thoughtworks.xstream.io;

import com.thoughtworks.xstream.core.util.FastStack;
import java.io.IOException;
import java.util.HashSet;
import java.util.Set;

public class StatefulWriter
  extends WriterWrapper
{
  public static int STATE_OPEN = 0;
  public static int STATE_NODE_START = 1;
  public static int STATE_VALUE = 2;
  public static int STATE_NODE_END = 3;
  public static int STATE_CLOSED = 4;
  private transient int state = STATE_OPEN;
  private transient int balance;
  private transient FastStack attributes;
  
  public StatefulWriter(HierarchicalStreamWriter wrapped)
  {
    super(wrapped);
    attributes = new FastStack(16);
  }
  
  public void startNode(String name)
  {
    startNodeCommon();
    super.startNode(name);
  }
  
  public void startNode(String name, Class clazz)
  {
    startNodeCommon();
    super.startNode(name, clazz);
  }
  
  private void startNodeCommon()
  {
    checkClosed();
    if (state == STATE_VALUE) {
      throw new StreamException(new IllegalStateException("Opening node after writing text"));
    }
    state = STATE_NODE_START;
    balance += 1;
    attributes.push(new HashSet());
  }
  
  public void addAttribute(String name, String value)
  {
    checkClosed();
    if (state != STATE_NODE_START) {
      throw new StreamException(new IllegalStateException("Writing attribute '" + name + "' without an opened node"));
    }
    Set currentAttributes = (Set)attributes.peek();
    if (currentAttributes.contains(name)) {
      throw new StreamException(new IllegalStateException("Writing attribute '" + name + "' twice"));
    }
    currentAttributes.add(name);
    super.addAttribute(name, value);
  }
  
  public void setValue(String text)
  {
    checkClosed();
    if (state != STATE_NODE_START) {
      throw new StreamException(new IllegalStateException("Writing text without an opened node"));
    }
    state = STATE_VALUE;
    super.setValue(text);
  }
  
  public void endNode()
  {
    checkClosed();
    if (balance-- == 0) {
      throw new StreamException(new IllegalStateException("Unbalanced node"));
    }
    attributes.popSilently();
    state = STATE_NODE_END;
    super.endNode();
  }
  
  public void flush()
  {
    checkClosed();
    super.flush();
  }
  
  public void close()
  {
    if ((state != STATE_NODE_END) && (state != STATE_OPEN)) {}
    state = STATE_CLOSED;
    super.close();
  }
  
  private void checkClosed()
  {
    if (state == STATE_CLOSED) {
      throw new StreamException(new IOException("Writing on a closed stream"));
    }
  }
  
  public int state()
  {
    return state;
  }
  
  private Object readResolve()
  {
    attributes = new FastStack(16);
    return this;
  }
}

/* Location:
 * Qualified Name:     com.thoughtworks.xstream.io.StatefulWriter
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package com.thoughtworks.xstream.io;

import com.thoughtworks.xstream.converters.ErrorReporter;
import com.thoughtworks.xstream.converters.ErrorWriter;
import java.util.Iterator;

public abstract interface HierarchicalStreamReader
  extends ErrorReporter
{
  public abstract boolean hasMoreChildren();
  
  public abstract void moveDown();
  
  public abstract void moveUp();
  
  public abstract String getNodeName();
  
  public abstract String getValue();
  
  public abstract String getAttribute(String paramString);
  
  public abstract String getAttribute(int paramInt);
  
  public abstract int getAttributeCount();
  
  public abstract String getAttributeName(int paramInt);
  
  public abstract Iterator getAttributeNames();
  
  public abstract void appendErrors(ErrorWriter paramErrorWriter);
  
  public abstract void close();
  
  public abstract HierarchicalStreamReader underlyingReader();
}

/* Location:
 * Qualified Name:     com.thoughtworks.xstream.io.HierarchicalStreamReader
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package com.thoughtworks.xstream.io;

import com.thoughtworks.xstream.converters.ErrorWriter;
import java.util.Iterator;

public abstract class ReaderWrapper
  implements ExtendedHierarchicalStreamReader
{
  protected HierarchicalStreamReader wrapped;
  
  protected ReaderWrapper(HierarchicalStreamReader reader)
  {
    wrapped = reader;
  }
  
  public boolean hasMoreChildren()
  {
    return wrapped.hasMoreChildren();
  }
  
  public void moveDown()
  {
    wrapped.moveDown();
  }
  
  public void moveUp()
  {
    wrapped.moveUp();
  }
  
  public String getNodeName()
  {
    return wrapped.getNodeName();
  }
  
  public String getValue()
  {
    return wrapped.getValue();
  }
  
  public String getAttribute(String name)
  {
    return wrapped.getAttribute(name);
  }
  
  public String getAttribute(int index)
  {
    return wrapped.getAttribute(index);
  }
  
  public int getAttributeCount()
  {
    return wrapped.getAttributeCount();
  }
  
  public String getAttributeName(int index)
  {
    return wrapped.getAttributeName(index);
  }
  
  public Iterator getAttributeNames()
  {
    return wrapped.getAttributeNames();
  }
  
  public void appendErrors(ErrorWriter errorWriter)
  {
    wrapped.appendErrors(errorWriter);
  }
  
  public void close()
  {
    wrapped.close();
  }
  
  public String peekNextChild()
  {
    if (!(wrapped instanceof ExtendedHierarchicalStreamReader)) {
      throw new UnsupportedOperationException("peekNextChild");
    }
    return ((ExtendedHierarchicalStreamReader)wrapped).peekNextChild();
  }
  
  public HierarchicalStreamReader underlyingReader()
  {
    return wrapped.underlyingReader();
  }
}

/* Location:
 * Qualified Name:     com.thoughtworks.xstream.io.ReaderWrapper
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package com.thoughtworks.xstream.io;

import com.thoughtworks.xstream.io.naming.NameCoder;
import com.thoughtworks.xstream.io.naming.NoNameCoder;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;

public abstract class AbstractDriver
  implements HierarchicalStreamDriver
{
  private NameCoder replacer;
  
  public AbstractDriver()
  {
    this(new NoNameCoder());
  }
  
  public AbstractDriver(NameCoder nameCoder)
  {
    replacer = nameCoder;
  }
  
  protected NameCoder getNameCoder()
  {
    return replacer;
  }
  
  public HierarchicalStreamReader createReader(URL in)
  {
    InputStream stream = null;
    try
    {
      stream = in.openStream();
    }
    catch (IOException e)
    {
      throw new StreamException(e);
    }
    return createReader(stream);
  }
  
  public HierarchicalStreamReader createReader(File in)
  {
    try
    {
      return createReader(new FileInputStream(in));
    }
    catch (FileNotFoundException e)
    {
      throw new StreamException(e);
    }
  }
}

/* Location:
 * Qualified Name:     com.thoughtworks.xstream.io.AbstractDriver
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package com.thoughtworks.xstream.io.json;

public class AbstractJsonWriter$Type
{
  public static Type NULL = new Type();
  public static Type STRING = new Type();
  public static Type NUMBER = new Type();
  public static Type BOOLEAN = new Type();
}

/* Location:
 * Qualified Name:     com.thoughtworks.xstream.io.json.AbstractJsonWriter.Type
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package com.thoughtworks.xstream.io.json;

class AbstractJsonWriter$StackElement
{
  final Class type;
  int status;
  
  public AbstractJsonWriter$StackElement(Class type, int status)
  {
    this.type = type;
    this.status = status;
  }
}

/* Location:
 * Qualified Name:     com.thoughtworks.xstream.io.json.AbstractJsonWriter.StackElement
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package com.thoughtworks.xstream.io.json;

class AbstractJsonWriter$IllegalWriterStateException
  extends IllegalStateException
{
  public AbstractJsonWriter$IllegalWriterStateException(int from, int to, String element)
  {
    super("Cannot turn from state " + getState(from) + " into state " + getState(to) + (element == null ? "" : new StringBuilder().append(" for property ").append(element).toString()));
  }
  
  private static String getState(int state)
  {
    switch (state)
    {
    case 1: 
      return "ROOT";
    case 2: 
      return "END_OBJECT";
    case 4: 
      return "START_OBJECT";
    case 8: 
      return "START_ATTRIBUTES";
    case 16: 
      return "NEXT_ATTRIBUTE";
    case 32: 
      return "END_ATTRIBUTES";
    case 64: 
      return "START_ELEMENTS";
    case 128: 
      return "NEXT_ELEMENT";
    case 256: 
      return "END_ELEMENTS";
    case 512: 
      return "SET_VALUE";
    }
    throw new IllegalArgumentException("Unknown state provided: " + state + ", cannot create message for IllegalWriterStateException");
  }
}

/* Location:
 * Qualified Name:     com.thoughtworks.xstream.io.json.AbstractJsonWriter.IllegalWriterStateException
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package com.thoughtworks.xstream.io.json;

import com.thoughtworks.xstream.converters.ConversionException;
import com.thoughtworks.xstream.core.util.FastStack;
import com.thoughtworks.xstream.io.AbstractWriter;
import com.thoughtworks.xstream.io.naming.NameCoder;
import com.thoughtworks.xstream.io.naming.NoNameCoder;
import com.thoughtworks.xstream.mapper.Mapper.Null;
import java.io.Externalizable;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.Arrays;
import java.util.Collection;
import java.util.HashSet;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;

public abstract class AbstractJsonWriter
  extends AbstractWriter
{
  public static final int DROP_ROOT_MODE = 1;
  public static final int STRICT_MODE = 2;
  public static final int EXPLICIT_MODE = 4;
  public static final int IEEE_754_MODE = 8;
  private static final int STATE_ROOT = 1;
  private static final int STATE_END_OBJECT = 2;
  private static final int STATE_START_OBJECT = 4;
  private static final int STATE_START_ATTRIBUTES = 8;
  private static final int STATE_NEXT_ATTRIBUTE = 16;
  private static final int STATE_END_ATTRIBUTES = 32;
  private static final int STATE_START_ELEMENTS = 64;
  private static final int STATE_NEXT_ELEMENT = 128;
  private static final int STATE_END_ELEMENTS = 256;
  private static final int STATE_SET_VALUE = 512;
  
  public static class Type
  {
    public static Type NULL = new Type();
    public static Type STRING = new Type();
    public static Type NUMBER = new Type();
    public static Type BOOLEAN = new Type();
  }
  
  private static class StackElement
  {
    final Class type;
    int status;
    
    public StackElement(Class type, int status)
    {
      this.type = type;
      this.status = status;
    }
  }
  
  private static class IllegalWriterStateException
    extends IllegalStateException
  {
    public IllegalWriterStateException(int from, int to, String element)
    {
      super();
    }
    
    private static String getState(int state)
    {
      switch (state)
      {
      case 1: 
        return "ROOT";
      case 2: 
        return "END_OBJECT";
      case 4: 
        return "START_OBJECT";
      case 8: 
        return "START_ATTRIBUTES";
      case 16: 
        return "NEXT_ATTRIBUTE";
      case 32: 
        return "END_ATTRIBUTES";
      case 64: 
        return "START_ELEMENTS";
      case 128: 
        return "NEXT_ELEMENT";
      case 256: 
        return "END_ELEMENTS";
      case 512: 
        return "SET_VALUE";
      }
      throw new IllegalArgumentException("Unknown state provided: " + state + ", cannot create message for IllegalWriterStateException");
    }
  }
  
  private static final Set NUMBER_TYPES = new HashSet(Arrays.asList(new Class[] { Byte.TYPE, Byte.class, Short.TYPE, Short.class, Integer.TYPE, Integer.class, Long.TYPE, Long.class, Float.TYPE, Float.class, Double.TYPE, Double.class, BigInteger.class, BigDecimal.class }));
  private int mode;
  private FastStack stack = new FastStack(16);
  private int expectedStates;
  
  public AbstractJsonWriter()
  {
    this(new NoNameCoder());
  }
  
  public AbstractJsonWriter(int mode)
  {
    this(mode, new NoNameCoder());
  }
  
  public AbstractJsonWriter(NameCoder nameCoder)
  {
    this(0, nameCoder);
  }
  
  public AbstractJsonWriter(int mode, NameCoder nameCoder)
  {
    super(nameCoder);
    this.mode = ((mode & 0x4) > 0 ? 4 : mode);
    stack.push(new StackElement(null, 1));
    expectedStates = 4;
  }
  
  public void startNode(String name, Class clazz)
  {
    if (name == null) {
      throw new NullPointerException("name");
    }
    stack.push(new StackElement(clazz, stack.peek()).status));
    handleCheckedStateTransition(4, name, null);
    expectedStates = 661;
  }
  
  public void startNode(String name)
  {
    startNode(name, null);
  }
  
  public void addAttribute(String name, String value)
  {
    handleCheckedStateTransition(16, name, value);
    expectedStates = 661;
  }
  
  public void setValue(String text)
  {
    Class type = stack.peek()).type;
    if (((type == Character.class) || (type == Character.TYPE)) && ("".equals(text))) {
      text = "\000";
    }
    handleCheckedStateTransition(512, null, text);
    expectedStates = 129;
  }
  
  public void endNode()
  {
    int size = stack.size();
    int nextState = size > 2 ? 128 : 1;
    handleCheckedStateTransition(nextState, null, null);
    stack.pop();
    stack.peek()).status = nextState;
    expectedStates = 4;
    if (size > 2) {
      expectedStates |= 0x81;
    }
  }
  
  private void handleCheckedStateTransition(int requiredState, String elementToAdd, String valueToAdd)
  {
    StackElement stackElement = (StackElement)stack.peek();
    if ((expectedStates & requiredState) == 0) {
      throw new IllegalWriterStateException(status, requiredState, elementToAdd);
    }
    int currentState = handleStateTransition(status, requiredState, elementToAdd, valueToAdd);
    status = currentState;
  }
  
  private int handleStateTransition(int currentState, int requiredState, String elementToAdd, String valueToAdd)
  {
    int size = stack.size();
    Class currentType = stack.peek()).type;
    boolean isArray = (size > 1) && (isArray(currentType));
    boolean isArrayElement = (size > 1) && (isArray(stack.get(size - 2)).type));
    switch (currentState)
    {
    case 1: 
      if (requiredState == 4)
      {
        currentState = handleStateTransition(64, 4, elementToAdd, null);
        return requiredState;
      }
      throw new IllegalWriterStateException(currentState, requiredState, elementToAdd);
    case 2: 
      switch (requiredState)
      {
      case 4: 
        currentState = handleStateTransition(currentState, 128, null, null);
        currentState = handleStateTransition(currentState, 4, elementToAdd, null);
        return requiredState;
      case 128: 
        nextElement();
        return requiredState;
      case 1: 
        if ((((mode & 0x1) == 0) || (size > 2)) && ((mode & 0x4) == 0)) {
          endObject();
        }
        return requiredState;
      }
      throw new IllegalWriterStateException(currentState, requiredState, elementToAdd);
    case 4: 
      switch (requiredState)
      {
      case 1: 
      case 4: 
      case 128: 
      case 512: 
        if ((!isArrayElement) || ((mode & 0x4) != 0))
        {
          currentState = handleStateTransition(currentState, 8, null, null);
          currentState = handleStateTransition(currentState, 32, null, null);
        }
        currentState = 64;
        switch (requiredState)
        {
        case 512: 
          currentState = handleStateTransition(currentState, 512, null, valueToAdd);
          break;
        case 4: 
          currentState = handleStateTransition(currentState, 4, elementToAdd, null);
          break;
        case 1: 
        case 128: 
          currentState = handleStateTransition(currentState, 512, null, null);
          currentState = handleStateTransition(currentState, requiredState, null, null);
        }
        return requiredState;
      case 8: 
        if ((mode & 0x4) != 0) {
          startArray();
        }
        return requiredState;
      case 16: 
        if (((mode & 0x4) != 0) || (!isArray))
        {
          currentState = handleStateTransition(currentState, 8, null, null);
          currentState = handleStateTransition(currentState, 16, elementToAdd, valueToAdd);
          return requiredState;
        }
        return 4;
      }
      throw new IllegalWriterStateException(currentState, requiredState, elementToAdd);
    case 128: 
      switch (requiredState)
      {
      case 4: 
        nextElement();
        if ((!isArrayElement) && ((mode & 0x4) == 0))
        {
          addLabel(encodeNode(elementToAdd));
          if (((mode & 0x4) == 0) && (isArray)) {
            startArray();
          }
          return requiredState;
        }
        break;
      case 1: 
        currentState = handleStateTransition(currentState, 2, null, null);
        currentState = handleStateTransition(currentState, 1, null, null);
        return requiredState;
      case 2: 
      case 128: 
        currentState = handleStateTransition(currentState, 256, null, null);
        currentState = handleStateTransition(currentState, 2, null, null);
        if (((mode & 0x4) == 0) && (!isArray)) {
          endObject();
        }
        return requiredState;
      case 256: 
        if (((mode & 0x4) == 0) && (isArray)) {
          endArray();
        }
        return requiredState;
      default: 
        throw new IllegalWriterStateException(currentState, requiredState, elementToAdd);
      }
    case 64: 
      switch (requiredState)
      {
      case 4: 
        if (((mode & 0x1) == 0) || (size > 2))
        {
          if ((!isArrayElement) || ((mode & 0x4) != 0))
          {
            if (!"".equals(valueToAdd)) {
              startObject();
            }
            addLabel(encodeNode(elementToAdd));
          }
          if ((mode & 0x4) != 0) {
            startArray();
          }
        }
        if (((mode & 0x4) == 0) && 
          (isArray)) {
          startArray();
        }
        return requiredState;
      case 512: 
        if (((mode & 0x2) != 0) && (size == 2)) {
          throw new ConversionException("Single value cannot be root element");
        }
        if (valueToAdd == null)
        {
          if (currentType == Mapper.Null.class)
          {
            addValue("null", Type.NULL);
          }
          else if (((mode & 0x4) == 0) && (!isArray))
          {
            startObject();
            endObject();
          }
        }
        else if (((mode & 0x8) != 0) && ((currentType == Long.TYPE) || (currentType == Long.class)))
        {
          long longValue = Long.parseLong(valueToAdd);
          if ((longValue > 9007199254740992L) || (longValue < -9007199254740992L)) {
            addValue(valueToAdd, Type.STRING);
          } else {
            addValue(valueToAdd, getType(currentType));
          }
        }
        else
        {
          addValue(valueToAdd, getType(currentType));
        }
        return requiredState;
      case 128: 
      case 256: 
        if ((mode & 0x4) == 0) {
          if (isArray) {
            endArray();
          } else {
            endObject();
          }
        }
        return requiredState;
      }
      throw new IllegalWriterStateException(currentState, requiredState, elementToAdd);
    case 256: 
      switch (requiredState)
      {
      case 2: 
        if ((mode & 0x4) != 0)
        {
          endArray();
          endArray();
          endObject();
        }
        return requiredState;
      }
      throw new IllegalWriterStateException(currentState, requiredState, elementToAdd);
    case 8: 
      switch (requiredState)
      {
      case 16: 
        if (elementToAdd != null)
        {
          String name = ((mode & 0x4) == 0 ? "@" : "") + elementToAdd;
          startObject();
          addLabel(encodeAttribute(name));
          addValue(valueToAdd, Type.STRING);
        }
        return requiredState;
      }
    case 16: 
      switch (requiredState)
      {
      case 32: 
        if ((mode & 0x4) != 0)
        {
          if (currentState == 16) {
            endObject();
          }
          endArray();
          nextElement();
          startArray();
        }
        return requiredState;
      case 16: 
        if ((!isArray) || ((mode & 0x4) != 0))
        {
          nextElement();
          String name = ((mode & 0x4) == 0 ? "@" : "") + elementToAdd;
          addLabel(encodeAttribute(name));
          addValue(valueToAdd, Type.STRING);
        }
        return requiredState;
      case 4: 
      case 512: 
        currentState = handleStateTransition(currentState, 32, null, null);
        currentState = handleStateTransition(currentState, 64, null, null);
        switch (requiredState)
        {
        case 512: 
          if ((mode & 0x4) == 0) {
            addLabel(encodeNode("$"));
          }
          currentState = handleStateTransition(currentState, 512, null, valueToAdd);
          if ((mode & 0x4) == 0) {
            endObject();
          }
          break;
        case 4: 
          currentState = handleStateTransition(currentState, 4, elementToAdd, (mode & 0x4) == 0 ? "" : null);
          break;
        case 2: 
          currentState = handleStateTransition(currentState, 512, null, null);
          currentState = handleStateTransition(currentState, 2, null, null);
        }
        return requiredState;
      case 128: 
        currentState = handleStateTransition(currentState, 32, null, null);
        currentState = handleStateTransition(currentState, 2, null, null);
        return requiredState;
      case 1: 
        currentState = handleStateTransition(currentState, 32, null, null);
        currentState = handleStateTransition(currentState, 2, null, null);
        currentState = handleStateTransition(currentState, 1, null, null);
        return requiredState;
      }
      throw new IllegalWriterStateException(currentState, requiredState, elementToAdd);
    case 32: 
      switch (requiredState)
      {
      case 64: 
        if ((mode & 0x4) == 0) {
          nextElement();
        }
        break;
      case 2: 
        currentState = handleStateTransition(64, 256, null, null);
        currentState = handleStateTransition(currentState, 2, null, null);
        break;
      default: 
        throw new IllegalWriterStateException(currentState, requiredState, elementToAdd);
      }
      return requiredState;
    case 512: 
      switch (requiredState)
      {
      case 256: 
        if (((mode & 0x4) == 0) && (isArray)) {
          endArray();
        }
        return requiredState;
      case 128: 
        currentState = handleStateTransition(currentState, 256, null, null);
        currentState = handleStateTransition(currentState, 2, null, null);
        return requiredState;
      case 1: 
        currentState = handleStateTransition(currentState, 256, null, null);
        currentState = handleStateTransition(currentState, 2, null, null);
        currentState = handleStateTransition(currentState, 1, null, null);
        return requiredState;
      }
      throw new IllegalWriterStateException(currentState, requiredState, elementToAdd);
    }
    throw new IllegalWriterStateException(currentState, requiredState, elementToAdd);
  }
  
  protected Type getType(Class clazz)
  {
    return NUMBER_TYPES.contains(clazz) ? Type.NUMBER : (clazz == Boolean.class) || (clazz == Boolean.TYPE) ? Type.BOOLEAN : clazz == Mapper.Null.class ? Type.NULL : Type.STRING;
  }
  
  protected boolean isArray(Class clazz)
  {
    return (clazz != null) && ((clazz.isArray()) || (Collection.class.isAssignableFrom(clazz)) || (Externalizable.class.isAssignableFrom(clazz)) || (Map.class.isAssignableFrom(clazz)) || (Map.Entry.class.isAssignableFrom(clazz)));
  }
  
  protected abstract void startObject();
  
  protected abstract void addLabel(String paramString);
  
  protected abstract void addValue(String paramString, Type paramType);
  
  protected abstract void startArray();
  
  protected abstract void nextElement();
  
  protected abstract void endArray();
  
  protected abstract void endObject();
}

/* Location:
 * Qualified Name:     com.thoughtworks.xstream.io.json.AbstractJsonWriter
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package com.thoughtworks.xstream.io.json;

import com.thoughtworks.xstream.io.naming.NameCoder;
import com.thoughtworks.xstream.io.naming.NoNameCoder;

public class JsonWriter$Format
{
  public static int SPACE_AFTER_LABEL = 1;
  public static int COMPACT_EMPTY_ELEMENT = 2;
  private char[] lineIndenter;
  private char[] newLine;
  private final int mode;
  private final NameCoder nameCoder;
  
  public JsonWriter$Format()
  {
    this(new char[] { ' ', ' ' }, new char[] { '\n' }, SPACE_AFTER_LABEL | COMPACT_EMPTY_ELEMENT);
  }
  
  public JsonWriter$Format(char[] lineIndenter, char[] newLine, int mode)
  {
    this(lineIndenter, newLine, mode, new NoNameCoder());
  }
  
  public JsonWriter$Format(char[] lineIndenter, char[] newLine, int mode, NameCoder nameCoder)
  {
    this.lineIndenter = lineIndenter;
    this.newLine = newLine;
    this.mode = mode;
    this.nameCoder = nameCoder;
  }
  
  public char[] getLineIndenter()
  {
    return lineIndenter;
  }
  
  public char[] getNewLine()
  {
    return newLine;
  }
  
  public int mode()
  {
    return mode;
  }
  
  public NameCoder getNameCoder()
  {
    return nameCoder;
  }
}

/* Location:
 * Qualified Name:     com.thoughtworks.xstream.io.json.JsonWriter.Format
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package com.thoughtworks.xstream.io.json;

import com.thoughtworks.xstream.io.naming.NameCoder;
import com.thoughtworks.xstream.io.xml.QNameMap;
import com.thoughtworks.xstream.io.xml.StaxWriter;
import com.thoughtworks.xstream.io.xml.XmlFriendlyReplacer;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Map;
import javax.xml.namespace.QName;
import javax.xml.stream.XMLStreamException;
import javax.xml.stream.XMLStreamWriter;
import org.codehaus.jettison.AbstractXMLStreamWriter;
import org.codehaus.jettison.mapped.MappedNamespaceConvention;

public class JettisonStaxWriter
  extends StaxWriter
{
  private final MappedNamespaceConvention convention;
  
  public JettisonStaxWriter(QNameMap qnameMap, XMLStreamWriter out, boolean writeEnclosingDocument, boolean namespaceRepairingMode, NameCoder nameCoder, MappedNamespaceConvention convention)
    throws XMLStreamException
  {
    super(qnameMap, out, writeEnclosingDocument, namespaceRepairingMode, nameCoder);
    this.convention = convention;
  }
  
  /**
   * @deprecated
   */
  public JettisonStaxWriter(QNameMap qnameMap, XMLStreamWriter out, boolean writeEnclosingDocument, boolean namespaceRepairingMode, XmlFriendlyReplacer replacer, MappedNamespaceConvention convention)
    throws XMLStreamException
  {
    this(qnameMap, out, writeEnclosingDocument, namespaceRepairingMode, replacer, convention);
  }
  
  public JettisonStaxWriter(QNameMap qnameMap, XMLStreamWriter out, boolean writeEnclosingDocument, boolean namespaceRepairingMode, MappedNamespaceConvention convention)
    throws XMLStreamException
  {
    super(qnameMap, out, writeEnclosingDocument, namespaceRepairingMode);
    this.convention = convention;
  }
  
  public JettisonStaxWriter(QNameMap qnameMap, XMLStreamWriter out, MappedNamespaceConvention convention)
    throws XMLStreamException
  {
    super(qnameMap, out);
    this.convention = convention;
  }
  
  public JettisonStaxWriter(QNameMap qnameMap, XMLStreamWriter out, NameCoder nameCoder, MappedNamespaceConvention convention)
    throws XMLStreamException
  {
    super(qnameMap, out, nameCoder);
    this.convention = convention;
  }
  
  public void startNode(String name, Class clazz)
  {
    XMLStreamWriter out = getXMLStreamWriter();
    if ((clazz != null) && ((out instanceof AbstractXMLStreamWriter)) && (
      (Collection.class.isAssignableFrom(clazz)) || (Map.class.isAssignableFrom(clazz)) || (clazz.isArray())))
    {
      QName qname = getQNameMap().getQName(encodeNode(name));
      String prefix = qname.getPrefix();
      String uri = qname.getNamespaceURI();
      String key = convention.createKey(prefix, uri, qname.getLocalPart());
      if (!((AbstractXMLStreamWriter)out).getSerializedAsArrays().contains(key)) {
        ((AbstractXMLStreamWriter)out).seriliazeAsArray(key);
      }
    }
    startNode(name);
  }
}

/* Location:
 * Qualified Name:     com.thoughtworks.xstream.io.json.JettisonStaxWriter
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package com.thoughtworks.xstream.io.json;

import com.thoughtworks.xstream.core.util.QuickWriter;
import com.thoughtworks.xstream.io.HierarchicalStreamWriter;
import com.thoughtworks.xstream.io.naming.NameCoder;
import com.thoughtworks.xstream.io.naming.NoNameCoder;
import java.io.Writer;

public class JsonWriter
  extends AbstractJsonWriter
{
  protected final QuickWriter writer;
  protected final Format format;
  private int depth;
  private boolean newLineProposed;
  
  /**
   * @deprecated
   */
  public JsonWriter(Writer writer, char[] lineIndenter, String newLine)
  {
    this(writer, 0, new Format(lineIndenter, newLine.toCharArray(), Format.SPACE_AFTER_LABEL | Format.COMPACT_EMPTY_ELEMENT));
  }
  
  /**
   * @deprecated
   */
  public JsonWriter(Writer writer, char[] lineIndenter)
  {
    this(writer, 0, new Format(lineIndenter, new char[] { '\n' }, Format.SPACE_AFTER_LABEL | Format.COMPACT_EMPTY_ELEMENT));
  }
  
  /**
   * @deprecated
   */
  public JsonWriter(Writer writer, String lineIndenter, String newLine)
  {
    this(writer, 0, new Format(lineIndenter.toCharArray(), newLine.toCharArray(), Format.SPACE_AFTER_LABEL | Format.COMPACT_EMPTY_ELEMENT));
  }
  
  /**
   * @deprecated
   */
  public JsonWriter(Writer writer, String lineIndenter)
  {
    this(writer, 0, new Format(lineIndenter.toCharArray(), new char[] { '\n' }, Format.SPACE_AFTER_LABEL | Format.COMPACT_EMPTY_ELEMENT));
  }
  
  public JsonWriter(Writer writer)
  {
    this(writer, 0, new Format(new char[] { ' ', ' ' }, new char[] { '\n' }, Format.SPACE_AFTER_LABEL | Format.COMPACT_EMPTY_ELEMENT));
  }
  
  /**
   * @deprecated
   */
  public JsonWriter(Writer writer, char[] lineIndenter, String newLine, int mode)
  {
    this(writer, mode, new Format(lineIndenter, newLine.toCharArray(), Format.SPACE_AFTER_LABEL | Format.COMPACT_EMPTY_ELEMENT));
  }
  
  public JsonWriter(Writer writer, int mode)
  {
    this(writer, mode, new Format());
  }
  
  public JsonWriter(Writer writer, Format format)
  {
    this(writer, 0, format);
  }
  
  public JsonWriter(Writer writer, int mode, Format format)
  {
    this(writer, mode, format, 1024);
  }
  
  public JsonWriter(Writer writer, int mode, Format format, int bufferSize)
  {
    super(mode, format.getNameCoder());
    this.writer = new QuickWriter(writer, bufferSize);
    this.format = format;
    depth = ((mode & 0x1) == 0 ? -1 : 0);
  }
  
  public void flush()
  {
    writer.flush();
  }
  
  public void close()
  {
    writer.close();
  }
  
  public HierarchicalStreamWriter underlyingWriter()
  {
    return this;
  }
  
  protected void startObject()
  {
    if (newLineProposed) {
      writeNewLine();
    }
    writer.write('{');
    startNewLine();
  }
  
  protected void addLabel(String name)
  {
    if (newLineProposed) {
      writeNewLine();
    }
    writer.write('"');
    writeText(name);
    writer.write("\":");
    if ((format.mode() & Format.SPACE_AFTER_LABEL) != 0) {
      writer.write(' ');
    }
  }
  
  protected void addValue(String value, AbstractJsonWriter.Type type)
  {
    if (newLineProposed) {
      writeNewLine();
    }
    if (type == AbstractJsonWriter.Type.STRING) {
      writer.write('"');
    }
    writeText(value);
    if (type == AbstractJsonWriter.Type.STRING) {
      writer.write('"');
    }
  }
  
  protected void startArray()
  {
    if (newLineProposed) {
      writeNewLine();
    }
    writer.write("[");
    startNewLine();
  }
  
  protected void nextElement()
  {
    writer.write(",");
    writeNewLine();
  }
  
  protected void endArray()
  {
    endNewLine();
    writer.write("]");
  }
  
  protected void endObject()
  {
    endNewLine();
    writer.write("}");
  }
  
  private void startNewLine()
  {
    if (++depth > 0) {
      newLineProposed = true;
    }
  }
  
  private void endNewLine()
  {
    if (depth-- > 0) {
      if (((format.mode() & Format.COMPACT_EMPTY_ELEMENT) != 0) && (newLineProposed)) {
        newLineProposed = false;
      } else {
        writeNewLine();
      }
    }
  }
  
  private void writeNewLine()
  {
    int depth = this.depth;
    writer.write(format.getNewLine());
    while (depth-- > 0) {
      writer.write(format.getLineIndenter());
    }
    newLineProposed = false;
  }
  
  private void writeText(String text)
  {
    int length = text.length();
    for (int i = 0; i < length; i++)
    {
      char c = text.charAt(i);
      switch (c)
      {
      case '"': 
        writer.write("\\\"");
        break;
      case '\\': 
        writer.write("\\\\");
        break;
      case '\b': 
        writer.write("\\b");
        break;
      case '\f': 
        writer.write("\\f");
        break;
      case '\n': 
        write
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23

Further reading...

For more information on Java 1.5 Tiger, you may find Java 1.5 Tiger, A developer's Notebook by D. Flanagan and B. McLaughlin from O'Reilly of interest.

New!JAR listings


Copyright 2006-2019. Infinite Loop Ltd