You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by se...@apache.org on 2012/03/21 20:04:50 UTC

svn commit: r1303506 - /commons/proper/csv/trunk/src/main/java/org/apache/commons/csv/Token.java

Author: sebb
Date: Wed Mar 21 19:04:50 2012
New Revision: 1303506

URL: http://svn.apache.org/viewvc?rev=1303506&view=rev
Log:
Move Token into separate file for more flexibility

Added:
    commons/proper/csv/trunk/src/main/java/org/apache/commons/csv/Token.java   (with props)

Added: commons/proper/csv/trunk/src/main/java/org/apache/commons/csv/Token.java
URL: http://svn.apache.org/viewvc/commons/proper/csv/trunk/src/main/java/org/apache/commons/csv/Token.java?rev=1303506&view=auto
==============================================================================
--- commons/proper/csv/trunk/src/main/java/org/apache/commons/csv/Token.java (added)
+++ commons/proper/csv/trunk/src/main/java/org/apache/commons/csv/Token.java Wed Mar 21 19:04:50 2012
@@ -0,0 +1,62 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.
+ * 
+ */
+
+package org.apache.commons.csv;
+
+import static org.apache.commons.csv.Token.Type.*;
+
+/**
+ * Token is an internal token representation.
+ * <p/>
+ * It is used as contract between the lexer and the parser.
+ */
+class Token {
+
+    /** length of the initial token (content-)buffer */
+    private static final int INITIAL_TOKEN_LENGTH = 50;
+    
+    enum Type {
+        /** Token has no valid content, i.e. is in its initialized state. */
+        INVALID,
+        
+        /** Token with content, at beginning or in the middle of a line. */
+        TOKEN,
+        
+        /** Token (which can have content) when end of file is reached. */
+        EOF,
+        
+        /** Token with content when end of a line is reached. */
+        EORECORD
+    }
+    
+    /** Token type */
+    Token.Type type = INVALID;
+    
+    /** The content buffer. */
+    StringBuilder content = new StringBuilder(INITIAL_TOKEN_LENGTH);
+    
+    /** Token ready flag: indicates a valid token with content (ready for the parser). */
+    boolean isReady;
+
+    Token reset() {
+        content.setLength(0);
+        type = INVALID;
+        isReady = false;
+        return this;
+    }
+}
\ No newline at end of file

Propchange: commons/proper/csv/trunk/src/main/java/org/apache/commons/csv/Token.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: commons/proper/csv/trunk/src/main/java/org/apache/commons/csv/Token.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision