Skip to content

Commit 5980f43

Browse files
committed
Javadoc changes for release
1 parent ad3dfbd commit 5980f43

File tree

8 files changed

+157
-121
lines changed

8 files changed

+157
-121
lines changed

src/main/java/org/owasp/fileio/Encoder.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ public Encoder() {
8181

8282
/**
8383
* Instantiates a new DefaultEncoder with the default codecs
84+
* @param codecs A List of Codecs to use
8485
*/
8586
public Encoder(List<Codec> codecs) {
8687
this.codecs = codecs;

src/main/java/org/owasp/fileio/FileValidator.java

Lines changed: 103 additions & 90 deletions
Large diffs are not rendered by default.

src/main/java/org/owasp/fileio/StringValidationRule.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ public StringValidationRule(String typeName, Encoder encoder, String whitelistPa
5050
}
5151

5252
/**
53+
* @param pattern A String which will be compiled into a regular expression pattern to add to the whitelist
5354
* @throws IllegalArgumentException if pattern is null
5455
*/
5556
public void addWhitelistPattern(String pattern) {
@@ -64,6 +65,7 @@ public void addWhitelistPattern(String pattern) {
6465
}
6566

6667
/**
68+
* @param p A regular expression pattern to add to the whitelist
6769
* @throws IllegalArgumentException if p is null
6870
*/
6971
public void addWhitelistPattern(Pattern p) {
@@ -74,6 +76,8 @@ public void addWhitelistPattern(Pattern p) {
7476
}
7577

7678
/**
79+
* @param pattern A String which will be compiled into a regular expression pattern to add to the blacklist
80+
7781
* @throws IllegalArgumentException if pattern is null
7882
*/
7983
public void addBlacklistPattern(String pattern) {
@@ -88,6 +92,7 @@ public void addBlacklistPattern(String pattern) {
8892
}
8993

9094
/**
95+
* @param p A regular expression pattern to add to the blacklist
9196
* @throws IllegalArgumentException if p is null
9297
*/
9398
public void addBlacklistPattern(Pattern p) {
@@ -119,7 +124,7 @@ public void setValidateInputAndCanonical(boolean flag) {
119124
*
120125
* @param context The context to include in exception messages
121126
* @param input the input to check
122-
* @param orig A origional input to include in exception messages. This is not included if it is the same as input.
127+
* @param orig A original input to include in exception messages. This is not included if it is the same as input.
123128
* @return input upon a successful check
124129
* @throws ValidationException if the check fails.
125130
*/
@@ -151,7 +156,7 @@ private String checkWhitelist(String context, String input) throws ValidationExc
151156
*
152157
* @param context The context to include in exception messages
153158
* @param input the input to check
154-
* @param orig A origional input to include in exception messages. This is not included if it is the same as input.
159+
* @param orig A original input to include in exception messages. This is not included if it is the same as input.
155160
* @return input upon a successful check
156161
* @throws ValidationException if the check fails.
157162
*/

src/main/java/org/owasp/fileio/codecs/Codec.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public Codec() {
4343
/**
4444
* Encode a String so that it can be safely used in a specific context.
4545
*
46-
* @param immune
46+
* @param immune An array of characters that will not be encoded.
4747
* @param input the String to encode
4848
* @return the encoded String
4949
*/
@@ -59,7 +59,7 @@ public String encode(char[] immune, String input) {
5959
/**
6060
* Default implementation that should be overridden in specific codecs.
6161
*
62-
* @param immune
62+
* @param immune An array of characters that will not be encoded.
6363
* @param c the Character to encode
6464
* @return the encoded Character
6565
*/
@@ -123,9 +123,9 @@ public static String toHex(char c) {
123123
/**
124124
* Utility to search a char[] for a specific char.
125125
*
126-
* @param c
127-
* @param array
128-
* @return
126+
* @param c The character to search for
127+
* @param array The array of characters to search
128+
* @return true if the array contains the character to search for
129129
*/
130130
public static boolean containsCharacter(char c, char[] array) {
131131
for (char ch : array) {

src/main/java/org/owasp/fileio/codecs/HTMLEntityCodec.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,9 @@ public HTMLEntityCodec() {
3838
*
3939
* Encodes a Character for safe use in an HTML entity field.
4040
*
41-
* @param immune
41+
* @param immune An array of characters that will not be encoded.
4242
*/
43+
@Override
4344
public String encodeCharacter(char[] immune, Character c) {
4445

4546
// check for immune characters
@@ -74,8 +75,9 @@ public String encodeCharacter(char[] immune, Character c) {
7475
*
7576
* Returns the decoded version of the character starting at index, or null if no decoding is possible.
7677
*
77-
* Formats all are legal both with and without semi-colon, upper/lower case: &#dddd; &#xhhhh; &name;
78+
* Formats all are legal both with and without semi-colon, upper/lower case: &amp;#dddd; &amp;#xhhhh; &amp;name;
7879
*/
80+
@Override
7981
public Character decodeCharacter(PushbackString input) {
8082
input.mark();
8183
Character first = input.next();

src/main/java/org/owasp/fileio/codecs/HashTrie.java

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
*
2929
* <b>NOTE:</b><br>
3030
* <ul>
31-
* <li>{@link Map.remove(Object)} is not supported.</li>
31+
* <li>java.util.Map.remove(java.lang.Object) is not supported.</li>
3232
* <li>
3333
* If deletion support is added the max key length will need work or removal.
3434
* </li>
@@ -405,6 +405,7 @@ public HashTrie() {
405405
* @param key The key to lookup
406406
* @return Entry with the longest matching key.
407407
*/
408+
@Override
408409
public Map.Entry<CharSequence, T> getLongestMatch(CharSequence key) {
409410
if (root == null || key == null) {
410411
return null;
@@ -419,6 +420,7 @@ public Map.Entry<CharSequence, T> getLongestMatch(CharSequence key) {
419420
* @return Entry with the longest matching key.
420421
* @throws IOException if keyIn.read() or keyIn.unread() does.
421422
*/
423+
@Override
422424
public Map.Entry<CharSequence, T> getLongestMatch(PushbackReader keyIn) throws IOException {
423425
if (root == null || keyIn == null) {
424426
return null;
@@ -431,6 +433,7 @@ public Map.Entry<CharSequence, T> getLongestMatch(PushbackReader keyIn) throws I
431433
*
432434
* @return max key length.
433435
*/
436+
@Override
434437
public int getMaxKeyLength() {
435438
return maxKeyLen;
436439
}
@@ -445,6 +448,7 @@ public int getMaxKeyLength() {
445448
/**
446449
* Clear all entries.
447450
*/
451+
@Override
448452
public void clear() {
449453
root = null;
450454
maxKeyLen = -1;
@@ -454,13 +458,15 @@ public void clear() {
454458
/**
455459
* {@inheritDoc}
456460
*/
461+
@Override
457462
public boolean containsKey(Object key) {
458463
return (get(key) != null);
459464
}
460465

461466
/**
462467
* {@inheritDoc}
463468
*/
469+
@Override
464470
public boolean containsValue(Object value) {
465471
if (root == null) {
466472
return false;
@@ -472,9 +478,10 @@ public boolean containsValue(Object value) {
472478
* Add mapping.
473479
*
474480
* @param key The mapping's key.
475-
* @value value The mapping's value
481+
* @param value value The mapping's value
476482
* @throws NullPointerException if key or value is null.
477483
*/
484+
@Override
478485
public T put(CharSequence key, T value) throws NullPointerException {
479486
int len;
480487
T old;
@@ -486,7 +493,7 @@ public T put(CharSequence key, T value) throws NullPointerException {
486493
throw new NullPointerException("Null values are not handled");
487494
}
488495
if (root == null) {
489-
root = new Node<T>();
496+
root = new Node<>();
490497
}
491498
if ((old = root.put(key, 0, value)) != null) {
492499
return old;
@@ -506,13 +513,15 @@ public T put(CharSequence key, T value) throws NullPointerException {
506513
* @return previous value
507514
* @throws UnsupportedOperationException always.
508515
*/
516+
@Override
509517
public T remove(Object key) throws UnsupportedOperationException {
510518
throw new UnsupportedOperationException();
511519
}
512520

513521
/**
514522
* {@inheritDoc}
515523
*/
524+
@Override
516525
public void putAll(Map<? extends CharSequence, ? extends T> map) {
517526
for (Map.Entry<? extends CharSequence, ? extends T> entry : map.entrySet()) {
518527
put(entry.getKey(), entry.getValue());
@@ -522,8 +531,9 @@ public void putAll(Map<? extends CharSequence, ? extends T> map) {
522531
/**
523532
* {@inheritDoc}
524533
*/
534+
@Override
525535
public Set<CharSequence> keySet() {
526-
Set<CharSequence> keys = new HashSet<CharSequence>(size);
536+
Set<CharSequence> keys = new HashSet<>(size);
527537

528538
if (root == null) {
529539
return keys;
@@ -534,8 +544,9 @@ public Set<CharSequence> keySet() {
534544
/**
535545
* {@inheritDoc}
536546
*/
547+
@Override
537548
public Collection<T> values() {
538-
ArrayList<T> values = new ArrayList<T>(size());
549+
ArrayList<T> values = new ArrayList<>(size());
539550

540551
if (root == null) {
541552
return values;
@@ -546,8 +557,9 @@ public Collection<T> values() {
546557
/**
547558
* {@inheritDoc}
548559
*/
560+
@Override
549561
public Set<Map.Entry<CharSequence, T>> entrySet() {
550-
Set<Map.Entry<CharSequence, T>> entries = new HashSet<Map.Entry<CharSequence, T>>(size());
562+
Set<Map.Entry<CharSequence, T>> entries = new HashSet<>(size());
551563

552564
if (root == null) {
553565
return entries;
@@ -561,6 +573,7 @@ public Set<Map.Entry<CharSequence, T>> entrySet() {
561573
* @param key The key to look up.
562574
* @return The value for key or null if the key is not found.
563575
*/
576+
@Override
564577
public T get(Object key) {
565578
if (root == null || key == null) {
566579
return null;
@@ -576,6 +589,7 @@ public T get(Object key) {
576589
*
577590
* @return the number or entries.
578591
*/
592+
@Override
579593
public int size() {
580594
return size;
581595
}
@@ -633,6 +647,7 @@ public String toString() {
633647
/**
634648
* {@inheritDoc}
635649
*/
650+
@Override
636651
public boolean isEmpty() {
637652
return (size() == 0);
638653
}

src/main/java/org/owasp/fileio/codecs/PushbackString.java

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -24,16 +24,16 @@ public class PushbackString {
2424
private int mark = 0;
2525

2626
/**
27-
*
28-
* @param input
27+
* Constructs a new instance of PushbackString
28+
* @param input the String to decode
2929
*/
3030
public PushbackString(String input) {
3131
this.input = input;
3232
}
3333

3434
/**
3535
*
36-
* @param c
36+
* @param c The character to set as the pushback
3737
*/
3838
public void pushback(Character c) {
3939
pushback = c;
@@ -50,7 +50,7 @@ public int index() {
5050

5151
/**
5252
*
53-
* @return
53+
* @return true if there are more characters to process
5454
*/
5555
public boolean hasNext() {
5656
if (pushback != null) {
@@ -70,7 +70,7 @@ public boolean hasNext() {
7070

7171
/**
7272
*
73-
* @return
73+
* @return the next character
7474
*/
7575
public Character next() {
7676
if (pushback != null) {
@@ -92,7 +92,7 @@ public Character next() {
9292

9393
/**
9494
*
95-
* @return
95+
* @return the next hex digit in the input, or null if the next character is not hex
9696
*/
9797
public Character nextHex() {
9898
Character c = next();
@@ -107,7 +107,7 @@ public Character nextHex() {
107107

108108
/**
109109
*
110-
* @return
110+
* @return the next octal digit in the input, or null if the next character is not octal
111111
*/
112112
public Character nextOctal() {
113113
Character c = next();
@@ -123,8 +123,8 @@ public Character nextOctal() {
123123
/**
124124
* Returns true if the parameter character is a hexidecimal digit 0 through 9, a through f, or A through F.
125125
*
126-
* @param c
127-
* @return
126+
* @param c The Character to test
127+
* @return true if the input character is a hex digit (0-F)
128128
*/
129129
public static boolean isHexDigit(Character c) {
130130
if (c == null) {
@@ -137,8 +137,8 @@ public static boolean isHexDigit(Character c) {
137137
/**
138138
* Returns true if the parameter character is an octal digit 0 through 7.
139139
*
140-
* @param c
141-
* @return
140+
* @param c The Character to test
141+
* @return true if the input character is an octal digit (0-7)
142142
*/
143143
public static boolean isOctalDigit(Character c) {
144144
if (c == null) {
@@ -151,7 +151,7 @@ public static boolean isOctalDigit(Character c) {
151151
/**
152152
* Return the next character without affecting the current index.
153153
*
154-
* @return
154+
* @return the next Character in the input
155155
*/
156156
public Character peek() {
157157
if (pushback != null) {
@@ -172,8 +172,8 @@ public Character peek() {
172172
/**
173173
* Test to see if the next character is a particular value without affecting the current index.
174174
*
175-
* @param c
176-
* @return
175+
* @param c The character to test for
176+
* @return true if the next character matches the input character
177177
*/
178178
public boolean peek(char c) {
179179
if (pushback != null && pushback.charValue() == c) {
@@ -209,7 +209,7 @@ public void reset() {
209209

210210
/**
211211
*
212-
* @return
212+
* @return the remainder of the input String, prepended with any pushback, if necessary
213213
*/
214214
protected String remainder() {
215215
String output = input.substring(index);

src/main/java/org/owasp/fileio/util/Utils.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
/**
1919
* This class provides a number of utility functions.
2020
*
21-
* @author August Detlefsen <augustd at codemagi dot com>
21+
* @author August Detlefsen [augustd at codemagi dot com]
2222
*/
2323
public class Utils {
2424

0 commit comments

Comments
 (0)