01: /*
02: * $Id: Descriptor.java,v 1.18 2007/03/12 10:40:49 agoubard Exp $
03: *
04: * Copyright 2003-2007 Orange Nederland Breedband B.V.
05: * See the COPYRIGHT file for redistribution and use restrictions.
06: */
07: package org.xins.common.service;
08:
09: import java.io.Serializable;
10: import java.util.Iterator;
11:
12: /**
13: * Descriptor for a service or group of services.
14: *
15: * @version $Revision: 1.18 $ $Date: 2007/03/12 10:40:49 $
16: * @author <a href="mailto:ernst@ernstdehaan.com">Ernst de Haan</a>
17: *
18: * @since XINS 1.0.0
19: */
20: public abstract class Descriptor implements Serializable {
21:
22: /**
23: * Constructs a new <code>Descriptor</code>.
24: */
25: Descriptor() {
26:
27: // empty
28: }
29:
30: /**
31: * Checks if this descriptor denotes a group of descriptor of descriptorss.
32: *
33: * @return
34: * <code>true</code> if this descriptor denotes a group,
35: * <code>false</code> otherwise.
36: */
37: public abstract boolean isGroup();
38:
39: /**
40: * Iterates over all leaves, the target descriptors.
41: *
42: * <p>The returned {@link Iterator} will not support
43: * {@link Iterator#remove()}. The iterator will only return
44: * {@link TargetDescriptor} instances, no instances of other classes and
45: * no <code>null</code> values.
46: *
47: * <p>Also, this iterator is guaranteed to return {@link #getTargetCount()}
48: * instances of class {@link TargetDescriptor}.
49: *
50: * @return
51: * iterator over the leaves, the target descriptors, in this
52: * descriptor, in the correct order, never <code>null</code>.
53: */
54: public abstract Iterator iterateTargets();
55:
56: /**
57: * Counts the total number of target descriptors in/under this descriptor.
58: *
59: * @return
60: * the total number of target descriptors, always >= 1.
61: */
62: public abstract int getTargetCount();
63:
64: /**
65: * Returns the <code>TargetDescriptor</code> that matches the specified
66: * CRC-32 checksum.
67: *
68: * @param crc
69: * the CRC-32 checksum.
70: *
71: * @return
72: * the {@link TargetDescriptor} that matches the specified checksum, or
73: * <code>null</code>, if none could be found in this descriptor.
74: */
75: public abstract TargetDescriptor getTargetByCRC(int crc);
76: }
|