-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added alias support, ability to get provider by filename/-extension
- Loading branch information
Showing
14 changed files
with
153 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
* eol=lf | ||
*.bat eol=crlf | ||
*.png binary | ||
*.zip binary | ||
*.tgz binary | ||
*.tar binary | ||
*.bz2 binary | ||
*.gz binary |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,13 @@ | ||
.* | ||
!.github | ||
!.gitignore | ||
!.gitattributes | ||
!.mvn | ||
*.bak | ||
*.log | ||
*.diff | ||
*.patch | ||
*.iml | ||
target | ||
eclipse-target | ||
war | ||
war |
17 changes: 17 additions & 0 deletions
17
core/src/main/java/io/github/mmm/marshall/AbstractStructuredFormatProvider.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
/* Copyright (c) The m-m-m Team, Licensed under the Apache License, Version 2.0 | ||
* http://www.apache.org/licenses/LICENSE-2.0 */ | ||
package io.github.mmm.marshall; | ||
|
||
/** | ||
* Abstract base implementation of {@link StructuredFormatProvider}. | ||
*/ | ||
public abstract class AbstractStructuredFormatProvider implements StructuredFormatProvider { | ||
|
||
/** | ||
* @return an array of aliases of this provider. | ||
* @see #getId() | ||
* @see StructuredFormatFactory#getProvider(String) | ||
*/ | ||
public abstract String[] getAliases(); | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
core/src/main/java/io/github/mmm/marshall/StructuredFormatHelper.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
/* Copyright (c) The m-m-m Team, Licensed under the Apache License, Version 2.0 | ||
* http://www.apache.org/licenses/LICENSE-2.0 */ | ||
package io.github.mmm.marshall; | ||
|
||
import java.nio.file.Path; | ||
|
||
/** | ||
* Helper to {@link #getProvider(Path) get} a {@link StructuredFormatProvider} from a {@link Path} or its filename. | ||
* | ||
* @since 1.0.0 | ||
*/ | ||
public interface StructuredFormatHelper { | ||
|
||
/** | ||
* @param path the {@link Path} pointing to a file where to store {@link StructuredFormat} payload (a marshalled | ||
* object). | ||
* @return the {@link StructuredFormatProvider} determined from the file extension. | ||
*/ | ||
static StructuredFormatProvider getProvider(Path path) { | ||
|
||
return getProvider(path.getFileName().toString()); | ||
} | ||
|
||
/** | ||
* | ||
* @param filename the {@link Path#getFileName() file name} as {@link String}. | ||
* @return the {@link StructuredFormatProvider} determined from the file extension. | ||
*/ | ||
static StructuredFormatProvider getProvider(String filename) { | ||
|
||
int lastDot = filename.lastIndexOf('.'); | ||
String id = filename; | ||
if (lastDot >= 0) { | ||
id = filename.substring(lastDot + 1); // extension | ||
} | ||
return StructuredFormatFactory.get().getProvider(id); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters