001 /**
002 * Licensed to the Apache Software Foundation (ASF) under one or more
003 * contributor license agreements. See the NOTICE file distributed with
004 * this work for additional information regarding copyright ownership.
005 * The ASF licenses this file to You under the Apache License, Version 2.0
006 * (the "License"); you may not use this file except in compliance with
007 * the License. You may obtain a copy of the License at
008 *
009 * http://www.apache.org/licenses/LICENSE-2.0
010 *
011 * Unless required by applicable law or agreed to in writing, software
012 * distributed under the License is distributed on an "AS IS" BASIS,
013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014 * See the License for the specific language governing permissions and
015 * limitations under the License.
016 */
017 package org.fusesource.hawtbuf.proto;
018
019 import java.io.IOException;
020 import java.io.InputStream;
021 import java.io.OutputStream;
022
023 import org.fusesource.hawtbuf.Buffer;
024
025
026 public interface Message<T> {
027
028 public T clone() throws CloneNotSupportedException;
029
030 public int serializedSizeUnframed();
031
032 public int serializedSizeFramed();
033
034 public void clear();
035
036 public T assertInitialized() throws UninitializedMessageException;
037
038 public T mergeFrom(T other);
039
040
041 public T mergeUnframed(byte[] data) throws InvalidProtocolBufferException;
042
043 public T mergeFramed(byte[] data) throws InvalidProtocolBufferException;
044
045 public T mergeUnframed(Buffer buffer) throws InvalidProtocolBufferException;
046
047 public T mergeFramed(Buffer buffer) throws InvalidProtocolBufferException;
048
049 public T mergeUnframed(InputStream input) throws IOException;
050
051 public T mergeFramed(InputStream input) throws IOException;
052
053 public T mergeUnframed(CodedInputStream input) throws IOException;
054
055 public T mergeFramed(CodedInputStream input) throws IOException;
056
057
058 public Buffer toUnframedBuffer();
059
060 public Buffer toFramedBuffer();
061
062 public byte[] toUnframedByteArray();
063
064 public byte[] toFramedByteArray();
065
066 public void writeUnframed(CodedOutputStream output) throws java.io.IOException;
067
068 public void writeFramed(CodedOutputStream output) throws java.io.IOException;
069
070 public void writeUnframed(OutputStream output) throws IOException;
071
072 public void writeFramed(OutputStream output) throws java.io.IOException;
073
074
075 }