Helper method to process a line that begins with a | (and may end with a |) @param PCs List of PCs to output @param aLine Line to parse @param buf @param out character sheet we are building up @param between Whether we are processing a line between pipes @return true if we processed successfully
(PlayerCharacter[] PCs, String aLine, StringBuilder buf, BufferedWriter out, boolean between)
| 3077 | * @return true if we processed successfully |
| 3078 | */ |
| 3079 | private boolean processPipedLine(PlayerCharacter[] PCs, String aLine, StringBuilder buf, BufferedWriter out, |
| 3080 | boolean between) |
| 3081 | { |
| 3082 | final StringTokenizer aTok = new StringTokenizer(aLine, "|", false); |
| 3083 | |
| 3084 | boolean noPipes = false; |
| 3085 | if (aTok.countTokens() == 1) |
| 3086 | { |
| 3087 | noPipes = true; |
| 3088 | } |
| 3089 | |
| 3090 | boolean betweenPipes = between; |
| 3091 | |
| 3092 | while (aTok.hasMoreTokens()) |
| 3093 | { |
| 3094 | String tok = aTok.nextToken(); |
| 3095 | |
| 3096 | // If we're not between pipes then just write to the output |
| 3097 | // removing tab characters if asked to do so |
| 3098 | if (!betweenPipes) |
| 3099 | { |
| 3100 | if (manualWhitespace) |
| 3101 | { |
| 3102 | tok = tok.replaceAll("[ \\t]", ""); |
| 3103 | } |
| 3104 | FileAccess.write(out, tok); |
| 3105 | } |
| 3106 | |
| 3107 | // Guaranteed to be between pipes here |
| 3108 | else if (!noPipes && !aTok.hasMoreTokens()) |
| 3109 | { |
| 3110 | buf.append(tok); |
| 3111 | } |
| 3112 | |
| 3113 | else |
| 3114 | { |
| 3115 | buf.append(tok); |
| 3116 | String aString = buf.toString(); |
| 3117 | |
| 3118 | // We have finished dealing with section |
| 3119 | // between the pipe characters so clear out the |
| 3120 | // StringBuilder |
| 3121 | int l = buf.length(); |
| 3122 | buf.delete(0, l); |
| 3123 | |
| 3124 | if (aString.startsWith("FOR.")) |
| 3125 | { |
| 3126 | doPartyForToken(PCs, out, aString); |
| 3127 | } |
| 3128 | else |
| 3129 | { |
| 3130 | |
| 3131 | Matcher mat = Pattern.compile("^(\\d+)").matcher(aString); |
| 3132 | int charNum = mat.matches() ? Integer.parseInt(mat.group()) : -1; |
| 3133 | |
| 3134 | // This seems bizarre since we haven't stripped the |
| 3135 | // integer from the front of this string which means |
| 3136 | // that it will not be recognised as a token and will |
no test coverage detected