| OLD | NEW |
| 1 // Protocol Buffers - Google's data interchange format | 1 // Protocol Buffers - Google's data interchange format |
| 2 // Copyright 2008 Google Inc. All rights reserved. | 2 // Copyright 2008 Google Inc. All rights reserved. |
| 3 // https://developers.google.com/protocol-buffers/ | 3 // https://developers.google.com/protocol-buffers/ |
| 4 // | 4 // |
| 5 // Redistribution and use in source and binary forms, with or without | 5 // Redistribution and use in source and binary forms, with or without |
| 6 // modification, are permitted provided that the following conditions are | 6 // modification, are permitted provided that the following conditions are |
| 7 // met: | 7 // met: |
| 8 // | 8 // |
| 9 // * Redistributions of source code must retain the above copyright | 9 // * Redistributions of source code must retain the above copyright |
| 10 // notice, this list of conditions and the following disclaimer. | 10 // notice, this list of conditions and the following disclaimer. |
| (...skipping 21 matching lines...) Expand all Loading... |
| 32 | 32 |
| 33 import java.io.InputStream; | 33 import java.io.InputStream; |
| 34 | 34 |
| 35 /** | 35 /** |
| 36 * Abstract interface for parsing Protocol Messages. | 36 * Abstract interface for parsing Protocol Messages. |
| 37 * | 37 * |
| 38 * The implementation should be stateless and thread-safe. | 38 * The implementation should be stateless and thread-safe. |
| 39 * | 39 * |
| 40 * <p>All methods may throw {@link InvalidProtocolBufferException}. In the event
of invalid data, | 40 * <p>All methods may throw {@link InvalidProtocolBufferException}. In the event
of invalid data, |
| 41 * like an encoding error, the cause of the thrown exception will be {@code null
}. However, if an | 41 * like an encoding error, the cause of the thrown exception will be {@code null
}. However, if an |
| 42 * I/O problem occurs, an exception is thrown with an {@link java.io.IOException
} cause. | 42 * I/O problem occurs, an exception is thrown with an {@link IOException} cause. |
| 43 * | 43 * |
| 44 * @author liujisi@google.com (Pherl Liu) | 44 * @author liujisi@google.com (Pherl Liu) |
| 45 */ | 45 */ |
| 46 public interface Parser<MessageType> { | 46 public interface Parser<MessageType> { |
| 47 | 47 |
| 48 // NB(jh): Other parts of the protobuf API that parse messages distinguish bet
ween an I/O problem | 48 // NB(jh): Other parts of the protobuf API that parse messages distinguish bet
ween an I/O problem |
| 49 // (like failure reading bytes from a socket) and invalid data (encoding error
) via the type of | 49 // (like failure reading bytes from a socket) and invalid data (encoding error
) via the type of |
| 50 // thrown exception. But it would be source-incompatible to make the methods i
n this interface do | 50 // thrown exception. But it would be source-incompatible to make the methods i
n this interface do |
| 51 // so since they were originally spec'ed to only throw InvalidProtocolBufferEx
ception. So callers | 51 // so since they were originally spec'ed to only throw InvalidProtocolBufferEx
ception. So callers |
| 52 // must inspect the cause of the exception to distinguish these two cases. | 52 // must inspect the cause of the exception to distinguish these two cases. |
| (...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 263 /** | 263 /** |
| 264 * Like {@link #parseDelimitedFrom(InputStream, ExtensionRegistryLite)}, | 264 * Like {@link #parseDelimitedFrom(InputStream, ExtensionRegistryLite)}, |
| 265 * but does not throw an exception if the message is missing required fields. | 265 * but does not throw an exception if the message is missing required fields. |
| 266 * Instead, a partial message is returned. | 266 * Instead, a partial message is returned. |
| 267 */ | 267 */ |
| 268 public MessageType parsePartialDelimitedFrom( | 268 public MessageType parsePartialDelimitedFrom( |
| 269 InputStream input, | 269 InputStream input, |
| 270 ExtensionRegistryLite extensionRegistry) | 270 ExtensionRegistryLite extensionRegistry) |
| 271 throws InvalidProtocolBufferException; | 271 throws InvalidProtocolBufferException; |
| 272 } | 272 } |
| OLD | NEW |