Default implementation for {@link Streamable}.

<p>Subclasses can simply add {@code implements Streamable} if they have an implementation in
Sanitizers.<name>Streaming. If they don't, this method will throw while trying to find it.
1122
public final AppendableAndOptions applyForJbcSrcStreaming(
      JbcSrcPluginContext context, Expression delegateAppendable, List<SoyExpression> args) {
    MethodRef sanitizerMethod = javaStreamingSanitizer;
    if (sanitizerMethod == null) {
      // lazily allocated
      sanitizerMethod =
          MethodRef.create(
                  Sanitizers.class,
                  name.substring(1) + "Streaming",
                  LoggingAdvisingAppendable.class)
              .asNonNullable();
      javaStreamingSanitizer = sanitizerMethod;
    }
    Expression streamingSanitizersExpr = sanitizerMethod.invoke(delegateAppendable);
    if (isCloseable()) {
      return AppendableAndOptions.createCloseable(streamingSanitizersExpr);
    } else {
      return AppendableAndOptions.create(streamingSanitizersExpr);
    }
  }
11824
@Override
	protected ProcessingItem addInputStream(Stream inputStream, PartitioningScheme scheme) {
		SamzaSystemStream stream = ((SamzaStream) inputStream).addDestination(new StreamDestination(this,this.getParallelism(),scheme));
		this.inputStreams.add(stream);
		return this;
	}
764442
protected void addSerializableClass(Class<?> serializable) {
        safeMapper.addMixIn(serializable, UseToStringAsValueMixIn.class);
        fullMapper.addMixIn(serializable, UseToStringAsValueMixIn.class);
    }
1321930
@Override
    public T addClass(Class<?> clazz) throws IllegalArgumentException {
        Validate.notNull(clazz, "Clazz must be specified");

        return addClasses(clazz);
    }
937014
@Override
    public I importFrom(final InputStream stream, Filter<ArchivePath> filter) throws ArchiveImportException {
        Validate.notNull(stream, "Stream must be specified");
        Validate.notNull(filter, "Filter must be specified");
        final S tarStream;
        try {
            tarStream = this.getInputStreamForRawStream(stream);
        } catch (final RuntimeException re) {
            throw new ArchiveImportException("Could not wrap raw input with TAR stream", re);
        } catch (final IOException e) {
            throw new ArchiveImportException("Could not wrap raw input with TAR stream", e);
        }
        return this.importFrom(tarStream, filter);
    }
1089156
public static byte[] toByteArray(Streamable streamable) {
        try {
            final ByteArrayOutputStream baos = new ByteArrayOutputStream(streamable.size());
            final DataOutputStream dos = new DataOutputStream(baos);
            streamable.write(dos);
            dos.flush();
            baos.close();
            return baos.toByteArray();
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }
1144018
@Override
    public void processClass (File source, Class<?> service)
        throws Exception
    {
        System.out.println("Processing " + service.getName() + "...");

        // verify that the service class name is as we expect it to be
        if (!service.getName().endsWith("Service")) {
            System.err.println("Cannot process '" + service.getName() + "':");
            System.err.println("Service classes must be named SomethingService.");
            return;
        }

        ServiceDescription desc = new ServiceDescription(service);
        generateMarshaller(source, desc);
        // generateDispatcher(source, desc); // dispatchers are no longer needed
        if (!_providerless.contains(service.getSimpleName())) {
            generateProvider(source, desc);
        }
    }
1335759
protected static Streamer create (Class<?> target)
        throws IOException
    {
        // validate that the class is really streamable
        boolean isInner = false, isStatic = Modifier.isStatic(target.getModifiers());
        try {
            isInner = (target.getDeclaringClass() != null);
        } catch (Throwable t) {
            log.warning("Failure checking innerness of class",
                "class", target.getName(), "error", t);
        }
        if (isInner && !isStatic) {
            throw new IllegalArgumentException(
                "Cannot stream non-static inner class: " + target.getName());
        }

        // create streamers for array types
        if (target.isArray()) {
            Class<?> componentType = target.getComponentType();
            if (Modifier.isFinal(componentType.getModifiers())) {
                Streamer delegate = Streamer.getStreamer(componentType);
                if (delegate != null) {
                    return new FinalArrayStreamer(componentType, delegate);
                } // else: error, below

            } else if (isStreamable(componentType)) {
                return new ArrayStreamer(componentType);
            }
            String errmsg = "Aiya! Streamer created for array type but we have no registered " +
                "streamer for the element type [type=" + target.getName() + "]";
            throw new RuntimeException(errmsg);
        }

        // create streamers for enum types
        if (target.isEnum()) {
            switch (ENUM_POLICY) {
            case NAME_WITH_BYTE_ENUM:
            case ORDINAL_WITH_BYTE_ENUM:
                if (ByteEnum.class.isAssignableFrom(target)) {
                    return new ByteEnumStreamer(target);
                }
                break;

            default:
                // we do not care if it is a ByteEnum, we move on...
                break;
            }

            switch (ENUM_POLICY) {
            case NAME_WITH_BYTE_ENUM:
            case NAME:
                return new NameEnumStreamer(target);

            default:
                List<?> universe = ImmutableList.copyOf(target.getEnumConstants());
                int maxOrdinal = universe.size() - 1;
                if (maxOrdinal <= Byte.MAX_VALUE) {
                    return new ByteOrdEnumStreamer(target, universe);

                } else if (maxOrdinal <= Short.MAX_VALUE) {
                    return new ShortOrdEnumStreamer(target, universe);

                } else {
                    return new IntOrdEnumStreamer(target, universe);
                }
            }
        }

        // create Streamers for other types
        Method reader = null;
        Method writer = null;
        try {
            reader = target.getMethod(READER_METHOD_NAME, READER_ARGS);
        } catch (NoSuchMethodException nsme) {
            // nothing to worry about, we just don't have one
        }
        try {
            writer = target.getMethod(WRITER_METHOD_NAME, WRITER_ARGS);
        } catch (NoSuchMethodException nsme) {
            // nothing to worry about, we just don't have one
        }

        // if there is no reader and no writer, we can do a simpler thing
        if ((reader == null) && (writer == null)) {
            return new ClassStreamer(target);
        } else {
            return new CustomClassStreamer(target, reader, writer);
        }
    }
1360723
@Override
  public StreamImpl stream()
    throws IOException
  {
    if (_streamImpl == null) {
      _streamImpl = new SocketStream();
    }

    _streamImpl.init(_s);

    return _streamImpl;
  }
240451
public static void registerInputStreamHandler(MimeType type, InputStreamHandler handler) {
        $.requireNotNull(handler);
        InputStreamHandlerDispatcher dispatcher = inputStreamHandlerLookup.get(type);
        if (null == dispatcher) {
            dispatcher = new InputStreamHandlerDispatcher(handler);
            inputStreamHandlerLookup.put(type, dispatcher);
        } else {
            dispatcher.add(handler);
        }
    }
1350904
private boolean isStreamPresentAndWritable(int streamId) {
        final Http2Stream stream = encoder.connection().stream(streamId);
        if (stream == null) {
            return false;
        }

        switch (stream.state()) {
            case RESERVED_LOCAL:
            case OPEN:
            case HALF_CLOSED_REMOTE:
                return true;
            default:
                // The response has been sent already.
                return false;
        }
    }
496226
public static void stream(final Readable readable, final HspListener listener) throws IOException {
        checkNotNull(readable);
        checkNotNull(listener);

        HspLineProcessor lineProcessor = new HspLineProcessor(listener);
        CharStreams.readLines(readable, lineProcessor);
    }
1367581
protected BufferedInputStream buffer(final InputStream inputStream) {
        // reject null early on rather than waiting for IO operation to fail
        if (inputStream == null) { // not checked by BufferedInputStream
            throw new NullPointerException("inputStream == null");
        }
        return inputStream instanceof BufferedInputStream ? (BufferedInputStream) inputStream
                : new BufferedInputStream(inputStream);
    }
562353
public void init(InputStream is)
    {
        _is = is;
        _method = null;
        _isLastChunk = true;
        _chunkLength = 0;
        _peek = -1;
        _refs = null;
        _replyFault = null;

        if (_serializerFactory == null)
            _serializerFactory = new SerializerFactory();
    }
379776
@Override
    public <X> EmbeddableType<X> embeddable(Class<X> paramClass)
    {
        EmbeddableType embeddableType = (EmbeddableType) embeddables.get(paramClass);
        if (embeddableType == null)
        {
            throw new IllegalArgumentException("Not a embeddable type, {class: " + paramClass + "}");
        }

        return embeddableType;
    }
1337492
private OutputStream initializeSource()
    {
    try
      {
      PipedOutputStream pipeOut = new PipedOutputStream();
      PipedInputStream pipeIn = new PipedInputStream( pipeOut);

      filterInput_ = pipeIn;
      return new FilterSourceStream( pipeOut);
      }
    catch( Exception e)
      {
      throw new RuntimeException( "Can't initialize source stream", e);
      }
    }
1219707
private void addFileStreamEntries(String kind) {
        Obligation obligation = database.getFactory().addObligation("java.io." + kind);
        database.addEntry(new MatchMethodEntry(new SubtypeTypeMatcher(BCELUtil.getObjectTypeInstance(Values.DOTTED_JAVA_IO_FILE + kind)),
                new ExactStringMatcher("<init>"), new RegexStringMatcher(".*"), false, ObligationPolicyDatabaseActionType.ADD,
                ObligationPolicyDatabaseEntryType.STRONG, obligation));
        database.addEntry(new MatchMethodEntry(new SubtypeTypeMatcher(BCELUtil.getObjectTypeInstance("java.io." + kind)),
                new ExactStringMatcher("close"), new ExactStringMatcher("()V"), false, ObligationPolicyDatabaseActionType.DEL,
                ObligationPolicyDatabaseEntryType.STRONG, obligation));
    }