01: /*
02: (c) Copyright 2004, 2005, 2006, 2007, 2008 Hewlett-Packard Development Company, LP, all rights reserved.
03: [See end of file]
04: $Id: Sequence.java,v 1.7 2008/01/02 12:06:05 andy_seaborne Exp $
05: */
06:
07: package com.hp.hpl.jena.graph.query.regexptrees;
08:
09: import java.util.List;
10:
11: /**
12: A sequence of regular expressions. The only access to the constructor is
13: through the <code>create</code> method, which does not construct unit
14: sequences.
15:
16: @author hedgehog
17: */
18: public class Sequence extends MultiOperandTree {
19: protected Sequence(RegexpTree[] operands) {
20: super (operands);
21: }
22:
23: public static RegexpTree create(List operands) {
24: if (operands.size() == 0)
25: return NON;
26: else if (operands.size() == 1)
27: return (RegexpTree) operands.get(0);
28: else
29: return new Sequence((RegexpTree[]) operands
30: .toArray(new RegexpTree[operands.size()]));
31: }
32:
33: public boolean equals(Object other) {
34: return other instanceof Sequence
35: && sameOperands((MultiOperandTree) other);
36: }
37:
38: public int hashCode() {
39: return hashCode(0);
40: }
41:
42: public String toString() {
43: return toString("seq");
44: }
45:
46: }
47:
48: /*
49: (c) Copyright 2004, 2005, 2006, 2007, 2008 Hewlett-Packard Development Company, LP
50: All rights reserved.
51:
52: Redistribution and use in source and binary forms, with or without
53: modification, are permitted provided that the following conditions
54: are met:
55:
56: 1. Redistributions of source code must retain the above copyright
57: notice, this list of conditions and the following disclaimer.
58:
59: 2. Redistributions in binary form must reproduce the above copyright
60: notice, this list of conditions and the following disclaimer in the
61: documentation and/or other materials provided with the distribution.
62:
63: 3. The name of the author may not be used to endorse or promote products
64: derived from this software without specific prior written permission.
65:
66: THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
67: IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
68: OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
69: IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
70: INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
71: NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
72: DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
73: THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
74: (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
75: THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
76: */
|