File: LazyAttributeMap.java

package info (click to toggle)
liblayout 0.2.10-5
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 5,332 kB
  • sloc: java: 51,125; xml: 138; makefile: 17
file content (105 lines) | stat: -rw-r--r-- 1,961 bytes parent folder | download | duplicates (5)
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
package org.jfree.layouting.util;

import java.util.Map;

/**
 * Todo: Document Me
 *
 * @author Thomas Morgner
 */
public class LazyAttributeMap extends AttributeMap
{
  private AttributeMap lazyMap;

  public LazyAttributeMap(final AttributeMap copy)
  {
    if (copy == null)
    {
      return;
    }
    if (copy.isReadOnly() == false)
    {
      copyInto(copy);
      return;
    }

    lazyMap = copy;
  }

  public Object setAttribute(final String namespace, final String attribute, final Object value)
  {
    if (isReadOnly())
    {
      throw new IllegalStateException();
    }
    if (lazyMap != null)
    {
      copyInto(lazyMap);
      lazyMap = null;
    }
    return super.setAttribute(namespace, attribute, value);
  }

  public AttributeMap createUnmodifiableMap()
  {
    if (lazyMap != null)
    {
      return lazyMap;
    }
    return super.createUnmodifiableMap();
  }

  public boolean isEmpty()
  {
    if (lazyMap != null)
    {
      return lazyMap.isEmpty();
    }
    return super.isEmpty();
  }

  public Object getAttribute(final String namespace, final String attribute)
  {
    if (lazyMap != null)
    {
      return lazyMap.getAttribute(namespace, attribute);
    }
    return super.getAttribute(namespace, attribute);
  }

  public Object getFirstAttribute(final String attribute)
  {
    if (lazyMap != null)
    {
      return lazyMap.getFirstAttribute(attribute);
    }
    return super.getFirstAttribute(attribute);
  }

  public Map getAttributes(final String namespace)
  {
    if (lazyMap != null)
    {
      return lazyMap.getAttributes(namespace);
    }
    return super.getAttributes(namespace);
  }

  public String[] getNameSpaces()
  {
    if (lazyMap != null)
    {
      return lazyMap.getNameSpaces();
    }
    return super.getNameSpaces();
  }

  public long getChangeTracker()
  {
    if (lazyMap != null)
    {
      return lazyMap.getChangeTracker();
    }
    return super.getChangeTracker();
  }
}