MCPcopy Create free account
hub / github.com/Qihoo360/poseidon / load

Method load

builder/index/src/main/java/util/IniParser.java:854–913  ·  view source on GitHub ↗

Loads options from a reader into this instance. Will read from the stream until it hits a section header, ie a '[' character, and resets the reader to point to this character. @param reader where to read from @throws IOException at an I/O problem

(BufferedReader reader)

Source from the content-addressed store, hash-verified

852 * @throws IOException at an I/O problem
853 */
854 public void load(BufferedReader reader) throws IOException {
855 while (reader.ready()) {
856 reader.mark(NAME_MAXLENGTH);
857 String line = reader.readLine().trim();
858
859 // Check for section header
860 if (line.length() > 0 && line.charAt(0) == HEADER_START) {
861 reader.reset();
862 return;
863 }
864
865 int delimIndex = -1;
866 // blank line
867 if (line.equals("")) {
868 this.addBlankLine();
869 }
870 // comment line
871 else if ((delimIndex = Arrays.binarySearch(this.commentDelimsSorted, line.charAt(0))) >= 0) {
872 addComment(line.substring(1), this.commentDelimsSorted[delimIndex]);
873 }
874 // option line
875 else {
876 delimIndex = -1;
877 int delimNum = -1;
878 int lastSpaceIndex = -1;
879 for (int i = 0, l = line.length(); i < l && delimIndex < 0; i++) {
880 delimNum = Arrays.binarySearch(this.optionDelimsSorted, line.charAt(i));
881 if (delimNum >= 0) {
882 delimIndex = i;
883 } else {
884 boolean isSpace = Arrays.binarySearch(
885 this.OPTION_DELIMS_WHITESPACE, line.charAt(i)) >= 0;
886 if (!isSpace && lastSpaceIndex >= 0) {
887 break;
888 } else if (isSpace) {
889 lastSpaceIndex = i;
890 }
891 }
892 }
893 // delimiter at start of line
894 if (delimIndex == 0) {
895 // XXX what's a man got to do?
896 }
897 // no delimiter found
898 else if (delimIndex < 0) {
899 if (lastSpaceIndex < 0) {
900 this.set(line, "");
901 } else {
902 this.set(line.substring(0, lastSpaceIndex)
903 , line.substring(lastSpaceIndex + 1));
904 }
905 }
906 // delimiter found
907 else {
908 this.set(line.substring(0, delimIndex)
909 , line.substring(delimIndex + 1), line.charAt(delimIndex));
910 }
911 }

Callers 1

loadMethod · 0.95

Calls 4

addBlankLineMethod · 0.95
addCommentMethod · 0.95
setMethod · 0.95
readLineMethod · 0.45

Tested by

no test coverage detected