1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32 package com.unitesk.atp.dynattrs;
33
34 import java.io.Serializable;
35
36 /***
37 * The default implementation of {@link Attributed} methods that
38 * deals with indexed attributes.
39 *
40 * @author <A href="mailto:demakov@ispras.ru">Alexey Demakov</A>
41 * @version $Id: IndexedAttributedImpl.java,v 1.2 2005/02/21 16:50:26 all-x Exp $
42 */
43 public abstract class IndexedAttributedImpl implements Attributed, Serializable
44 {
45 /***
46 * {@inheritDoc}
47 */
48 public boolean isIndexed( String name )
49 {
50 Object value = getAttribute( name );
51
52 try
53 {
54 return Accessor.isIndexed( value );
55 }
56 catch( Exception e )
57 {
58 throw new AttributeException( this, name, value, e );
59 }
60 }
61
62 /***
63 * {@inheritDoc}
64 */
65 public int sizeAttribute( String name )
66 {
67 Object value = getAttribute( name );
68
69 try
70 {
71 return Accessor.sizeIndexed( value );
72 }
73 catch( Exception e )
74 {
75 throw new AttributeException( this, name, value, e );
76 }
77 }
78
79 /***
80 * {@inheritDoc}
81 */
82 public Object getAttribute( String name, int index )
83 {
84 Object value = getAttribute( name );
85
86 try
87 {
88 return Accessor.getIndexed( value, index );
89 }
90 catch( Exception e )
91 {
92 throw new AttributeException( this, name, value, e );
93 }
94 }
95
96 /***
97 * {@inheritDoc}
98 */
99 public void setAttribute( String name, int index, Object elem )
100 {
101 Object value = getAttribute( name );
102
103 try
104 {
105 Accessor.setIndexed( value, index, elem );
106 }
107 catch( Exception e )
108 {
109 throw new AttributeException( this, name, value, e );
110 }
111 }
112 }