Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Extract to standalone repo.

* Filter history to include only `QueueFile` and `QueueFileTest`.
* Move from `retrofit.io` to `com.squareup.tape` package.
* Add support files for compilation and the start of documentation.
  • Loading branch information...
commit 26f2adca34d7e1327136c8f7c03d87b2e9d9e9ba 1 parent 1fc0457
@JakeWharton JakeWharton authored
View
22 .gitignore
@@ -0,0 +1,22 @@
+.classpath
+.project
+.settings
+eclipsebin
+
+bin
+gen
+build
+out
+lib
+
+target
+pom.xml.*
+release.properties
+
+.idea
+*.iml
+classes
+
+obj
+
+.DS_Store
View
64 README.md
@@ -0,0 +1,64 @@
+Tape by Square, Inc.
+====================
+
+A lightning fast, transactional, file-based FIFO for Java.
+
+*For usage instructions please see [the website][1].*
+
+
+
+Download
+--------
+
+Downloadable .jars can be found on the [GitHub download page][2].
+
+You can also depend on the .jar through Maven:
+
+```xml
+<dependency>
+ <groupId>com.squareup</groupId>
+ <artifactId>tape</artifactId>
+ <version>(insert latest version)</version>
+</dependency>
+```
+
+
+Contributing
+------------
+
+If you would like to contribute code to Tape you can do so through GitHub by
+forking the repository and sending a pull request.
+
+When submitting code, please make every effort to follow existing conventions
+and style in order to keep the code as readable as possible. Please also make
+sure your code compiles by running `mvn clean verify`. Checkstyle failures
+during compilation indicate errors in your style and can be viewed in the
+`checkstyle-result.xml` file.
+
+Before your code can be accepted into the project you must also sign the
+[Individual Contributor License Agreement (CLA)][3].
+
+
+
+License
+-------
+
+ Copyright 2012 Square, Inc.
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+
+
+ [1]: http://square.github.com/tape/
+ [2]: http://github.com/square/tape/downloads
+ [3]: https://spreadsheets.google.com/spreadsheet/viewform?formkey=dDViT2xzUHAwRkI3X3k5Z0lQM091OGc6MQ&ndplr=1
View
120 checkstyle.xml
@@ -0,0 +1,120 @@
+<?xml version="1.0"?>
+<!DOCTYPE module PUBLIC
+ "-//Puppy Crawl//DTD Check Configuration 1.2//EN"
+ "http://www.puppycrawl.com/dtds/configuration_1_2.dtd">
+
+<module name="Checker">
+ <module name="NewlineAtEndOfFile"/>
+ <module name="FileLength"/>
+ <module name="FileTabCharacter"/>
+
+ <!-- Trailing spaces -->
+ <module name="RegexpSingleline">
+ <property name="format" value="\s+$"/>
+ <property name="message" value="Line has trailing spaces."/>
+ </module>
+
+ <module name="TreeWalker">
+ <property name="cacheFile" value="${checkstyle.cache.file}"/>
+
+ <!-- Checks for Javadoc comments. -->
+ <!-- See http://checkstyle.sf.net/config_javadoc.html -->
+ <!--module name="JavadocMethod"/-->
+ <module name="JavadocType"/>
+ <!--module name="JavadocVariable"/-->
+ <module name="JavadocStyle"/>
+
+
+ <!-- Checks for Naming Conventions. -->
+ <!-- See http://checkstyle.sf.net/config_naming.html -->
+ <module name="ConstantName"/>
+ <module name="LocalFinalVariableName"/>
+ <module name="LocalVariableName"/>
+ <module name="MemberName"/>
+ <module name="MethodName"/>
+ <module name="PackageName"/>
+ <module name="ParameterName"/>
+ <module name="StaticVariableName"/>
+ <module name="TypeName"/>
+
+
+ <!-- Checks for imports -->
+ <!-- See http://checkstyle.sf.net/config_import.html -->
+ <module name="AvoidStarImport"/>
+ <module name="IllegalImport"/> <!-- defaults to sun.* packages -->
+ <module name="RedundantImport"/>
+ <module name="UnusedImports"/>
+
+
+ <!-- Checks for Size Violations. -->
+ <!-- See http://checkstyle.sf.net/config_sizes.html -->
+ <module name="LineLength">
+ <property name="max" value="120"/>
+ </module>
+ <module name="MethodLength"/>
+ <module name="ParameterNumber"/>
+
+
+ <!-- Checks for whitespace -->
+ <!-- See http://checkstyle.sf.net/config_whitespace.html -->
+ <module name="GenericWhitespace"/>
+ <module name="EmptyForIteratorPad"/>
+ <module name="MethodParamPad"/>
+ <module name="NoWhitespaceAfter"/>
+ <module name="NoWhitespaceBefore"/>
+ <module name="OperatorWrap"/>
+ <module name="ParenPad"/>
+ <module name="TypecastParenPad"/>
+ <module name="WhitespaceAfter"/>
+ <module name="WhitespaceAround"/>
+
+
+ <!-- Modifier Checks -->
+ <!-- See http://checkstyle.sf.net/config_modifiers.html -->
+ <!--module name="ModifierOrder"/-->
+ <module name="RedundantModifier"/>
+
+
+ <!-- Checks for blocks. You know, those {}'s -->
+ <!-- See http://checkstyle.sf.net/config_blocks.html -->
+ <module name="AvoidNestedBlocks"/>
+ <module name="EmptyBlock"/>
+ <module name="LeftCurly"/>
+ <!--module name="NeedBraces"/-->
+ <module name="RightCurly"/>
+
+
+ <!-- Checks for common coding problems -->
+ <!-- See http://checkstyle.sf.net/config_coding.html -->
+ <!--module name="AvoidInlineConditionals"/-->
+ <module name="CovariantEquals"/>
+ <module name="DoubleCheckedLocking"/>
+ <module name="EmptyStatement"/>
+ <module name="EqualsAvoidNull"/>
+ <module name="EqualsHashCode"/>
+ <!--module name="HiddenField"/-->
+ <module name="IllegalInstantiation"/>
+ <module name="InnerAssignment"/>
+ <!--module name="MagicNumber"/-->
+ <module name="MissingSwitchDefault"/>
+ <module name="RedundantThrows"/>
+ <module name="SimplifyBooleanExpression"/>
+ <module name="SimplifyBooleanReturn"/>
+
+ <!-- Checks for class design -->
+ <!-- See http://checkstyle.sf.net/config_design.html -->
+ <!--module name="DesignForExtension"/-->
+ <module name="FinalClass"/>
+ <module name="HideUtilityClassConstructor"/>
+ <module name="InterfaceIsType"/>
+ <!--s/module name="VisibilityModifier"/-->
+
+
+ <!-- Miscellaneous other checks. -->
+ <!-- See http://checkstyle.sf.net/config_misc.html -->
+ <module name="ArrayTypeStyle"/>
+ <!--module name="FinalParameters"/-->
+ <!--module name="TodoComment"/-->
+ <module name="UpperEll"/>
+ </module>
+</module>
View
98 pom.xml
@@ -0,0 +1,98 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.sonatype.oss</groupId>
+ <artifactId>oss-parent</artifactId>
+ <version>7</version>
+ </parent>
+
+ <groupId>com.squareup</groupId>
+ <artifactId>tape</artifactId>
+ <packaging>jar</packaging>
+ <version>1.0.0-SNAPSHOT</version>
+
+ <name>FastPass</name>
+ <description>A lightning fast, transactional, file-based FIFO for Java.</description>
+
+ <scm>
+ <url>http://github.com/square/tape</url>
+ <connection>scm:git:git://github.com/square/tape.git</connection>
+ <developerConnection>scg:git:git@github.com:square/tape.git</developerConnection>
+ </scm>
+
+ <organization>
+ <name>Square, Inc.</name>
+ <url>http://squareup.com</url>
+ </organization>
+
+ <issueManagement>
+ <system>GitHub Issues</system>
+ <url>http://github.com/square/tape/issues</url>
+ </issueManagement>
+
+ <licenses>
+ <license>
+ <name>Apache License Version 2.0</name>
+ <url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
+ <distribution>repo</distribution>
+ </license>
+ </licenses>
+
+ <properties>
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+
+ <java.version>1.6</java.version>
+ <junit.version>4.10</junit.version>
+ <fest.version>1.4</fest.version>
+ </properties>
+
+ <dependencies>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>${junit.version}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.easytesting</groupId>
+ <artifactId>fest-assert</artifactId>
+ <version>${fest.version}</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>2.5</version>
+ <configuration>
+ <source>${java.version}</source>
+ <target>${java.version}</target>
+ </configuration>
+ </plugin>
+
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-checkstyle-plugin</artifactId>
+ <version>2.9.1</version>
+ <configuration>
+ <failsOnError>true</failsOnError>
+ <configLocation>checkstyle.xml</configLocation>
+ </configuration>
+ <executions>
+ <execution>
+ <phase>verify</phase>
+ <goals>
+ <goal>checkstyle</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+</project>
View
14 queue/src/main/java/retrofit/io/QueueFile.java → src/main/java/com/squareup/tape/QueueFile.java
@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package retrofit.io;
+package com.squareup.tape;
import java.io.File;
import java.io.FileNotFoundException;
@@ -40,7 +40,7 @@
* the system crashes after {@code peek} and during processing, the element will
* remain in the queue, to be processed when the system restarts.
* <p/>
- * <p><b><font color="red">NOTE:</font></b> The current implementation is built
+ * <p><strong>NOTE:</strong> The current implementation is built
* for file systems that support atomic segment writes (like YAFFS). Most
* conventional file systems don't support this; if the power goes out while
* writing a segment, the segment will contain garbage and the file will be
@@ -279,10 +279,10 @@ public void add(byte[] data) throws IOException {
* @param data to copy bytes from
* @param offset to start from in buffer
* @param count number of bytes to copy
- * @throws IndexOutOfBoundsException if {@code offset < 0} or {@code count <
- * 0}, or if {@code offset + count} is
- * bigger than the length of {@code
- * buffer}.
+ * @throws IndexOutOfBoundsException if {@code offset < 0} or
+ * {@code count < 0}, or if
+ * {@code offset + count} is bigger than
+ * the length of {@code buffer}.
*/
public synchronized void add(byte[] data, int offset, int count)
throws IOException {
@@ -438,7 +438,7 @@ public synchronized void forEach(ElementReader reader) throws IOException {
}
/** Reads a single element. */
- private class ElementInputStream extends InputStream {
+ private final class ElementInputStream extends InputStream {
private int position;
private int remaining;
View
8 queue/src/test/java/retrofit/io/QueueFileTest.java → src/test/java/com/squareup/tape/QueueFileTest.java
@@ -1,16 +1,12 @@
// Copyright 2010 Square, Inc.
-package retrofit.io;
+package com.squareup.tape;
import org.fest.assertions.Assertions;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
-import java.io.File;
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.RandomAccessFile;
+import java.io.*;
import java.util.LinkedList;
import java.util.Queue;
import java.util.logging.Logger;
Please sign in to comment.
Something went wrong with that request. Please try again.