Projects >> shrinkwrap >>1aebbaf90618b0fde4b9835954734102dab3cba3

Chunk
Conflicting content
import java.io.IOException;
import java.io.InputStream;
<<<<<<< HEAD:extension-tar/impl/src/main/java/org/jboss/shrinkwrap/tar/impl/importer/TarImporterBase.java
import java.util.logging.Logger;

import org.jboss.shrinkwrap.api.Archive;
import org.jboss.shrinkwrap.api.asset.ByteArrayAsset;
import org.jboss.shrinkwrap.api.importer.ArchiveImportException;
import org.jboss.shrinkwrap.api.importer.StreamImporter;
import org.jboss.shrinkwrap.impl.base.AssignableBase;
import org.jboss.shrinkwrap.impl.base.Validate;
import org.jboss.shrinkwrap.tar.impl.io.TarEntry;
import org.jboss.shrinkwrap.tar.impl.io.TarInputStream;
=======

import org.jboss.shrinkwrap.api.Archive;
import org.jboss.shrinkwrap.tar.api.importer.TarGzImporter;
import org.jboss.tarbarian.api.TarGzInputStream;
>>>>>>> 531727916e57b466581d2327684bc5556a9246da:extension-tar/src/main/java/org/jboss/shrinkwrap/tar/impl/importer/TarGzImporterImpl.java

/**
 * Base of implementations used to import existing 
Solution content
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.logging.Logger;

import org.jboss.shrinkwrap.api.Archive;
import org.jboss.shrinkwrap.api.asset.ByteArrayAsset;
import org.jboss.shrinkwrap.api.importer.ArchiveImportException;
import org.jboss.shrinkwrap.api.importer.StreamImporter;
import org.jboss.shrinkwrap.impl.base.AssignableBase;
import org.jboss.shrinkwrap.impl.base.Validate;
import org.jboss.shrinkwrap.tar.impl.io.TarEntry;
import org.jboss.shrinkwrap.tar.impl.io.TarInputStream;

/**
 * Base of implementations used to import existing 
File
TarImporterBase.java
Developer's decision
Manual
Kind of conflict
Import
Chunk
Conflicting content
    */
 *
 * @author ALR
 */
<<<<<<< HEAD:extension-tar/impl/src/main/java/org/jboss/shrinkwrap/tar/impl/importer/TarImporterBase.java
abstract class TarImporterBase> extends AssignableBase>
      implements
         StreamImporter
{
   //-------------------------------------------------------------------------------------||
   // Class Members ----------------------------------------------------------------------||
   //-------------------------------------------------------------------------------------||

   /**
    * Logger
   @SuppressWarnings("unused")
   private static final Logger log = Logger.getLogger(TarImporterBase.class.getName());

   //-------------------------------------------------------------------------------------||
   // Constructor ------------------------------------------------------------------------||
   //-------------------------------------------------------------------------------------||

   public TarImporterBase(final Archive archive)
   {
      super(archive);
   }

   //-------------------------------------------------------------------------------------||
   // Contracts --------------------------------------------------------------------------||
   //-------------------------------------------------------------------------------------||

   /**
    * Returns the actual class for this implementation
    */
   abstract Class getActualClass();

   /**
    * Obtains the correct {@link InputStream} wrapper type for the specified raw
    * data input
    * @param in
    * @return
    * @throws IOException
    */
   abstract S getInputStreamForRawStream(InputStream in) throws IOException;
=======
public class TarGzImporterImpl extends TarImporterBase implements TarGzImporter
{
>>>>>>> 531727916e57b466581d2327684bc5556a9246da:extension-tar/src/main/java/org/jboss/shrinkwrap/tar/impl/importer/TarGzImporterImpl.java

   //-------------------------------------------------------------------------------------||
   // Functional Methods -----------------------------------------------------------------||
Solution content
 *
 * @author ALR
 */
abstract class TarImporterBase>
      extends
         AssignableBase> implements StreamImporter
{
   //-------------------------------------------------------------------------------------||
   // Class Members ----------------------------------------------------------------------||
   //-------------------------------------------------------------------------------------||

   /**
    * Logger
    */
   @SuppressWarnings("unused")
   private static final Logger log = Logger.getLogger(TarImporterBase.class.getName());

   //-------------------------------------------------------------------------------------||
   // Constructor ------------------------------------------------------------------------||
   //-------------------------------------------------------------------------------------||

   public TarImporterBase(final Archive archive)
   {
      super(archive);
   }

   //-------------------------------------------------------------------------------------||
   // Contracts --------------------------------------------------------------------------||
   //-------------------------------------------------------------------------------------||

   /**
    * Returns the actual class for this implementation
    */
   abstract Class getActualClass();

   /**
    * Obtains the correct {@link InputStream} wrapper type for the specified raw
    * data input
    * @param in
    * @return
    * @throws IOException
    */
   abstract S getInputStreamForRawStream(InputStream in) throws IOException;

   //-------------------------------------------------------------------------------------||
   // Functional Methods -----------------------------------------------------------------||
File
TarImporterBase.java
Developer's decision
Version 1
Kind of conflict
Annotation
Attribute
Class signature
Comment
Method declaration
Method interface
Method invocation
Chunk
Conflicting content
   // Functional Methods -----------------------------------------------------------------||
   //-------------------------------------------------------------------------------------||

<<<<<<< HEAD:extension-tar/impl/src/main/java/org/jboss/shrinkwrap/tar/impl/importer/TarImporterBase.java
   /**
    * Provides covarient return
    */
   private I covarientReturn()
   {
      return this.getActualClass().cast(this);
=======
   public TarGzImporterImpl(final Archive archive)
   {
      super(archive);
>>>>>>> 531727916e57b466581d2327684bc5556a9246da:extension-tar/src/main/java/org/jboss/shrinkwrap/tar/impl/importer/TarGzImporterImpl.java
   }

   //-------------------------------------------------------------------------------------||
Solution content
   // Functional Methods -----------------------------------------------------------------||
   //-------------------------------------------------------------------------------------||

   /**
    * Provides covarient return
    */
   private I covarientReturn()
   {
      return this.getActualClass().cast(this);
   }

   //-------------------------------------------------------------------------------------||
File
TarImporterBase.java
Developer's decision
Version 1
Kind of conflict
Comment
Method invocation
Method signature
Return statement
Chunk
Conflicting content
   /**
    * {@inheritDoc}
<<<<<<< HEAD:extension-tar/impl/src/main/java/org/jboss/shrinkwrap/tar/impl/importer/TarImporterBase.java
    * @see org.jboss.shrinkwrap.api.importer.StreamImporter#importFrom(java.io.InputStream)
    */
   @Override
   public I importFrom(final InputStream stream) throws ArchiveImportException
   {
      Validate.notNull(stream, "Stream must be specified");
      final S tarStream;
      try
      {
         tarStream = this.getInputStreamForRawStream(stream);
      }
      catch (final RuntimeException re)
      {
         throw new ArchiveImportException("Could not wrap raw input with TAR stream", re);
      }
      catch (final IOException e)
      {
         throw new ArchiveImportException("Could not wrap raw input with TAR stream", e);
      }
      return this.importFrom(tarStream);
=======
    * @see org.jboss.shrinkwrap.tar.impl.importer.TarImporterBase#getInputStreamForRawStream(java.io.InputStream)
    */
   @Override
   TarGzInputStream getInputStreamForRawStream(final InputStream in) throws IOException
   {
      assert in != null : "Specified inputstream was null";
      return new TarGzInputStream(in);
>>>>>>> 531727916e57b466581d2327684bc5556a9246da:extension-tar/src/main/java/org/jboss/shrinkwrap/tar/impl/importer/TarGzImporterImpl.java
   }

   /**
Solution content
   /**
    * {@inheritDoc}
    * @see org.jboss.shrinkwrap.api.importer.StreamImporter#importFrom(java.io.InputStream)
    */
   @Override
   public I importFrom(final InputStream stream) throws ArchiveImportException
   {
      Validate.notNull(stream, "Stream must be specified");
      final S tarStream;
      try
      {
         tarStream = this.getInputStreamForRawStream(stream);
      }
      catch (final RuntimeException re)
      {
         throw new ArchiveImportException("Could not wrap raw input with TAR stream", re);
      }
      catch (final IOException e)
      {
         throw new ArchiveImportException("Could not wrap raw input with TAR stream", e);
      }
      return this.importFrom(tarStream);
   }

   /**
File
TarImporterBase.java
Developer's decision
Version 1
Kind of conflict
Annotation
Assert statement
Comment
Method invocation
Method signature
Return statement
Try statement
Variable
Chunk
Conflicting content
   {
    * {@inheritDoc}
    * @see org.jboss.shrinkwrap.tar.impl.importer.TarImporterBase#getActualClass()
    */
<<<<<<< HEAD:extension-tar/impl/src/main/java/org/jboss/shrinkwrap/tar/impl/importer/TarImporterBase.java
   private I importFrom(final S stream) throws ArchiveImportException
      Validate.notNull(stream, "Stream must be specified");
      try
      {
         TarEntry entry;
         while ((entry = stream.getNextEntry()) != null)
         {
            // Get the name
            String entryName = entry.getName();
            
            final Archive archive = this.getArchive();

            // Handle directories separately
            if (entry.isDirectory())
            {
               archive.addDirectory(entryName);
               continue;
            }

            ByteArrayOutputStream output = new ByteArrayOutputStream(8192);
            byte[] content = new byte[4096];
            int readBytes;
            while ((readBytes = stream.read(content, 0, content.length)) != -1)
            {
               output.write(content, 0, readBytes);
            }
            archive.add(new ByteArrayAsset(output.toByteArray()), entryName);
         }
      }
      catch (final RuntimeException re)
      {
         throw new ArchiveImportException("Could not import stream", re);
      }
      catch (IOException e)
      {
         throw new ArchiveImportException("Could not import stream", e);
      }
      return this.covarientReturn();
   }

   /**
    * {@inheritDoc}
    * @see org.jboss.shrinkwrap.api.importer.StreamImporter#importFrom(java.lang.Object)
    */
   @Override
   public I importFrom(final File file) throws ArchiveImportException
   {
      Validate.notNull(file, "File must be specified");
      if (!file.exists())
      {
         throw new IllegalArgumentException("Specified file for import does not exist: " + file);
      }
      if (file.isDirectory())
      {
         throw new IllegalArgumentException("Specified file for import is a directory: " + file);
      }

      final S archive;
      try
      {
         archive = this.getInputStreamForFile(file);
      }
      catch (final IOException e)
      {
         throw new ArchiveImportException("Could not read archive file " + file, e);
      }

      return this.importFrom(archive);

   }

   //-------------------------------------------------------------------------------------||
   // Internal Helper Methods ------------------------------------------------------------||
   //-------------------------------------------------------------------------------------||

   /**
    * Obtains an implementation-specific stream to the specified {@link File}
    * @param file To open a stream to, must be specified
    * @return
    * @throws IOException If there was a problem getting an instream to the file
    */
   private S getInputStreamForFile(File file) throws IOException
   {
      assert file != null : "File must be specified";
      return this.getInputStreamForRawStream(new FileInputStream(file));
   }

=======
   @Override
   Class getActualClass()
   {
      return TarGzImporter.class;
   }

>>>>>>> 531727916e57b466581d2327684bc5556a9246da:extension-tar/src/main/java/org/jboss/shrinkwrap/tar/impl/importer/TarGzImporterImpl.java
}
Solution content
      {
    * {@inheritDoc}
    * @see org.jboss.shrinkwrap.api.importer.StreamImporter#importFrom(java.io.InputStream)
    */
   private I importFrom(final S stream) throws ArchiveImportException
   {
      Validate.notNull(stream, "Stream must be specified");
      try
      {
         TarEntry entry;
         while ((entry = stream.getNextEntry()) != null)
         {
            // Get the name
            String entryName = entry.getName();

            final Archive archive = this.getArchive();

            // Handle directories separately
            if (entry.isDirectory())
            {
               archive.addDirectory(entryName);
               continue;
            }

            ByteArrayOutputStream output = new ByteArrayOutputStream(8192);
            byte[] content = new byte[4096];
            int readBytes;
            while ((readBytes = stream.read(content, 0, content.length)) != -1)
            {
               output.write(content, 0, readBytes);
            }
            archive.add(new ByteArrayAsset(output.toByteArray()), entryName);
         }
      }
      catch (final RuntimeException re)
      {
         throw new ArchiveImportException("Could not import stream", re);
      }
      catch (IOException e)
      {
         throw new ArchiveImportException("Could not import stream", e);
      }
      return this.covarientReturn();
   }

   /**
    * {@inheritDoc}
    * @see org.jboss.shrinkwrap.api.importer.StreamImporter#importFrom(java.lang.Object)
    */
   @Override
   public I importFrom(final File file) throws ArchiveImportException
   {
      Validate.notNull(file, "File must be specified");
      if (!file.exists())
      {
         throw new IllegalArgumentException("Specified file for import does not exist: " + file);
      }
      if (file.isDirectory())
      {
         throw new IllegalArgumentException("Specified file for import is a directory: " + file);
      }

      final S archive;
      try
      {
         archive = this.getInputStreamForFile(file);
      }
      catch (final IOException e)
         throw new ArchiveImportException("Could not read archive file " + file, e);
      }

      return this.importFrom(archive);

   }

   //-------------------------------------------------------------------------------------||
   // Internal Helper Methods ------------------------------------------------------------||
   //-------------------------------------------------------------------------------------||

   /**
    * Obtains an implementation-specific stream to the specified {@link File}
    * @param file To open a stream to, must be specified
    * @return
    * @throws IOException If there was a problem getting an instream to the file
    */
   private S getInputStreamForFile(File file) throws IOException
   {
      assert file != null : "File must be specified";
      return this.getInputStreamForRawStream(new FileInputStream(file));
   }

}
File
TarImporterBase.java
Developer's decision
Version 1
Kind of conflict
Annotation
Comment
Method declaration
Chunk
Conflicting content
   @Override
   @Override
   public String toString(final Formatter formatter) throws IllegalArgumentException
   {
<<<<<<< HEAD
      return this.getArchive().toString(formatter);
=======
      return archive.toString(formatter);
   }
   
   public int hashCode()
   {
      return archive.hashCode();
   }

   @Override
   public boolean equals(Object obj)
   {
      if (obj instanceof ArchiveBase) {
         return archive.equals(obj);
      }
      
      if (!(obj instanceof ContainerBase))
         return false;
      
      final ContainerBase other = (ContainerBase) obj;
      return archive.equals(other.getArchive());
   }   

   //-------------------------------------------------------------------------------------||
   // Required Implementations - SpecializedBase -----------------------------------------||
   //-------------------------------------------------------------------------------------||

   /* (non-Javadoc)
    * @see org.jboss.shrinkwrap.impl.base.SpecializedBase#getArchive()
    */
   @Override
   protected Archive getArchive()
   {
      return archive;
>>>>>>> 531727916e57b466581d2327684bc5556a9246da
   }
   
   //-------------------------------------------------------------------------------------||
Solution content
   @Override
   public String toString(final Formatter formatter) throws IllegalArgumentException
   {
      return this.getArchive().toString(formatter);
   }
   
   @Override
   public int hashCode()
   {
      return this.getArchive().hashCode();
   }

   @Override
   public boolean equals(Object obj)
   {
      if (obj instanceof ArchiveBase) {
         return this.getArchive().equals(obj);
      }
      
      if (!(obj instanceof ContainerBase))
         return false;
      
      final ContainerBase other = (ContainerBase) obj;
      return this.getArchive().equals(other.getArchive());
   }
   
   //-------------------------------------------------------------------------------------||
File
ContainerBase.java
Developer's decision
Manual
Kind of conflict
Annotation
Attribute
Comment
Method declaration
Method invocation
Method signature
Return statement
Chunk
Conflicting content
      while (in.read() != -1);

   }
<<<<<<< HEAD
=======

>>>>>>> 531727916e57b466581d2327684bc5556a9246da
}
Solution content
      while (in.read() != -1);

   }
}
File
ZipSerializableViewImpl.java
Developer's decision
Version 1
Kind of conflict
Blank