svn commit: r732682 [2/2] - in /commons/sandbox/compress/trunk/src: main/java/org/apache/commons/compress/archivers/tar/ test/java/org/apache/commons/compress/archivers/
Modified: commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarOutputStream.java URL: http://svn.apache.org/viewvc/commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarOutputStream.java?rev=732682&r1=732681&r2=732682&view=diff == --- commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarOutputStream.java (original) +++ commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarOutputStream.java Thu Jan 8 03:09:25 2009 @@ -24,323 +24,259 @@ import java.io.OutputStream; /** - * The TarOutputStream writes a UNIX tar archive as an OutputStream. Methods are - * provided to put entries, and then write their contents by writing to this - * stream using write(). + * The TarOutputStream writes a UNIX tar archive as an OutputStream. + * Methods are provided to put entries, and then write their contents + * by writing to this stream using write(). + * */ -public class TarOutputStream -extends FilterOutputStream -{ -/** - * Flag to indicate that an error should be generated if - * an attempt is made to write an entry that exceeds the 100 char - * POSIX limit. - */ +public class TarOutputStream extends FilterOutputStream { +/** Fail if a long file name is required in the archive. */ public static final int LONGFILE_ERROR = 0; -/** - * Flag to indicate that entry name should be truncated if - * an attempt is made to write an entry that exceeds the 100 char - * POSIX limit. - */ +/** Long paths will be truncated in the archive. */ public static final int LONGFILE_TRUNCATE = 1; -/** - * Flag to indicate that entry name should be formatted - * according to GNU tar extension if an attempt is made - * to write an entry that exceeds the 100 char POSIX - * limit. Note that this makes the jar unreadable by - * non-GNU tar commands. - */ +/** GNU tar extensions are used to store long file names in the archive. */ public static final int LONGFILE_GNU = 2; -private int m_longFileMode = LONGFILE_ERROR; -private byte[] m_assemBuf; -private int m_assemLen; -private TarBuffer m_buffer; -private int m_currBytes; -private int m_currSize; +// CheckStyle:VisibilityModifier OFF - bc +protected boolean debug; +protected long currSize; +protected StringcurrName; +protected long currBytes; +protected byte[]oneBuf; +protected byte[]recordBuf; +protected int assemLen; +protected byte[]assemBuf; +protected TarBuffer buffer; +protected int longFileMode = LONGFILE_ERROR; +// CheckStyle:VisibilityModifier ON -private byte[] m_oneBuf; -private byte[] m_recordBuf; +private boolean closed = false; /** - * Construct a TarOutputStream using specified input - * stream and default block and record sizes. - * - * @param output stream to create TarOutputStream from - * @see TarBuffer#DEFAULT_BLOCKSIZE - * @see TarBuffer#DEFAULT_RECORDSIZE + * Constructor for TarInputStream. + * @param os the output stream to use */ -public TarOutputStream( final OutputStream output ) -{ -this( output, TarBuffer.DEFAULT_BLOCKSIZE, TarBuffer.DEFAULT_RECORDSIZE ); +public TarOutputStream(OutputStream os) { +this(os, TarBuffer.DEFAULT_BLKSIZE, TarBuffer.DEFAULT_RCDSIZE); } /** - * Construct a TarOutputStream using specified input - * stream, block size and default record sizes. - * - * @param output stream to create TarOutputStream from - * @param blockSize the block size - * @see TarBuffer#DEFAULT_RECORDSIZE + * Constructor for TarInputStream. + * @param os the output stream to use + * @param blockSize the block size to use */ -public TarOutputStream( final OutputStream output, -final int blockSize ) -{ -this( output, blockSize, TarBuffer.DEFAULT_RECORDSIZE ); +public TarOutputStream(OutputStream os, int blockSize) { +this(os, blockSize, TarBuffer.DEFAULT_RCDSIZE); } /** - * Construct a TarOutputStream using specified input - * stream, block size and record sizes. - * - * @param output stream to create TarOutputStream from - * @param blockSize the block size - * @param recordSize the record size - */ -public TarOutputStream( final OutputStream output, -final int blockSize, -final int recordSize ) -{ -super( output ); - -m_buffer = new TarBuffer( output, blockSize, recordSize ); -m_assemLen = 0; -m_assemBuf = new byte[ recordSize ]; -m_recordBuf = new byte[ recordSize ]; -m_oneBuf = new byte[ 1
svn commit: r732856 - in /commons/proper/scxml/branches/J6/src/main/java/org/apache/commons/scxml: io/ModelUpdater.java io/SCXMLSerializer.java model/State.java model/Transition.java semantics/SCXMLSe
Author: sebb Date: Thu Jan 8 14:37:27 2009 New Revision: 732856 URL: http://svn.apache.org/viewvc?rev=732856&view=rev Log: Remove remaining deprecated code Modified: commons/proper/scxml/branches/J6/src/main/java/org/apache/commons/scxml/io/ModelUpdater.java commons/proper/scxml/branches/J6/src/main/java/org/apache/commons/scxml/io/SCXMLSerializer.java commons/proper/scxml/branches/J6/src/main/java/org/apache/commons/scxml/model/State.java commons/proper/scxml/branches/J6/src/main/java/org/apache/commons/scxml/model/Transition.java commons/proper/scxml/branches/J6/src/main/java/org/apache/commons/scxml/semantics/SCXMLSemanticsImpl.java Modified: commons/proper/scxml/branches/J6/src/main/java/org/apache/commons/scxml/io/ModelUpdater.java URL: http://svn.apache.org/viewvc/commons/proper/scxml/branches/J6/src/main/java/org/apache/commons/scxml/io/ModelUpdater.java?rev=732856&r1=732855&r2=732856&view=diff == --- commons/proper/scxml/branches/J6/src/main/java/org/apache/commons/scxml/io/ModelUpdater.java (original) +++ commons/proper/scxml/branches/J6/src/main/java/org/apache/commons/scxml/io/ModelUpdater.java Thu Jan 8 14:37:27 2009 @@ -160,17 +160,8 @@ for (Transition trn : s.getTransitionsList()) { updateTransition(trn, targets); } -Parallel p = s.getParallel(); //TODO: Remove in v1.0 Invoke inv = s.getInvoke(); -if ((inv != null && p != null) -|| (inv != null && !c.isEmpty()) -|| (p != null && !c.isEmpty())) { -logAndThrowModelError(ERR_STATE_BAD_CONTENTS, -new Object[] {getStateName(s)}); -} -if (p != null) { -updateParallel(p, targets); -} else if (inv != null) { +if (inv != null) { String ttype = inv.getTargettype(); if (ttype == null || ttype.trim().length() == 0) { logAndThrowModelError(ERR_INVOKE_NO_TARGETTYPE, @@ -351,15 +342,6 @@ + "null or not a descendant of {0}"; /** - * Error message when a state element contains anything other than - * one, one or any number of - * children. - */ -private static final String ERR_STATE_BAD_CONTENTS = "{0} should " -+ "contain either one , one or any number of " -+ " children."; - -/** * Error message when a referenced history state cannot be found. */ private static final String ERR_STATE_NO_HIST = "Referenced history state" Modified: commons/proper/scxml/branches/J6/src/main/java/org/apache/commons/scxml/io/SCXMLSerializer.java URL: http://svn.apache.org/viewvc/commons/proper/scxml/branches/J6/src/main/java/org/apache/commons/scxml/io/SCXMLSerializer.java?rev=732856&r1=732855&r2=732856&view=diff == --- commons/proper/scxml/branches/J6/src/main/java/org/apache/commons/scxml/io/SCXMLSerializer.java (original) +++ commons/proper/scxml/branches/J6/src/main/java/org/apache/commons/scxml/io/SCXMLSerializer.java Thu Jan 8 14:37:27 2009 @@ -165,11 +165,8 @@ for (Transition t : s.getTransitionsList()) { serializeTransition(b, t, indent + INDENT); } -Parallel p = s.getParallel(); Invoke inv = s.getInvoke(); -if (p != null) { -serializeParallel(b, p, indent + INDENT); -} else if (inv != null) { +if (inv != null) { serializeInvoke(b , inv, indent + INDENT); } else { Map c = s.getChildren(); @@ -302,41 +299,12 @@ b.append(" cond=\"").append(SCXMLHelper.escapeXML(t.getCond())). append("\""); } -boolean next = !SCXMLHelper.isStringEmpty(t.getNext()); -if (next) { -b.append(" target=\"" + t.getNext() + "\""); -} b.append(">\n"); -boolean exit = serializeActions(b, t.getActions(), indent + INDENT); -if (!next && !exit) { -serializeTarget(b, t, indent + INDENT); -} +serializeActions(b, t.getActions(), indent + INDENT); b.append(indent).append("\n"); } /** - * Serialize this Transition's Target. - * - * - * @param b The buffer to append the serialization to - * @param t The Transition whose Target needs to be serialized - * @param indent The indent for this XML element - * - * @deprecated Inline element has been deprecated - * in the SCXML WD - */ -@Deprecated -public static void serializeTarget(final StringBuffer b, -final Transition t, final String indent) { -if (t.getTarget() != null) { -b.append(indent).append(""); -// The inline transition target can only be a state -serializeState(b, (State) t.get
svn commit: r732892 - in /commons/proper/scxml/branches/J6/src: main/java/org/apache/commons/scxml/io/ModelUpdater.java main/java/org/apache/commons/scxml/io/SCXMLSerializer.java test/java/org/apache/
Author: rahul Date: Thu Jan 8 16:56:16 2009 New Revision: 732892 URL: http://svn.apache.org/viewvc?rev=732892&view=rev Log: Restore some of the bits removed in r732856. Added a simple test for serialization. Modified: commons/proper/scxml/branches/J6/src/main/java/org/apache/commons/scxml/io/ModelUpdater.java commons/proper/scxml/branches/J6/src/main/java/org/apache/commons/scxml/io/SCXMLSerializer.java commons/proper/scxml/branches/J6/src/test/java/org/apache/commons/scxml/io/SCXMLSerializerTest.java Modified: commons/proper/scxml/branches/J6/src/main/java/org/apache/commons/scxml/io/ModelUpdater.java URL: http://svn.apache.org/viewvc/commons/proper/scxml/branches/J6/src/main/java/org/apache/commons/scxml/io/ModelUpdater.java?rev=732892&r1=732891&r2=732892&view=diff == --- commons/proper/scxml/branches/J6/src/main/java/org/apache/commons/scxml/io/ModelUpdater.java (original) +++ commons/proper/scxml/branches/J6/src/main/java/org/apache/commons/scxml/io/ModelUpdater.java Thu Jan 8 16:56:16 2009 @@ -161,6 +161,9 @@ updateTransition(trn, targets); } Invoke inv = s.getInvoke(); +if (inv != null && !c.isEmpty()) { +logAndThrowModelError(ERR_STATE_BAD_CONTENTS, new Object[] {getStateName(s)}); +} if (inv != null) { String ttype = inv.getTargettype(); if (ttype == null || ttype.trim().length() == 0) { @@ -342,6 +345,13 @@ + "null or not a descendant of {0}"; /** + * Error message when a state element contains anything other than + * anor any number of children. + */ +private static final String ERR_STATE_BAD_CONTENTS = "{0} should " ++ "contain either one or any number of children."; + +/** * Error message when a referenced history state cannot be found. */ private static final String ERR_STATE_NO_HIST = "Referenced history state" Modified: commons/proper/scxml/branches/J6/src/main/java/org/apache/commons/scxml/io/SCXMLSerializer.java URL: http://svn.apache.org/viewvc/commons/proper/scxml/branches/J6/src/main/java/org/apache/commons/scxml/io/SCXMLSerializer.java?rev=732892&r1=732891&r2=732892&view=diff == --- commons/proper/scxml/branches/J6/src/main/java/org/apache/commons/scxml/io/SCXMLSerializer.java (original) +++ commons/proper/scxml/branches/J6/src/main/java/org/apache/commons/scxml/io/SCXMLSerializer.java Thu Jan 8 16:56:16 2009 @@ -299,6 +299,10 @@ b.append(" cond=\"").append(SCXMLHelper.escapeXML(t.getCond())). append("\""); } +if (!SCXMLHelper.isStringEmpty(t.getNext())) { +b.append(" target=\"").append(SCXMLHelper.escapeXML(t.getNext())). +append("\""); +} b.append(">\n"); serializeActions(b, t.getActions(), indent + INDENT); b.append(indent).append("\n"); Modified: commons/proper/scxml/branches/J6/src/test/java/org/apache/commons/scxml/io/SCXMLSerializerTest.java URL: http://svn.apache.org/viewvc/commons/proper/scxml/branches/J6/src/test/java/org/apache/commons/scxml/io/SCXMLSerializerTest.java?rev=732892&r1=732891&r2=732892&view=diff == --- commons/proper/scxml/branches/J6/src/test/java/org/apache/commons/scxml/io/SCXMLSerializerTest.java (original) +++ commons/proper/scxml/branches/J6/src/test/java/org/apache/commons/scxml/io/SCXMLSerializerTest.java Thu Jan 8 16:56:16 2009 @@ -313,6 +313,21 @@ assertEquals(actualValue, returnValue.toString()); } +public void testSerializeTransition() { +Transition t = new Transition(); + +t.setEvent("foo.bar"); +t.setCond("i == 3"); +t.setNext("next"); + +String actualValue = "\n\n"; + +StringBuffer returnValue = new StringBuffer(); +SCXMLSerializer.serializeTransition(returnValue, t, ""); + +assertEquals(actualValue, returnValue.toString()); +} + public void testSerializeTransitionEscapeXML() { Transition t = new Transition();