Skip to content

Commit

Permalink
made HandleSet serializable
Browse files Browse the repository at this point in the history
  • Loading branch information
Orbiter committed May 15, 2012
1 parent e7e381d commit 1795a73
Show file tree
Hide file tree
Showing 10 changed files with 216 additions and 100 deletions.
2 changes: 1 addition & 1 deletion .classpath
Expand Up @@ -46,7 +46,7 @@
<classpathentry kind="lib" path="lib/httpclient-4.1.3.jar"/>
<classpathentry kind="lib" path="lib/httpmime-4.1.3.jar"/>
<classpathentry kind="lib" path="lib/commons-io-2.1.jar"/>
<classpathentry kind="lib" path="lib/apache-solr-solrj-3.6.0.jar"/>
<classpathentry kind="lib" path="lib/apache-solr-solrj-3.6.0.jar" sourcepath="/solrj/src"/>
<classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/4"/>
<classpathentry kind="lib" path="lib/icu4j-core.jar"/>
<classpathentry kind="output" path="gen"/>
Expand Down
4 changes: 3 additions & 1 deletion source/net/yacy/cora/order/ByteOrder.java
Expand Up @@ -24,8 +24,10 @@

package net.yacy.cora.order;

import java.io.Serializable;

public interface ByteOrder extends Order<byte[]> {

public interface ByteOrder extends Order<byte[]>, Serializable {

@Override
public boolean wellformed(byte[] a);
Expand Down
72 changes: 38 additions & 34 deletions source/net/yacy/kelondro/index/Column.java
Expand Up @@ -10,7 +10,7 @@
// $LastChangedBy$
//
// LICENSE
//
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
Expand All @@ -27,22 +27,26 @@

package net.yacy.kelondro.index;

import java.io.Serializable;

import net.yacy.kelondro.util.kelondroException;

public final class Column {
public final class Column implements Serializable {

private static final long serialVersionUID=6558500565023465301L;

public static final int celltype_undefined = 0;
public static final int celltype_boolean = 1;
public static final int celltype_binary = 2;
public static final int celltype_string = 3;
public static final int celltype_cardinal = 4;
public static final int celltype_bitfield = 5;

public static final int encoder_none = 0;
public static final int encoder_b64e = 1;
public static final int encoder_b256 = 2;
public static final int encoder_bytes = 3;

public int cellwidth;
public final String nickname;
protected final int celltype;
Expand All @@ -65,7 +69,7 @@ public Column(String celldef) {
celldef = celldef.trim();
if (celldef.length() > 0 && celldef.charAt(0) == '<') celldef = celldef.substring(1);
if (celldef.endsWith(">")) celldef = celldef.substring(0, celldef.length() - 1);

// parse type definition
int p = celldef.indexOf(' ');
String typename = "";
Expand All @@ -76,7 +80,7 @@ public Column(String celldef) {
} else {
typename = celldef.substring(0, p);
celldef = celldef.substring(p + 1).trim();

if (typename.equals("boolean")) {
this.celltype = celltype_boolean;
this.cellwidth = 1;
Expand Down Expand Up @@ -109,9 +113,9 @@ public Column(String celldef) {
this.cellwidth = -1; // yet undefined
} else {
throw new kelondroException("kelondroColumn - undefined type def '" + typename + "'");
}
}
}

// parse length
p = celldef.indexOf('-');
if (p < 0) {
Expand Down Expand Up @@ -144,7 +148,7 @@ public Column(String celldef) {
celldef = celldef.substring(q + 1);
}
}

// check length constraints
if (this.cellwidth < 0) throw new kelondroException("kelondroColumn - no cell width given for " + this.nickname);
if (((typename.equals("boolean")) && (this.cellwidth > 1)) ||
Expand Down Expand Up @@ -179,9 +183,9 @@ public Column(String celldef) {
if (this.celltype == celltype_cardinal) throw new kelondroException("kelondroColumn - encoder missing for cell " + this.nickname);
this.encoder = encoder_bytes;
}

assert (this.celltype != celltype_cardinal) || (this.encoder == encoder_b64e) || (this.encoder == encoder_b256);

// parse/check description
if (celldef.length() > 0 && celldef.charAt(0) == '"') {
p = celldef.indexOf('"', 1);
Expand All @@ -195,43 +199,43 @@ public Column(String celldef) {
@Override
public final String toString() {
final StringBuilder s = new StringBuilder(20);
switch (celltype) {
switch (this.celltype) {
case celltype_undefined:
s.append(nickname);
s.append(this.nickname);
s.append('-');
s.append(cellwidth);
s.append(this.cellwidth);
break;
case celltype_boolean:
s.append("boolean ");
s.append(nickname);
s.append(this.nickname);
break;
case celltype_binary:
s.append("byte[] ");
s.append(nickname);
s.append(this.nickname);
s.append('-');
s.append(cellwidth);
s.append(this.cellwidth);
break;
case celltype_string:
s.append("String ");
s.append(nickname);
s.append(this.nickname);
s.append('-');
s.append(cellwidth);
s.append(this.cellwidth);
break;
case celltype_cardinal:
s.append("Cardinal ");
s.append(nickname);
s.append(this.nickname);
s.append('-');
s.append(cellwidth);
s.append(this.cellwidth);
break;
case celltype_bitfield:
s.append("Bitfield ");
s.append(nickname);
s.append(this.nickname);
s.append('-');
s.append(cellwidth);
s.append(this.cellwidth);
break;
}
switch (encoder) {

switch (this.encoder) {
case encoder_b64e:
s.append(" {b64e}");
break;
Expand All @@ -249,11 +253,11 @@ public final String toString() {
public final int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + celltype;
result = prime * result + cellwidth;
result = prime * result + encoder;
result = prime * result + this.celltype;
result = prime * result + this.cellwidth;
result = prime * result + this.encoder;
result = prime * result
+ ((nickname == null) ? 0 : nickname.hashCode());
+ ((this.nickname == null) ? 0 : this.nickname.hashCode());
return result;
}

Expand All @@ -266,12 +270,12 @@ public boolean equals(final Object obj) {
if (obj == null) return false;
if (!(obj instanceof Column)) return false;
final Column other = (Column) obj;
if (celltype != other.celltype) return false;
if (cellwidth != other.cellwidth) return false;
if (encoder != other.encoder) return false;
if (nickname == null) {
if (this.celltype != other.celltype) return false;
if (this.cellwidth != other.cellwidth) return false;
if (this.encoder != other.encoder) return false;
if (this.nickname == null) {
if (other.nickname != null) return false;
} else if (!nickname.equals(other.nickname)) return false;
} else if (!this.nickname.equals(other.nickname)) return false;
return true;
}

Expand Down

0 comments on commit 1795a73

Please sign in to comment.