Package: TIFFRecord
TIFFRecord
name | instruction | branch | complexity | line | method | ||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
TIFFRecord(String, String, String, List) |
|
|
|
|
|
||||||||||||||||||||
getCapitalizedTagName() |
|
|
|
|
|
||||||||||||||||||||
getConstTagName() |
|
|
|
|
|
||||||||||||||||||||
getEnums() |
|
|
|
|
|
||||||||||||||||||||
getId() |
|
|
|
|
|
||||||||||||||||||||
getJavaType() |
|
|
|
|
|
||||||||||||||||||||
getJavaTypeToString() |
|
|
|
|
|
||||||||||||||||||||
getStrippedTagName() |
|
|
|
|
|
||||||||||||||||||||
getTagName() |
|
|
|
|
|
||||||||||||||||||||
getType() |
|
|
|
|
|
||||||||||||||||||||
getUncapitalizedTagName() |
|
|
|
|
|
||||||||||||||||||||
isHasEnums() |
|
|
|
|
|
||||||||||||||||||||
static {...} |
|
|
|
|
|
||||||||||||||||||||
toString() |
|
|
|
|
|
Coverage
1: /*
2: * *********************************************************************************************************************
3: *
4: * Mistral: open source imaging engine
5: * http://tidalwave.it/projects/mistral
6: *
7: * Copyright (C) 2003 - 2023 by Tidalwave s.a.s. (http://tidalwave.it)
8: *
9: * *********************************************************************************************************************
10: *
11: * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
12: * the License. You may obtain a copy of the License at
13: *
14: * http://www.apache.org/licenses/LICENSE-2.0
15: *
16: * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
17: * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
18: * specific language governing permissions and limitations under the License.
19: *
20: * *********************************************************************************************************************
21: *
22: * git clone https://bitbucket.org/tidalwave/mistral-src
23: * git clone https://github.com/tidalwave-it/mistral-src
24: *
25: * *********************************************************************************************************************
26: */
27: package it.tidalwave.image.codegenerator;
28:
29: import java.util.ArrayList;
30: import java.util.List;
31: import java.util.MissingResourceException;
32: import java.util.ResourceBundle;
33: import java.util.concurrent.CopyOnWriteArrayList;
34: import lombok.ToString;
35:
36: @ToString
37: public class TIFFRecord
38: {
39: private static ResourceBundle javaTypeDict = ResourceBundle.getBundle("TIFFRecord_JavaType");
40: private static final String UNDEFINED = "undefined";
41:
42: private final String id;
43: private final String tagName;
44: private final String type;
45: private final List<TIFFEnumValueName> enums = new ArrayList<>();
46:
47: public TIFFRecord (final String id, final String tagName, final String type, final List<TIFFEnumValueName> enums)
48: {
49: this.id = id;
50: this.tagName = tagName;
51: this.type = type.toLowerCase();
52:
53:• if (enums != null && !enums.isEmpty())
54: {
55: this.enums.addAll(enums);
56: }
57: }
58:
59: public int getId()
60: {
61: try
62: {
63: return Integer.parseInt(id);
64: }
65: catch (NumberFormatException e)
66: {
67: return -1;
68: }
69: }
70:
71: public String getTagName()
72: {
73: return tagName;
74: }
75:
76: public String getType()
77: {
78:• if (type.equals(UNDEFINED))
79: {
80: return "byte";
81: }
82:
83: return type;
84: }
85:
86: public String getJavaType()
87: {
88:• if (this.isHasEnums())
89: {
90: return this.getCapitalizedTagName();
91: }
92:
93: final var type = getType();
94:
95: try
96: {
97: return javaTypeDict.getString(type);
98: }
99: catch (MissingResourceException e)
100: {
101: return type;
102: }
103: }
104:
105: public String getJavaTypeToString()
106: {
107: var result = "get" + this.getCapitalizedTagName() + "()";
108:
109:• if (this.getJavaType().endsWith("[]"))
110: {
111: result = "toString(" + result + ")";
112: }
113:
114: return result;
115: }
116:
117: public String getUncapitalizedTagName()
118: {
119: return Utils.uncapitalized(getStrippedTagName());
120: }
121:
122: public String getCapitalizedTagName()
123: {
124: return Utils.capitalized(getStrippedTagName());
125: }
126:
127: public String getConstTagName()
128: {
129: return Utils.strip(tagName.toUpperCase().replace(' ', '_'));
130: }
131:
132: public boolean isHasEnums()
133: {
134:• return !enums.isEmpty();
135: }
136:
137: public List<TIFFEnumValueName> getEnums()
138: {
139: return new CopyOnWriteArrayList<>(enums);
140: }
141:
142: private String getStrippedTagName()
143: {
144: return Utils.strip(tagName).replace('/', '_').replace('(', '_').replace(')', '_');
145: }
146: }