< prev index next >

src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/dv/util/Base64.java

Print this page


   1 /*
   2  * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
   3  * @LastModified: Nov 2017
   4  */
   5 /*
   6  * Licensed to the Apache Software Foundation (ASF) under one or more
   7  * contributor license agreements.  See the NOTICE file distributed with
   8  * this work for additional information regarding copyright ownership.
   9  * The ASF licenses this file to You under the Apache License, Version 2.0
  10  * (the "License"); you may not use this file except in compliance with
  11  * the License.  You may obtain a copy of the License at
  12  *
  13  *      http://www.apache.org/licenses/LICENSE-2.0
  14  *
  15  * Unless required by applicable law or agreed to in writing, software
  16  * distributed under the License is distributed on an "AS IS" BASIS,
  17  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  18  * See the License for the specific language governing permissions and
  19  * limitations under the License.
  20  */
  21 
  22 package com.sun.org.apache.xerces.internal.impl.dv.util;
  23 
  24 /**
  25  * This class provides encode/decode for RFC 2045 Base64 as
  26  * defined by RFC 2045, N. Freed and N. Borenstein.
  27  * RFC 2045: Multipurpose Internet Mail Extensions (MIME)
  28  * Part One: Format of Internet Message Bodies. Reference
  29  * 1996 Available at: http://www.ietf.org/rfc/rfc2045.txt
  30  * This class is used by XML Schema binary format validation
  31  *
  32  * This implementation does not encode/decode streaming
  33  * data. You need the data that you will encode/decode
  34  * already on a byte arrray.
  35  *
  36  * @xerces.internal
  37  *
  38  * @author Jeffrey Rodriguez
  39  * @author Sandy Gao

  40  */
  41 public final class  Base64 {
  42 
  43     static private final int  BASELENGTH         = 128;
  44     static private final int  LOOKUPLENGTH       = 64;
  45     static private final int  TWENTYFOURBITGROUP = 24;
  46     static private final int  EIGHTBIT           = 8;
  47     static private final int  SIXTEENBIT         = 16;
  48     static private final int  SIXBIT             = 6;
  49     static private final int  FOURBYTE           = 4;
  50     static private final int  SIGN               = -128;
  51     static private final char PAD                = '=';
  52     static private final boolean fDebug          = false;
  53     static final private byte [] base64Alphabet        = new byte[BASELENGTH];
  54     static final private char [] lookUpBase64Alphabet  = new char[LOOKUPLENGTH];
  55 
  56     static {
  57 
  58         for (int i = 0; i < BASELENGTH; ++i) {
  59             base64Alphabet[i] = -1;


   1 /*
   2  * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.

   3  */
   4 /*
   5  * Licensed to the Apache Software Foundation (ASF) under one or more
   6  * contributor license agreements.  See the NOTICE file distributed with
   7  * this work for additional information regarding copyright ownership.
   8  * The ASF licenses this file to You under the Apache License, Version 2.0
   9  * (the "License"); you may not use this file except in compliance with
  10  * the License.  You may obtain a copy of the License at
  11  *
  12  *      http://www.apache.org/licenses/LICENSE-2.0
  13  *
  14  * Unless required by applicable law or agreed to in writing, software
  15  * distributed under the License is distributed on an "AS IS" BASIS,
  16  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  17  * See the License for the specific language governing permissions and
  18  * limitations under the License.
  19  */
  20 
  21 package com.sun.org.apache.xerces.internal.impl.dv.util;
  22 
  23 /**
  24  * This class provides encode/decode for RFC 2045 Base64 as
  25  * defined by RFC 2045, N. Freed and N. Borenstein.
  26  * RFC 2045: Multipurpose Internet Mail Extensions (MIME)
  27  * Part One: Format of Internet Message Bodies. Reference
  28  * 1996 Available at: http://www.ietf.org/rfc/rfc2045.txt
  29  * This class is used by XML Schema binary format validation
  30  *
  31  * This implementation does not encode/decode streaming
  32  * data. You need the data that you will encode/decode
  33  * already on a byte arrray.
  34  *
  35  * @xerces.internal
  36  *
  37  * @author Jeffrey Rodriguez
  38  * @author Sandy Gao
  39  * @LastModified: Nov 2017
  40  */
  41 public final class  Base64 {
  42 
  43     static private final int  BASELENGTH         = 128;
  44     static private final int  LOOKUPLENGTH       = 64;
  45     static private final int  TWENTYFOURBITGROUP = 24;
  46     static private final int  EIGHTBIT           = 8;
  47     static private final int  SIXTEENBIT         = 16;
  48     static private final int  SIXBIT             = 6;
  49     static private final int  FOURBYTE           = 4;
  50     static private final int  SIGN               = -128;
  51     static private final char PAD                = '=';
  52     static private final boolean fDebug          = false;
  53     static final private byte [] base64Alphabet        = new byte[BASELENGTH];
  54     static final private char [] lookUpBase64Alphabet  = new char[LOOKUPLENGTH];
  55 
  56     static {
  57 
  58         for (int i = 0; i < BASELENGTH; ++i) {
  59             base64Alphabet[i] = -1;


< prev index next >