1 package org
.spearce
.jgit
.lib
;
3 import java
.io
.BufferedReader
;
4 import java
.io
.IOException
;
5 import java
.io
.InputStream
;
6 import java
.io
.InputStreamReader
;
7 import java
.io
.UnsupportedEncodingException
;
8 import java
.util
.zip
.InflaterInputStream
;
10 public class ObjectReader
{
11 private final ObjectId objectId
;
13 private final String objectType
;
15 private final int objectSize
;
17 private InflaterInputStream inflater
;
19 public ObjectReader(final ObjectId id
, final InputStream src
)
22 inflater
= new InflaterInputStream(src
);
24 final StringBuffer tempType
= new StringBuffer(16);
33 if (c
< 'a' || c
> 'z') {
34 throw new CorruptObjectException("Corrupt header in "
37 if (tempType
.length() >= 16) {
38 throw new CorruptObjectException("Type header exceed limit in "
41 tempType
.append((char) c
);
43 objectType
= tempType
.toString();
50 if (c
< '0' || c
> '9') {
51 throw new CorruptObjectException("Corrupt header in "
57 objectSize
= tempSize
;
60 public ObjectId
getId() {
64 public String
getType() {
68 public int getSize() {
72 public BufferedReader
getBufferedReader()
73 throws UnsupportedEncodingException
{
74 return new BufferedReader(new InputStreamReader(inflater
, "UTF-8"));
77 public InputStream
getInputStream() {
81 public void close() throws IOException
{