55
66import java .util .Arrays ;
77
8- public class Binary implements Scalar <byte []> {
9- protected byte [] value ;
10-
8+ public class Binary extends Scalar <byte []> {
119 public Binary () {
10+ super ();
1211 }
1312
1413 public Binary (Object value ) throws ValidationException {
15- this . set (value );
14+ super (value );
1615 }
1716
1817 @ Override
19- public String toString () {
18+ public java . lang . String toString () {
2019 if (this .value != null ) {
2120 return Base64 .encodeBase64String (this .value );
2221 }
2322 return NULL_VALUE_STRING ;
2423 }
2524
26- @ Override
27- public boolean isValid () {
28- return this .value != null ;
29- }
30-
3125 @ Override
3226 public ArrowType dataType () {
3327 return ArrowType .Binary .INSTANCE ;
3428 }
3529
3630 @ Override
37- public void set (Object value ) throws ValidationException {
38- if (value == null ) {
39- this .value = null ;
40- return ;
41- }
42-
43- if (value instanceof Scalar <?> scalar ) {
44- if (!scalar .isValid ()) {
45- this .value = null ;
46- return ;
47- }
48-
49- this .set (scalar .get ());
50- return ;
51- }
52-
31+ public void setValue (Object value ) throws ValidationException {
5332 if (value instanceof byte [] bytes ) {
5433 this .value = bytes ;
5534 return ;
@@ -61,18 +40,13 @@ public void set(Object value) throws ValidationException {
6140 }
6241
6342 if (value instanceof char [] chars ) {
64- this .value = Base64 .decodeBase64 (new String (chars ));
43+ this .value = Base64 .decodeBase64 (new java . lang . String (chars ));
6544 return ;
6645 }
6746
6847 throw new ValidationException (ValidationException .NO_CONVERSION_AVAILABLE , this .dataType (), value );
6948 }
7049
71- @ Override
72- public byte [] get () {
73- return this .value ;
74- }
75-
7650 @ Override
7751 public boolean equals (Object other ) {
7852 if (other instanceof Binary o ) {
@@ -83,4 +57,20 @@ public boolean equals(Object other) {
8357 }
8458 return false ;
8559 }
60+
61+ public static class LargeBinary extends Binary {
62+
63+ public LargeBinary () {
64+ super ();
65+ }
66+
67+ public LargeBinary (Object value ) throws ValidationException {
68+ super (value );
69+ }
70+
71+ @ Override
72+ public ArrowType dataType () {
73+ return ArrowType .LargeBinary .INSTANCE ;
74+ }
75+ }
8676}
0 commit comments