+/*
+ * Copyright (C) 2007-2012 Mathieu Baudier
+ *
+ * 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.
+ */
package org.argeo.jcr.tabular;
import java.io.InputStream;
import org.apache.commons.io.IOUtils;
import org.argeo.ArgeoException;
import org.argeo.jcr.ArgeoTypes;
-import org.argeo.jcr.JcrUtils;
import org.argeo.util.CsvParser;
import org.argeo.util.tabular.ArrayTabularRow;
import org.argeo.util.tabular.TabularColumn;
public JcrTabularRowIterator(Node tableNode) {
try {
- Node contentNode = tableNode.getNode(Property.JCR_CONTENT);
for (NodeIterator it = tableNode.getNodes(); it.hasNext();) {
Node node = it.nextNode();
if (node.isNodeType(ArgeoTypes.ARGEO_COLUMN)) {
Integer type = PropertyType.valueFromName(node.getProperty(
Property.JCR_REQUIRED_TYPE).getString());
- TabularColumn tc = new TabularColumn(node.getName(), type);
+ TabularColumn tc = new TabularColumn(node.getProperty(
+ Property.JCR_TITLE).getString(), type);
header.add(tc);
- // } else if (node.getName().equals(Property.JCR_CONTENT)) {
- // contentNode = node;
}
}
- // should not happen since content is mandatory
- assert contentNode != null;
-
+ Node contentNode = tableNode.getNode(Property.JCR_CONTENT);
if (contentNode.isNodeType(ArgeoTypes.ARGEO_CSV)) {
textLines = new ArrayBlockingQueue<List<String>>(1000);
csvParser = new CsvParser() {
// TODO Auto-generated catch block
e.printStackTrace();
}
- //textLines.add(tokens);
+ // textLines.add(tokens);
if (hasNext == null) {
hasNext = true;
synchronized (JcrTabularRowIterator.this) {
return true;
// (parsingCompleted && textLines.isEmpty())
- return false;
-
-// if (!hasNext && textLines.isEmpty()) {
-// if (in != null) {
-// IOUtils.closeQuietly(in);
-// in = null;
-// }
-// if (binary != null) {
-// JcrUtils.closeQuietly(binary);
-// binary = null;
-// }
-// return false;
-// } else
-// return true;
+ return false;
+
+ // if (!hasNext && textLines.isEmpty()) {
+ // if (in != null) {
+ // IOUtils.closeQuietly(in);
+ // in = null;
+ // }
+ // if (binary != null) {
+ // JcrUtils.closeQuietly(binary);
+ // binary = null;
+ // }
+ // return false;
+ // } else
+ // return true;
}
public synchronized TabularRow next() {
return currentRowNumber;
}
+ public List<TabularColumn> getHeader() {
+ return header;
+ }
+
}