MCPcopy Create free account
hub / github.com/DeNA/PacketProxy / parsePosition

Method parsePosition

src/main/java/core/org/xbill/DNS/LOCRecord.java:93–132  ·  view source on GitHub ↗
(Tokenizer st, String type)

Source from the content-addressed store, hash-verified

91}
92
93private long
94parsePosition(Tokenizer st, String type) throws IOException {
95 boolean isLatitude = type.equals("latitude");
96 int deg = 0, min = 0;
97 double sec = 0;
98 long value;
99 String s;
100
101 deg = st.getUInt16();
102 if (deg > 180 || (deg > 90 && isLatitude))
103 throw st.exception("Invalid LOC " + type + " degrees");
104
105 s = st.getString();
106 try {
107 min = Integer.parseInt(s);
108 if (min < 0 || min > 59)
109 throw st.exception("Invalid LOC " + type + " minutes");
110 s = st.getString();
111 sec = parseFixedPoint(s);
112 if (sec < 0 || sec >= 60)
113 throw st.exception("Invalid LOC " + type + " seconds");
114 s = st.getString();
115 } catch (NumberFormatException e) {
116 }
117
118 if (s.length() != 1)
119 throw st.exception("Invalid LOC " + type);
120
121 value = (long) (1000 * (sec + 60L * (min + 60L * deg)));
122
123 char c = Character.toUpperCase(s.charAt(0));
124 if ((isLatitude && c == 'S') || (!isLatitude && c == 'W'))
125 value = -value;
126 else if ((isLatitude && c != 'N') || (!isLatitude && c != 'E'))
127 throw st.exception("Invalid LOC " + type);
128
129 value += (1L << 31);
130
131 return value;
132}
133
134private long
135parseDouble(Tokenizer st, String type, boolean required, long min, long max,

Callers 1

rdataFromStringMethod · 0.95

Calls 6

parseFixedPointMethod · 0.95
getUInt16Method · 0.80
exceptionMethod · 0.80
lengthMethod · 0.80
equalsMethod · 0.45
getStringMethod · 0.45

Tested by

no test coverage detected