Skip to content

Commit 4bd4824

Browse files
author
Stephane Landelle
committed
Minor clean up
1 parent 4ecc87f commit 4bd4824

File tree

2 files changed

+37
-40
lines changed

2 files changed

+37
-40
lines changed

api/src/main/java/org/asynchttpclient/multipart/Part.java

Lines changed: 11 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ public abstract class Part {
4444
* form-data as a byte array
4545
*/
4646
public static final byte[] FORM_DATA_DISPOSITION_TYPE_BYTES = "form-data".getBytes(StandardCharsets.US_ASCII);
47-
47+
4848
/**
4949
* name as a byte array
5050
*/
@@ -105,6 +105,13 @@ public abstract class Part {
105105
*/
106106
public abstract String getContentId();
107107

108+
/**
109+
* Gets the disposition-type to be used in Content-Disposition header
110+
*
111+
* @return the disposition-type
112+
*/
113+
public abstract String getDispositionType();
114+
108115
/**
109116
* Tests if this part can be sent more than once.
110117
*
@@ -115,30 +122,18 @@ public boolean isRepeatable() {
115122
return true;
116123
}
117124

118-
private String dispositionType;
119-
/**
120-
* Gets the disposition-type to be used in Content-Disposition header
121-
*
122-
* @return the disposition-type
123-
*/
124-
public String getDispositionType() {
125-
return dispositionType;
126-
}
127-
128-
public void setDispositionType(String dispositionType) {
129-
this.dispositionType = dispositionType;
130-
}
131-
132125
protected void visitStart(PartVisitor visitor, byte[] boundary) throws IOException {
133126
visitor.withBytes(EXTRA_BYTES);
134127
visitor.withBytes(boundary);
135128
}
136129

137130
protected void visitDispositionHeader(PartVisitor visitor) throws IOException {
131+
138132
if (getName() != null) {
139133
visitor.withBytes(CRLF_BYTES);
140134
visitor.withBytes(CONTENT_DISPOSITION_BYTES);
141-
visitor.withBytes(dispositionType != null? dispositionType.getBytes(StandardCharsets.US_ASCII): FORM_DATA_DISPOSITION_TYPE_BYTES);
135+
visitor.withBytes(getDispositionType() != null ? getDispositionType().getBytes(StandardCharsets.US_ASCII)
136+
: FORM_DATA_DISPOSITION_TYPE_BYTES);
142137
visitor.withBytes(NAME_BYTES);
143138
visitor.withBytes(QUOTE_BYTES);
144139
visitor.withBytes(getName().getBytes(StandardCharsets.US_ASCII));

api/src/main/java/org/asynchttpclient/multipart/PartBase.java

Lines changed: 26 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -15,27 +15,35 @@
1515
public abstract class PartBase extends Part {
1616

1717
/**
18-
* Name of the file part.
18+
* The name of the form field, part of the Content-Disposition header
1919
*/
2020
private final String name;
2121

2222
/**
23-
* Content type of the file part.
23+
* The main part of the Content-Type header
2424
*/
2525
private final String contentType;
2626

2727
/**
28-
* Content encoding of the file part.
28+
* The charset (part of Content-Type header)
2929
*/
3030
private final String charSet;
3131

3232
/**
33-
* The transfer encoding.
33+
* The Content-Transfer-Encoding header value.
3434
*/
3535
private final String transferEncoding;
3636

37+
/**
38+
* The Content-Id
39+
*/
3740
private final String contentId;
3841

42+
/**
43+
* The disposition type (part of Content-Disposition)
44+
*/
45+
private String dispositionType;
46+
3947
/**
4048
* Constructor.
4149
*
@@ -57,43 +65,37 @@ public PartBase(String name, String contentType, String charSet, String transfer
5765
this.contentId = contentId;
5866
}
5967

60-
/**
61-
* Returns the name.
62-
*
63-
* @return The name.
64-
*/
68+
@Override
6569
public String getName() {
6670
return this.name;
6771
}
6872

69-
/**
70-
* Returns the content type of this part.
71-
*
72-
* @return String The name.
73-
*/
73+
@Override
7474
public String getContentType() {
7575
return this.contentType;
7676
}
7777

78-
/**
79-
* Return the character encoding of this part.
80-
*
81-
* @return String The name.
82-
*/
78+
@Override
8379
public String getCharSet() {
8480
return this.charSet;
8581
}
8682

87-
/**
88-
* Returns the transfer encoding of this part.
89-
*
90-
* @return String The name.
91-
*/
83+
@Override
9284
public String getTransferEncoding() {
9385
return transferEncoding;
9486
}
9587

88+
@Override
9689
public String getContentId() {
9790
return contentId;
9891
}
92+
93+
@Override
94+
public String getDispositionType() {
95+
return dispositionType;
96+
}
97+
98+
public void setDispositionType(String dispositionType) {
99+
this.dispositionType = dispositionType;
100+
}
99101
}

0 commit comments

Comments
 (0)