1
2
3
4
5
6
7
8
9
10
11 package org.eclipse.jgit.errors;
12
13 import java.text.MessageFormat;
14
15 import org.eclipse.jgit.internal.JGitText;
16 import org.eclipse.jgit.lib.AnyObjectId;
17 import org.eclipse.jgit.lib.ObjectId;
18
19
20
21
22 public class LargeObjectException extends RuntimeException {
23 private static final long serialVersionUID = 1L;
24
25 private ObjectId objectId;
26
27
28
29
30 public LargeObjectException() {
31
32 }
33
34
35
36
37
38
39
40
41 public LargeObjectException(Throwable cause) {
42 initCause(cause);
43 }
44
45
46
47
48
49
50
51
52 public LargeObjectException(AnyObjectId id) {
53 setObjectId(id);
54 }
55
56
57
58
59
60
61 public ObjectId getObjectId() {
62 return objectId;
63 }
64
65
66
67
68
69
70 protected String getObjectName() {
71 if (getObjectId() != null)
72 return getObjectId().name();
73 return JGitText.get().unknownObject;
74 }
75
76
77
78
79
80
81
82 public void setObjectId(AnyObjectId id) {
83 if (objectId == null)
84 objectId = id.copy();
85 }
86
87
88 @Override
89 public String getMessage() {
90 return MessageFormat.format(JGitText.get().largeObjectException,
91 getObjectName());
92 }
93
94
95 public static class OutOfMemory extends LargeObjectException {
96 private static final long serialVersionUID = 1L;
97
98
99
100
101
102
103
104 public OutOfMemory(OutOfMemoryError cause) {
105 initCause(cause);
106 }
107
108 @Override
109 public String getMessage() {
110 return MessageFormat.format(JGitText.get().largeObjectOutOfMemory,
111 getObjectName());
112 }
113 }
114
115
116 public static class ExceedsByteArrayLimit extends LargeObjectException {
117 private static final long serialVersionUID = 1L;
118
119 @Override
120 public String getMessage() {
121 return MessageFormat
122 .format(JGitText.get().largeObjectExceedsByteArray,
123 getObjectName());
124 }
125 }
126
127
128 public static class ExceedsLimit extends LargeObjectException {
129 private static final long serialVersionUID = 1L;
130
131 private final long limit;
132
133 private final long size;
134
135
136
137
138
139
140
141
142
143 public ExceedsLimit(long limit, long size) {
144 this.limit = limit;
145 this.size = size;
146 }
147
148 @Override
149 public String getMessage() {
150 return MessageFormat.format(JGitText.get().largeObjectExceedsLimit,
151 getObjectName(), Long.valueOf(limit), Long.valueOf(size));
152 }
153 }
154 }