pylucene 3.5.0-3
[pylucene.git] / lucene-java-3.5.0 / lucene / src / java / org / apache / lucene / util / fst / Outputs.java
1 package org.apache.lucene.util.fst;
2
3 /**
4  * Licensed to the Apache Software Foundation (ASF) under one or more
5  * contributor license agreements.  See the NOTICE file distributed with
6  * this work for additional information regarding copyright ownership.
7  * The ASF licenses this file to You under the Apache License, Version 2.0
8  * (the "License"); you may not use this file except in compliance with
9  * the License.  You may obtain a copy of the License at
10  *
11  *     http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  */
19
20 import java.io.IOException;
21
22 import org.apache.lucene.store.DataInput;
23 import org.apache.lucene.store.DataOutput;
24
25 /**
26  * Represents the outputs for an FST, providing the basic
27  * algebra needed for the FST.
28  *
29  * @lucene.experimental
30  */
31
32 public abstract class Outputs<T> {
33
34   // TODO: maybe change this API to allow for re-use of the
35   // output instances -- this is an insane amount of garbage
36   // (new object per byte/char/int) if eg used during
37   // analysis
38
39   /** Eg common("foo", "foobar") -> "foo" */
40   public abstract T common(T output1, T output2);
41
42   /** Eg subtract("foobar", "foo") -> "bar" */
43   public abstract T subtract(T output, T inc);
44
45   /** Eg add("foo", "bar") -> "foobar" */
46   public abstract T add(T prefix, T output);
47
48   public abstract void write(T output, DataOutput out) throws IOException;
49
50   public abstract T read(DataInput in) throws IOException;
51
52   /** NOTE: this output is compared with == so you must
53    *  ensure that all methods return the single object if
54    *  it's really no output */
55   public abstract T getNoOutput();
56
57   public abstract String outputToString(T output);
58
59   public T merge(T first, T second) {
60     throw new UnsupportedOperationException();
61   }
62 }