changeset 234:b25feac318d8

add lucene jar and minor changes git-svn-id: https://luan-java.googlecode.com/svn/trunk@235 21e917c8-12df-6dd8-5cb6-c86387c605b9
author fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
date Thu, 02 Oct 2014 20:08:39 +0000
parents ef39bc4d3f70
children f247c2ea9eef
files build.sh core/src/luan/AbstractLuanTable.java dist/luan-core-trunk.jar dist/luan-logging-trunk.jar dist/luan-lucene-trunk.jar dist/luan-mail-trunk.jar dist/luan-web-trunk.jar lucene/src/luan/modules/lucene/FieldTable.java lucene/src/luan/modules/lucene/LuceneSearcher.java
diffstat 9 files changed, 29 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/build.sh	Thu Oct 02 02:58:55 2014 +0000
+++ b/build.sh	Thu Oct 02 20:08:39 2014 +0000
@@ -39,3 +39,11 @@
 javac -classpath $CLASSPATH `find $SRC -name *.java`
 cd $SRC
 jar cvf $HOME/dist/luan-mail-$VERSION.jar `find . -name *.class -o -name *.luan`
+
+cd $HOME
+SRC=lucene/src
+CLASSPATH=$HOME/core/src:$HOME/$SRC
+for i in $HOME/lucene/ext/* ; do CLASSPATH=$CLASSPATH:$i ; done
+javac -classpath $CLASSPATH `find $SRC -name *.java`
+cd $SRC
+jar cvf $HOME/dist/luan-lucene-$VERSION.jar `find . -name *.class -o -name *.luan`
--- a/core/src/luan/AbstractLuanTable.java	Thu Oct 02 02:58:55 2014 +0000
+++ b/core/src/luan/AbstractLuanTable.java	Thu Oct 02 20:08:39 2014 +0000
@@ -29,7 +29,11 @@
 	}
 
 	@Override public Map<Object,Object> asMap() {
-		return Collections.emptyMap();
+		Map<Object,Object> map = new HashMap<Object,Object>();
+		for( Map.Entry<Object,Object> entry : this ) {
+			map.put(entry.getKey(),entry.getValue());
+		}
+		return map;
 	}
 
 	protected abstract String type();
Binary file dist/luan-core-trunk.jar has changed
Binary file dist/luan-logging-trunk.jar has changed
Binary file dist/luan-lucene-trunk.jar has changed
Binary file dist/luan-mail-trunk.jar has changed
Binary file dist/luan-web-trunk.jar has changed
--- a/lucene/src/luan/modules/lucene/FieldTable.java	Thu Oct 02 02:58:55 2014 +0000
+++ b/lucene/src/luan/modules/lucene/FieldTable.java	Thu Oct 02 20:08:39 2014 +0000
@@ -27,8 +27,15 @@
 		if( !(value instanceof String) )
 			throw new UnsupportedOperationException("value must be string");
 		String field = (String)value;
-		map.put(name,field);
-		reverseMap.put(field,name);
+		String oldField = map.put(name,field);
+		if( oldField != null )
+			reverseMap.remove(oldField);
+		String oldName = reverseMap.put(field,name);
+		if( oldName != null ) {
+			reverseMap.put(field,oldName);
+			map.remove(name);
+			throw new IllegalArgumentException("field '"+oldName+"' is already assigned to '"+field+"'");
+		}
 	}
 
 	@Override public final Object get(Object key) {
--- a/lucene/src/luan/modules/lucene/LuceneSearcher.java	Thu Oct 02 02:58:55 2014 +0000
+++ b/lucene/src/luan/modules/lucene/LuceneSearcher.java	Thu Oct 02 20:08:39 2014 +0000
@@ -128,9 +128,14 @@
 		if( !(obj2 instanceof String) )
 			throw luan.exception("invalid sort field"+pos+", order must be 'ascending' or 'descending'");
 		String order = (String)obj2;
-		if( !(order.equals("ascending") || order.equals("descending")) )
+		boolean reverse;
+		if( order.equalsIgnoreCase("ascending") )
+			reverse = false;
+		else if( order.equalsIgnoreCase("descending") )
+			reverse = true;
+		else
 			throw luan.exception("invalid sort field"+pos+", order must be 'ascending' or 'descending'");
-		return new SortField( field, type, order.equals("descending") );
+		return new SortField( field, type, reverse );
 	}
 
 	private Sort sort(LuanState luan,LuanTable sortTbl) throws LuanException {