2 * Copyright (C) 2007 EDIT
3 * European Distributed Institute of Taxonomy
4 * http://www.e-taxonomy.eu
6 * The contents of this file are subject to the Mozilla Public License Version 1.1
7 * See LICENSE.TXT at the top of this package for the full license terms.
10 package eu
.etaxonomy
.cdm
.persistence
.fetch
;
12 import org
.apache
.log4j
.Logger
;
20 public class CdmFetch
{
21 private static final Logger logger
= Logger
.getLogger(CdmFetch
.class);
23 public static CdmFetch
NO_FETCH() {return new CdmFetch(0);}
24 public static CdmFetch
FETCH_NOTHING() {return new CdmFetch(0);}
26 public static CdmFetch
FETCH_DESCRIPTIONS() {return new CdmFetch(1);}
27 public static CdmFetch
FETCH_CHILDTAXA() {return new CdmFetch(2);}
28 public static CdmFetch
FETCH_PARENT_TAXA() {return new CdmFetch(3);}
29 public static CdmFetch
FETCH_ANNOTATIONS_ALL() {return new CdmFetch(4);}
30 public static CdmFetch
FETCH_MARKER_ALL() {return new CdmFetch(5);}
31 public static CdmFetch
FETCH_SYNONYMS() {return new CdmFetch(6);}
33 protected int fetchSum
;
35 private CdmFetch(int fetchId
) {
36 this.fetchSum
= (int)Math
.pow(2, fetchId
);
39 public void add(CdmFetch cdmFetch
) {
40 this.fetchSum
= (this.fetchSum
| cdmFetch
.fetchSum
);
43 public boolean includes(CdmFetch cdmFetch
){
44 int andFetch
= cdmFetch
.fetchSum
& this.fetchSum
;
45 if (andFetch
== cdmFetch
.fetchSum
){
55 public static void main(String
[] args
) {
56 CdmFetch fetch1
= FETCH_DESCRIPTIONS();
57 CdmFetch fetch2
= FETCH_MARKER_ALL();
58 CdmFetch fetch3
= FETCH_SYNONYMS();
59 CdmFetch fetch4
= FETCH_DESCRIPTIONS();
62 logger
.warn(fetch3
.includes(fetch1
));
63 logger
.warn(fetch1
.includes(fetch2
));
64 logger
.warn(fetch2
.includes(fetch1
));
66 logger
.warn(fetch2
.includes(fetch1
));
68 logger
.warn(fetch1
.includes(fetch4
));