content: // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
  // SPDX-License-Identifier: Apache-2.0
  package com.amazon.ion.impl.lite;
  
  import com.amazon.ion.IonBlob;
  import com.amazon.ion.IonType;
  import com.amazon.ion.IonWriter;
  import com.amazon.ion.ValueVisitor;
  import com.amazon.ion.impl._Private_Utils;
  import java.io.IOException;
  import java.io.InputStream;
  
  
  final class IonBlobLite
      extends IonLobLite
      implements IonBlob
  {
      private static final int HASH_SIGNATURE =
          IonType.BLOB.toString().hashCode();
  
      /**
       * Constructs a <code>null.blob</code> element.
       */
      IonBlobLite(ContainerlessContext context, boolean isNull)
      {
          super(context, isNull);
      }
  
      IonBlobLite(IonBlobLite existing, IonContext context)
      {
          super(existing, context);
      }
  
      @Override
      IonValueLite shallowClone(IonContext context)
      {
          return new IonBlobLite(this, context);
      }
  
      @Override
      public IonBlobLite clone()
      {
          return (IonBlobLite) shallowClone(ContainerlessContext.wrap(getSystem()));
      }
  
      @Override
      int hashSignature() {
          return HASH_SIGNATURE;
      }
  
      @Override
      int scalarHashCode() {
          return lobHashCode(HASH_SIGNATURE);
      }
  
      @Override
      public IonType getTypeSlow()
      {
          return IonType.BLOB;
      }
  
  
      public void printBase64(Appendable out)
          throws IOException
      {
          validateThisNotNull();
          InputStream byteStream = newInputStream();
          try
          {
              _Private_Utils.writeAsBase64(byteStream, out);
          }
          finally
          {
              byteStream.close();
          }
      }
  
      @Override
      final void writeBodyTo(IonWriter writer, SymbolTableProvider symbolTableProvider)
          throws IOException
      {
          writer.writeBlob(getBytesNoCopy());
      }
  
      @Override
      public void accept(ValueVisitor visitor) throws Exception
      {
          visitor.visit(this);
      }
  }
  