MCPcopy Create free account
hub / github.com/agateau/pixelwheels / parseHeader

Method parseHeader

core/src/com/agateau/translations/PoParser.java:263–285  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

261 }
262
263 private void parseHeader() throws PoParserException {
264 if (!mMsgId.equals("")) {
265 throw new PoParserException(mLineNumber + 1, "Missing header");
266 }
267 String header = mMsgStr.get(0);
268 Matcher matcher = HEADER_PATTERN.matcher(header);
269 if (!matcher.find()) {
270 throw new PoParserException(
271 mLineNumber + 1, "Can't find plural definition in header:\n" + header);
272 }
273 mPluralCount = Integer.parseInt(matcher.group(1));
274 // Simplify expressionString: remove spaces and surrounding parenthesis
275 String expressionString = matcher.group(2).replace(" ", "");
276 if (expressionString.startsWith("(") && expressionString.endsWith(")")) {
277 expressionString = expressionString.substring(1, expressionString.length() - 1);
278 }
279 Messages.PluralExpression expression = sPluralExpressionByString.get(expressionString);
280 if (expression == null) {
281 throw new PoParserException(
282 mLineNumber + 1, "Unknown plural expression: " + expressionString);
283 }
284 mMessages = new Messages(expression);
285 }
286
287 // Internal function to be able to early returns and still get the clean of member vars
288 // in addCurrentEntry()

Callers 1

addCurrentEntryMethod · 0.95

Calls 4

replaceMethod · 0.80
equalsMethod · 0.45
getMethod · 0.45
findMethod · 0.45

Tested by

no test coverage detected