MCPcopy Create free account
hub / github.com/AstroImageJ/astroimagej / getValue

Method getValue

ij/src/main/java/ij/Macro.java:111–153  ·  view source on GitHub ↗
(String options, String key, String defaultValue)

Source from the content-addressed store, hash-verified

109 }
110
111 public static String getValue(String options, String key, String defaultValue) {
112 key = trimKey(key);
113 if (!options.endsWith(" "))
114 options = options + " ";
115 key += '=';
116 int index=-1;
117 do { // Require that key not be preceded by a letter
118 index = options.indexOf(key, ++index);
119 if (index<0) return defaultValue;
120 } while (index!=0&&Character.isLetter(options.charAt(index-1)));
121 options = options.substring(index+key.length(), options.length());
122 if (options.charAt(0)=='\'') {
123 index = options.indexOf("'",1);
124 if (index<0)
125 return defaultValue;
126 else
127 return options.substring(1, index);
128 } else if (options.charAt(0)=='[') {
129 int count = 1;
130 index = -1;
131 for (int i=1; i<options.length(); i++) {
132 char ch = options.charAt(i);
133 if (ch=='[')
134 count++;
135 else if (ch==']')
136 count--;
137 if (count==0) {
138 index = i;
139 break;
140 }
141 }
142 if (index<0)
143 return defaultValue;
144 else
145 return options.substring(1, index);
146 } else {
147 index = options.indexOf(" ");
148 if (index<0)
149 return defaultValue;
150 else
151 return options.substring(0, index);
152 }
153 }
154
155 public static String trimKey(String key) {
156 if (key==null)

Callers 15

setOptionsMethod · 0.95
runMethod · 0.95
appendNewImageMethod · 0.95
updateMacroOptionsMethod · 0.95
displayDialogMethod · 0.95
isMacroMethod · 0.95
DirectoryChooserMethod · 0.95
OpenDialogMethod · 0.95
getNextNumberMethod · 0.95
getNextStringMethod · 0.95
getNextChoiceMethod · 0.95

Calls 5

trimKeyMethod · 0.95
charAtMethod · 0.80
substringMethod · 0.80
lengthMethod · 0.65
indexOfMethod · 0.45

Tested by

no test coverage detected