田源
2024-03-07 4b4083fd73dc27ece42f4835483565eef0e4f608
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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
package com.mxgraph.io;
 
import com.mxgraph.util.mxUtils;
import com.mxgraph.view.mxStylesheet;
import java.util.Hashtable;
import java.util.Iterator;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
 
public class mxStylesheetCodec extends mxObjectCodec
{
  public mxStylesheetCodec()
  {
    this(new mxStylesheet());
  }
 
  public mxStylesheetCodec(Object paramObject)
  {
    this(paramObject, null, null, null);
  }
 
  public mxStylesheetCodec(Object paramObject, String[] paramArrayOfString1, String[] paramArrayOfString2, Map<String, String> paramMap)
  {
    super(paramObject, paramArrayOfString1, paramArrayOfString2, paramMap);
  }
 
  public Node encode(mxCodec parammxCodec, Object paramObject)
  {
    Element localElement1 = parammxCodec.document.createElement(getName());
    if (paramObject instanceof mxStylesheet)
    {
      mxStylesheet localmxStylesheet = (mxStylesheet)paramObject;
      Iterator localIterator1 = localmxStylesheet.getStyles().entrySet().iterator();
      while (localIterator1.hasNext())
      {
        Map.Entry localEntry1 = (Map.Entry)localIterator1.next();
        Element localElement2 = parammxCodec.document.createElement("add");
        String str = (String)localEntry1.getKey();
        localElement2.setAttribute("as", str);
        Map localMap = (Map)localEntry1.getValue();
        Iterator localIterator2 = localMap.entrySet().iterator();
        while (localIterator2.hasNext())
        {
          Map.Entry localEntry2 = (Map.Entry)localIterator2.next();
          Element localElement3 = parammxCodec.document.createElement("add");
          localElement3.setAttribute("as", String.valueOf(localEntry2.getKey()));
          localElement3.setAttribute("value", getStringValue(localEntry2));
          localElement2.appendChild(localElement3);
        }
        if (localElement2.getChildNodes().getLength() > 0)
          localElement1.appendChild(localElement2);
      }
    }
    return localElement1;
  }
 
  protected String getStringValue(Map.Entry<String, Object> paramEntry)
  {
    if (paramEntry.getValue() instanceof Boolean)
      return ((((Boolean)paramEntry.getValue()).booleanValue()) ? "1" : "0");
    return paramEntry.getValue().toString();
  }
 
  public Object decode(mxCodec parammxCodec, Node paramNode, Object paramObject)
  {
    Object localObject1 = null;
    if (paramNode instanceof Element)
    {
      String str1 = ((Element)paramNode).getAttribute("id");
      localObject1 = parammxCodec.objects.get(str1);
      if (localObject1 == null)
      {
        localObject1 = paramObject;
        if (localObject1 == null)
          localObject1 = cloneTemplate(paramNode);
        if ((str1 != null) && (str1.length() > 0))
          parammxCodec.putObject(str1, localObject1);
      }
      for (paramNode = paramNode.getFirstChild(); paramNode != null; paramNode = paramNode.getNextSibling())
      {
        if ((processInclude(parammxCodec, paramNode, localObject1)) || (!(paramNode.getNodeName().equals("add"))) || (!(paramNode instanceof Element)))
          continue;
        String str2 = ((Element)paramNode).getAttribute("as");
        if ((str2 == null) || (str2.length() <= 0))
          continue;
        String str3 = ((Element)paramNode).getAttribute("extend");
        Hashtable localHashtable = (str3 != null) ? (Map)((mxStylesheet)localObject1).getStyles().get(str3) : null;
        if (localHashtable == null)
          localHashtable = new Hashtable();
        else
          localHashtable = new Hashtable(localHashtable);
        for (Node localNode = paramNode.getFirstChild(); localNode != null; localNode = localNode.getNextSibling())
        {
          if (!(localNode instanceof Element))
            continue;
          Element localElement = (Element)localNode;
          String str4 = localElement.getAttribute("as");
          if (localNode.getNodeName().equals("add"))
          {
            String str5 = localNode.getTextContent();
            Object localObject2 = null;
            if ((str5 != null) && (str5.length() > 0))
              localObject2 = mxUtils.eval(str5);
            else
              localObject2 = localElement.getAttribute("value");
            if (localObject2 != null)
              localHashtable.put(str4, localObject2);
          }
          else
          {
            if (!(localNode.getNodeName().equals("remove")))
              continue;
            localHashtable.remove(str4);
          }
        }
        ((mxStylesheet)localObject1).putCellStyle(str2, localHashtable);
      }
    }
    return localObject1;
  }
}
 
/* Location:           C:\Users\platform-001\Desktop\新建文件夹 (2)\jgraphx.jar
 * Qualified Name:     com.mxgraph.io.mxStylesheetCodec
 * JD-Core Version:    0.5.3
 */