parent
b8405c23b8
commit
7bbbd7af0a
|
@ -30,10 +30,10 @@ package org.hl7.fhir.utilities;
|
|||
*/
|
||||
|
||||
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.hl7.fhir.exceptions.FHIRException;
|
||||
|
||||
import java.io.BufferedInputStream;
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileNotFoundException;
|
||||
|
@ -42,7 +42,6 @@ import java.io.FilenameFilter;
|
|||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.math.BigDecimal;
|
||||
import java.net.URLEncoder;
|
||||
import java.nio.channels.FileChannel;
|
||||
import java.nio.file.Paths;
|
||||
|
@ -50,27 +49,18 @@ import java.time.Duration;
|
|||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.hl7.fhir.exceptions.FHIRException;
|
||||
|
||||
import net.sf.saxon.TransformerFactoryImpl;
|
||||
|
||||
import static org.apache.commons.lang3.StringUtils.isBlank;
|
||||
|
||||
public class Utilities {
|
||||
|
||||
// private static final String TOKEN_REGEX = "^a-z[A-Za-z0-9]*$";
|
||||
|
||||
private static final String OID_REGEX = "[0-2](\\.(0|[1-9][0-9]*))+";
|
||||
|
||||
/**
|
||||
* Returns the plural form of the word in the string.
|
||||
*
|
||||
* <p>
|
||||
* Examples:
|
||||
*
|
||||
* <pre>
|
||||
|
@ -81,12 +71,11 @@ public class Utilities {
|
|||
* inflector.pluralize("the blue mailman") #=> "the blue mailmen"
|
||||
* inflector.pluralize("CamelOctopus") #=> "CamelOctopi"
|
||||
* </pre>
|
||||
*
|
||||
*
|
||||
*
|
||||
* <p>
|
||||
* <p>
|
||||
* <p>
|
||||
* Note that if the {@link Object#toString()} is called on the supplied object, so this method works for non-strings, too.
|
||||
*
|
||||
*
|
||||
* @param word the word that is to be pluralized.
|
||||
* @return the pluralized form of the word, or the word itself if it could not be pluralized
|
||||
* @see #singularize(Object)
|
||||
|
@ -285,8 +274,7 @@ public class Utilities {
|
|||
return b.toString();
|
||||
}
|
||||
|
||||
public static String capitalize(String s)
|
||||
{
|
||||
public static String capitalize(String s) {
|
||||
if (s == null) return null;
|
||||
if (s.length() == 0) return s;
|
||||
if (s.length() == 1) return s.toUpperCase();
|
||||
|
@ -332,8 +320,7 @@ public class Utilities {
|
|||
source = new FileInputStream(sourceFile).getChannel();
|
||||
destination = new FileOutputStream(destFile).getChannel();
|
||||
destination.transferFrom(source, 0, source.size());
|
||||
}
|
||||
finally {
|
||||
} finally {
|
||||
if (source != null) {
|
||||
source.close();
|
||||
}
|
||||
|
@ -344,8 +331,7 @@ public class Utilities {
|
|||
}
|
||||
|
||||
public static boolean checkFolder(String dir, List<String> errors)
|
||||
throws IOException
|
||||
{
|
||||
throws IOException {
|
||||
if (!new CSFile(dir).exists()) {
|
||||
errors.add("Unable to find directory " + dir);
|
||||
return false;
|
||||
|
@ -355,8 +341,7 @@ public class Utilities {
|
|||
}
|
||||
|
||||
public static boolean checkFile(String purpose, String dir, String file, List<String> errors)
|
||||
throws IOException
|
||||
{
|
||||
throws IOException {
|
||||
if (!new CSFile(dir + file).exists()) {
|
||||
if (errors != null)
|
||||
errors.add("Unable to find " + purpose + " file " + file + " in " + dir);
|
||||
|
@ -424,8 +409,7 @@ public class Utilities {
|
|||
return name + ext;
|
||||
}
|
||||
|
||||
public static String cleanupTextString( String contents )
|
||||
{
|
||||
public static String cleanupTextString(String contents) {
|
||||
if (contents == null || contents.trim().equals(""))
|
||||
return null;
|
||||
else
|
||||
|
@ -438,8 +422,6 @@ public class Utilities {
|
|||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public static void bytesToFile(byte[] content, String filename) throws IOException {
|
||||
FileOutputStream out = new FileOutputStream(filename);
|
||||
out.write(content);
|
||||
|
@ -448,7 +430,6 @@ public class Utilities {
|
|||
}
|
||||
|
||||
|
||||
|
||||
public static String appendSlash(String definitions) {
|
||||
return definitions.endsWith(File.separator) ? definitions : definitions + File.separator;
|
||||
}
|
||||
|
@ -466,8 +447,7 @@ public class Utilities {
|
|||
}
|
||||
|
||||
|
||||
public static String systemEol()
|
||||
{
|
||||
public static String systemEol() {
|
||||
return System.getProperty("line.separator");
|
||||
}
|
||||
|
||||
|
@ -667,7 +647,6 @@ public class Utilities {
|
|||
}
|
||||
|
||||
|
||||
|
||||
// public static void checkCase(String filename) {
|
||||
// File f = new CSFile(filename);
|
||||
// if (!f.getName().equals(filename))
|
||||
|
@ -794,7 +773,6 @@ public class Utilities {
|
|||
}
|
||||
|
||||
|
||||
|
||||
public static String normalize(String s) {
|
||||
if (noString(s))
|
||||
return null;
|
||||
|
@ -1013,8 +991,6 @@ public class Utilities {
|
|||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public static boolean isOid(String cc) {
|
||||
return cc.matches(OID_REGEX) && cc.lastIndexOf('.') >= 5;
|
||||
}
|
||||
|
@ -1074,12 +1050,14 @@ public class Utilities {
|
|||
if (in1 != null) {
|
||||
try {
|
||||
in1.close();
|
||||
} catch (IOException e) {}
|
||||
} catch (IOException e) {
|
||||
}
|
||||
}
|
||||
if (in2 != null) {
|
||||
try {
|
||||
in2.close();
|
||||
} catch (IOException e) {}
|
||||
} catch (IOException e) {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1309,5 +1287,4 @@ public class Utilities {
|
|||
}
|
||||
|
||||
|
||||
|
||||
}
|
40
pom.xml
40
pom.xml
|
@ -311,6 +311,29 @@
|
|||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.sonatype.plugins</groupId>
|
||||
<artifactId>nexus-staging-maven-plugin</artifactId>
|
||||
<version>1.6.7</version>
|
||||
<extensions>true</extensions>
|
||||
<configuration>
|
||||
<serverId>ossrh</serverId>
|
||||
<nexusUrl>https://oss.sonatype.org/</nexusUrl>
|
||||
<autoReleaseAfterClose>true</autoReleaseAfterClose>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-deploy-plugin</artifactId>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
<profiles>
|
||||
<profile>
|
||||
<id>deploy</id>
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-gpg-plugin</artifactId>
|
||||
|
@ -329,21 +352,8 @@
|
|||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.sonatype.plugins</groupId>
|
||||
<artifactId>nexus-staging-maven-plugin</artifactId>
|
||||
<version>1.6.7</version>
|
||||
<extensions>true</extensions>
|
||||
<configuration>
|
||||
<serverId>ossrh</serverId>
|
||||
<nexusUrl>https://oss.sonatype.org/</nexusUrl>
|
||||
<autoReleaseAfterClose>true</autoReleaseAfterClose>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-deploy-plugin</artifactId>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</profile>
|
||||
</profiles>
|
||||
</project>
|
||||
|
|
Loading…
Reference in New Issue