// Path: src/main/java/com/marcospassos/phpserializer/state/FinishedState.java
// public class FinishedState extends AbstractState
// {
//     @Override
//     public boolean isReferable()
//     {
//         return false;
//     }
// }
// 
// Path: src/main/java/com/marcospassos/phpserializer/state/WritingValueState.java
// public class WritingValueState extends AbstractState
// {
//     /**
//      * The parent state.
//      */
//     WriterState parent;
// 
//     /**
//      * Creates an initial state.
//      */
//     public WritingValueState()
//     {
//         this(new FinishedState());
//     }
// 
//     /**
//      * Creates a new state from the specified parent state.
//      *
//      * @param parent The parent state.
//      */
//     public WritingValueState(WriterState parent)
//     {
//         this.parent = parent;
//     }
// 
//     @Override
//     public boolean isReferable()
//     {
//         return true;
//     }
// 
//     @Override
//     public WriterState serializableBegin()
//     {
//         return new WritingSerializableObjectState(parent);
//     }
// 
//     @Override
//     public WriterState objectBegin()
//     {
//         return new WritingObjectState(parent);
//     }
// 
//     @Override
//     public WriterState value()
//     {
//         return parent;
//     }
// 
//     @Override
//     public WriterState arrayBegin()
//     {
//         return new WritingArrayState(parent);
//     }
// }


import java.lang.reflect.Modifier;
import java.nio.charset.Charset;
import com.marcospassos.phpserializer.state.FinishedState;
import com.marcospassos.phpserializer.state.WritingValueState;
    /**
     * Writes the start of an object to the buffer and returns an object-level
     * sub writer.
     *
     * @param className The fully-qualified name of the class.
     *
     * @return An object-level sub writer to write the object's data.
     */
    public Writer writeSerializableObjectStart(String className)
    {
        setState(state.serializableBegin());

        buffer.append("C:");
        buffer.append(className.length());
        buffer.append(":\"");
        buffer.append(className);
        buffer.append("\":");

        subWriter = new Writer();
        subWriter.pointer = pointer + 1;

        return subWriter;
    }

    /**
     * Writes the end of a serializable object to the buffer.
     */
    public void writeSerializableObjectEnd() {
        setState(state.serializableEnd());

// Path: src/main/java/com/marcospassos/phpserializer/state/FinishedState.java
// public class FinishedState extends AbstractState
// {
//     @Override
//     public boolean isReferable()
//     {
//         return false;
//     }
// }
// 
// Path: src/main/java/com/marcospassos/phpserializer/state/WritingValueState.java
// public class WritingValueState extends AbstractState
// {
//     /**
//      * The parent state.
//      */
//     WriterState parent;
// 
//     /**
//      * Creates an initial state.
//      */
//     public WritingValueState()
//     {
//         this(new FinishedState());
//     }
// 
//     /**
//      * Creates a new state from the specified parent state.
//      *
//      * @param parent The parent state.
//      */
//     public WritingValueState(WriterState parent)
//     {
//         this.parent = parent;
//     }
// 
//     @Override
//     public boolean isReferable()
//     {
//         return true;
//     }
// 
//     @Override
//     public WriterState serializableBegin()
//     {
//         return new WritingSerializableObjectState(parent);
//     }
// 
//     @Override
//     public WriterState objectBegin()
//     {
//         return new WritingObjectState(parent);
//     }
// 
//     @Override
//     public WriterState value()
//     {
//         return parent;
//     }
// 
//     @Override
//     public WriterState arrayBegin()
//     {
//         return new WritingArrayState(parent);
//     }
// }


// Path: src/main/java/com/marcospassos/phpserializer/Writer.java
import java.lang.reflect.Modifier;
import java.nio.charset.Charset;
import com.marcospassos.phpserializer.state.FinishedState;
import com.marcospassos.phpserializer.state.WritingValueState;

    /**
     * Writes the start of an object to the buffer and returns an object-level
     * sub writer.
     *
     * @param className The fully-qualified name of the class.
     *
     * @return An object-level sub writer to write the object's data.
     */
    public Writer writeSerializableObjectStart(String className)
    {
        setState(state.serializableBegin());

        buffer.append("C:");
        buffer.append(className.length());
        buffer.append(":\"");
        buffer.append(className);
        buffer.append("\":");

        subWriter = new Writer();
        subWriter.pointer = pointer + 1;

        return subWriter;
    }

    /**
     * Writes the end of a serializable object to the buffer.
     */
    public void writeSerializableObjectEnd() {
        setState(state.serializableEnd());

        if (!(subWriter.state instanceof FinishedState)) {