-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Tables implementation work by rpaquay #7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
6a25ef7
cfb7c93
bbcee3e
9432fac
f481f38
28a3cec
b3fc550
6696e2c
9cede50
b9a00d4
a4f49b0
bf53b9c
a72bc2a
711e23d
06146b7
8fdbcf7
3f5f5d7
802e9b0
34de8fe
18c8255
04cc644
87ebda2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,59 @@ | ||
| /** | ||
| * Copyright 2011 Microsoft Corporation | ||
| * | ||
| * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| * you may not use this file except in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
| package com.microsoft.windowsazure.services.blob.implementation; | ||
|
|
||
| import java.text.DateFormat; | ||
| import java.text.ParseException; | ||
| import java.text.SimpleDateFormat; | ||
| import java.util.Date; | ||
| import java.util.Locale; | ||
| import java.util.TimeZone; | ||
|
|
||
| /* | ||
| * "not quite" ISO 8601 date time conversion routines | ||
| */ | ||
| public class ISO8601DateConverter { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is used by both blob and table, so can it move to the utils package?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Inside the .implementation. packages I wouldn't worry about that - services can cross-reference implementation as needed and it's not a namespace used directly by user code. Plus it can be a bit of a challenge to read into exactly what the separation of concern structure of the .utils. packages is at the moment. If we want to refactor where things live it should probably be done holistically. I'd be afraid moving individual implementation class that are used by another service would only add to the confusion.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ok, sounds good. |
||
| // Note: because of the trailing "0000000", this is not quite ISO 8601 compatible | ||
| private static final String DATETIME_PATTERN = "yyyy-MM-dd'T'HH:mm:ss.SSSSSSS'Z'"; | ||
| private static final String SHORT_DATETIME_PATTERN = "yyyy-MM-dd'T'HH:mm:ss'Z'"; | ||
|
|
||
| public String format(Date date) { | ||
| return getFormat().format(date); | ||
| } | ||
|
|
||
| public Date parse(String date) throws ParseException { | ||
| if (date == null) | ||
| return null; | ||
|
|
||
| // Sometimes, the date comes back without the ".SSSSSSS" part (presumably when the decimal value | ||
| // of the date is "0". Use the short format in that case. | ||
| if (date.indexOf('.') < 0) | ||
| return getShortFormat().parse(date); | ||
| else | ||
| return getFormat().parse(date); | ||
| } | ||
|
|
||
| private DateFormat getFormat() { | ||
| DateFormat iso8601Format = new SimpleDateFormat(DATETIME_PATTERN, Locale.US); | ||
| iso8601Format.setTimeZone(TimeZone.getTimeZone("GMT")); | ||
| return iso8601Format; | ||
| } | ||
|
|
||
| private DateFormat getShortFormat() { | ||
| DateFormat iso8601Format = new SimpleDateFormat(SHORT_DATETIME_PATTERN, Locale.US); | ||
| iso8601Format.setTimeZone(TimeZone.getTimeZone("GMT")); | ||
| return iso8601Format; | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,47 @@ | ||
| package com.microsoft.windowsazure.services.core.utils; | ||
|
|
||
| import java.util.List; | ||
|
|
||
| public class CommaStringBuilder { | ||
| private final StringBuilder sb = new StringBuilder(); | ||
|
|
||
| public void add(String representation) { | ||
| if (sb.length() > 0) { | ||
| sb.append(","); | ||
| } | ||
| sb.append(representation); | ||
| } | ||
|
|
||
| public void addValue(boolean value, String representation) { | ||
| if (value) { | ||
| add(representation); | ||
| } | ||
| } | ||
|
|
||
| public static String join(List<String> values) { | ||
| CommaStringBuilder sb = new CommaStringBuilder(); | ||
|
|
||
| for (String value : values) { | ||
| sb.add(value); | ||
| } | ||
|
|
||
| return sb.toString(); | ||
| } | ||
|
|
||
| public static String join(String... values) { | ||
| CommaStringBuilder sb = new CommaStringBuilder(); | ||
|
|
||
| for (String value : values) { | ||
| sb.add(value); | ||
| } | ||
|
|
||
| return sb.toString(); | ||
| } | ||
|
|
||
| @Override | ||
| public String toString() { | ||
| if (sb.length() == 0) | ||
| return null; | ||
| return sb.toString(); | ||
| } | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this needed? If so, then we need to update the list of prereqs also.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like it is needed. As I understand it, the table batch operations use MIME encoding to envelope multiple requests and responses in an http operation. The multi-part support in the javax.mail library is used to support this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK.