Tabnine Logo
StringUtil2
Code IndexAdd Tabnine to your IDE (free)

How to use
StringUtil2
in
ucar.unidata.util

Best Java code snippets using ucar.unidata.util.StringUtil2 (Showing top 20 results out of 315)

origin: edu.ucar/netcdf

/**
 * Replace special characters with entities for XML attributes.
 * special: '&', '<', '>', '\'', '"', '\r', '\n'
 *
 * @param x string to quote
 * @return equivilent string using entities for any special chars
 */
static public String quoteXmlAttribute(String x) {
 return replace(x, xmlIn, xmlOut);
}
origin: Unidata/thredds

/**
 * Clean up strings to be used in Netcdf Object names
 * @param name original name
 * @return cleaned up name
 */
static public String cleanName(String name) {
 if (name == null) return null;
 int pos = name.indexOf("(see");
 if (pos < 0) pos = name.indexOf("(See");
 if (pos > 0) name = name.substring(0,pos);
 name = StringUtil2.replace(name, '/', "-");
 StringBuilder sb = new StringBuilder(name);
 StringUtil2.replace(sb, '+', "plus");
 StringUtil2.remove(sb, ".;,=[]()/*\"");
 return StringUtil2.collapseWhitespace(sb.toString().trim());
}
origin: edu.ucar/netcdf

private String normalize(String units) {
 if (units.equals("/second")) units = "1/sec";
 if (units.equals("degrees K")) units = "K";
 else {
  units = StringUtil2.substitute(units, "**", "^");
  units = StringUtil2.remove(units, ')');
  units = StringUtil2.remove(units, '(');
 }
 return units;
}
origin: Unidata/thredds

public static String cleanUnit(String unit) {
 String result = StringUtil2.remove(unit, 176);
 return StringUtil2.replace(result, (char) 65533, "2"); // seems to be a superscript 2 in some language
}
origin: edu.ucar/cdm

public static void main2(String args[]) {
 if (args.length < 2) {
  showUsage();
  return;
 }
 if (args[0].equalsIgnoreCase("escape")) {
  String ok = (args.length > 2)
      ? args[2]
      : "";
  System.out.println(" escape(" + args[1] + "," + ok + ")= "
      + StringUtil2.escape(args[1], ok));
 } else if (args[0].equalsIgnoreCase("unescape")) {
  System.out.println(" unescape(" + args[1] + ")= "
      + StringUtil2.unescape(args[1]));
 } else {
  showUsage();
 }
}
origin: Unidata/thredds

private String unescapeAttributeStringValues(String value) {
 return StringUtil2.substitute(value, substAttributeStrings, escapeAttributeStrings);
}
origin: bcdev/beam

uriString = StringUtil2.replace(uriString, '\\', "/");
  uriString = StringUtil2.unescape(uriString.substring(5));  // 11/10/2010 from erussell@ngs.org
origin: Unidata/thredds

static String munge(String org) {
 String result = StringUtil2.remove(org, "_");
 result = StringUtil2.remove(result, "-");
 return result;
}
origin: Unidata/thredds

public CoverageCoordAxisBuilder setDependsOn(String dependsOn) {
 if (dependsOn != null && dependsOn.trim().length() > 0) {
  List<String> temp = new ArrayList<>();
  Collections.addAll(temp, StringUtil2.splitString(dependsOn));
  this.dependsOn = Collections.unmodifiableList(temp);
 } else {
  this.dependsOn = Collections.emptyList();
 }
 return this;
}
origin: Unidata/thredds

line = dataIS.readLine();
if (line != null) {
 line = StringUtil2.remove(line, '*');
 String[] split = StringUtil2.splitString(line);
 scale = Integer.parseInt(split[0].trim());
 refVal = Integer.parseInt(split[1].trim());
origin: edu.ucar/cdm

public static String cleanup(String s) {
 if (s == null) return null;
 return cleanup(s.getBytes(CDM.utf8Charset));
}
origin: Unidata/thredds

  String snum = StringUtil2.cleanup(cols.get(0).text()).trim();
  String desc = StringUtil2.cleanup(cols.get(1).text()).trim();
  if (snum.contains("Reserved") || desc.contains("Reserved") || desc.contains("Missing") ) {
   if (debugParam) System.out.printf("*** Skip Reserved %s%n", row.text());
  String snum = StringUtil2.cleanup(cols.get(0).text()).trim();
  String desc = StringUtil2.cleanup(cols.get(1).text()).trim();
  if (snum.contains("Reserved") || desc.contains("Reserved") || desc.contains("Missing") ) {
   if (debugParam) System.out.printf("*** Skip Reserved %s%n", row.text());
int lastPos = url.lastIndexOf('.');
String filename = "Table4" + url.substring(pos, lastPos);
filename = StringUtil2.removeWhitespace(filename);
filename = StringUtil2.substitute(filename,"-", ".");
writeParamTableXml(filename, title, url, filename, stuff);
origin: Unidata/thredds

  String snum = StringUtil2.cleanup(cols.get(0).text()).trim();
  String desc = StringUtil2.cleanup(cols.get(1).text()).trim();
  if (snum.contains("Reserved") || desc.contains("Reserved") ) {
   if (debug) System.out.printf("*** Skip Reserved %s%n", row.text());
String filename = StringUtil2.removeWhitespace(tableName);
writeCodeTableXml(filename, title, url, tableName, stuff);
origin: edu.ucar/netcdf

public String getPath() {
 return (path == null) ? null : StringUtil2.unescape(path);
}
origin: Unidata/thredds

 public HashMap<Integer, Grib1Parameter> parseXml(Element root) {
  HashMap<Integer, Grib1Parameter> result = new HashMap<>();
  Element fnmocTable = root.getChild("fnmocTable");
  List<Element> params = fnmocTable.getChildren("entry");
  for (Element elem1 : params) {
   int code;
   try {
    code = Integer.parseInt(elem1.getChildText("grib1Id"));
   } catch (NumberFormatException e) {
    System.out.printf("BAD number= %s%n", elem1.getChildText("grib1Id"));
    continue;
   }
   String desc = elem1.getChildText("description");
   if (desc == null) continue;
   //if (desc.startsWith("no definition")) continue; // skip; use standard def
   desc = StringUtil2.collapseWhitespace(desc);
   String units = elem1.getChildText("unitsFNMOC");
   if (units == null) units = "";
   String name = elem1.getChildText("name");
   Grib1Parameter parameter = new Grib1Parameter(Grib1ParamTableReader.this, code, name, desc, units, null);
   result.put(parameter.getNumber(), parameter);
   if (debug) System.out.printf(" %s%n", parameter);
  }
  useName = true;
  return result;
 }
}
origin: Unidata/thredds

static public String makeNameFromDescription(String desc) {
 if (desc == null) return null;
 int pos = desc.indexOf("(see");
 if (pos < 0) pos = desc.indexOf("(See");
 if (pos > 0) desc = desc.substring(0, pos);
 StringBuilder sb = new StringBuilder(desc.trim());
 StringUtil2.replace(sb, '+', "plus");
 StringUtil2.replace(sb, "/. ", "-p_");
 StringUtil2.remove(sb, ";,=[]()");
 return sb.toString();
}
origin: Unidata/thredds

public static void addAlias(String aliasKey, String actual) {
 alias.put(aliasKey, StringUtil2.substitute(actual, "\\", "/"));
}
origin: edu.ucar/cdm

uriString = StringUtil2.replace(uriString, '\\', "/");
 uriString = StringUtil2.unescape(uriString.substring(5));  // 11/10/2010 from erussell@ngs.org
origin: Unidata/thredds

static String cleanNumber(String s) {
 return StringUtil2.remove(s, ' ');
}
origin: edu.ucar/netcdf

public void addDatasetType(String datasetTypes) {
 // if they list datasetType explicitly, remove defaults
 if (!explicit) datasets = EnumSet.noneOf(PointDatasetType.class);
 explicit = true;
 String[] types = StringUtil2.splitString(datasetTypes);
 for (String type : types) {
  try {
   PointDatasetType fdt = PointDatasetType.valueOf(type);
   datasets.add(fdt);
  } catch (Exception e) {
   log.warn("Dont recognize PointDatasetType " + type);
  }
 }
}
ucar.unidata.utilStringUtil2

Javadoc

Static String and StringBuilder utilities

Most used methods

  • replace
    Replace any of the characters from out with corresponding character from in
  • remove
    Remove any of the characters in out from sb
  • substitute
    Find all occurences of the "match" in original, and substitute the "subst" string, directly into the
  • cleanup
    Delete any non-printable characters
  • splitString
    Split a string on one or more whitespace. Cover for String.split, because who can remember regexp?
  • unescape
    This finds any '%xx' and converts to the equivalent char. Inverse of escape().
  • collapseWhitespace
    Collapse continuous whitespace into one single " ".
  • allow
    Replace any char not alphanumeric or in allowChars by replaceChar.
  • breakTextAtWords
    Break the given text into lines, respecting word boundaries (blank space).
  • escape
    Escape any char not alphanumeric or in okChars. Escape by replacing char with %xx (hex).
  • getTokens
  • makeValidCdmObjectName
  • getTokens,
  • makeValidCdmObjectName,
  • padLeft,
  • padRight,
  • quoteHtmlContent,
  • unreplace,
  • filter7bits,
  • match,
  • quoteXmlAttribute,
  • removeFromEnd

Popular in Java

  • Start an intent from android
  • notifyDataSetChanged (ArrayAdapter)
  • putExtra (Intent)
  • startActivity (Activity)
  • GridLayout (java.awt)
    The GridLayout class is a layout manager that lays out a container's components in a rectangular gri
  • Menu (java.awt)
  • Runnable (java.lang)
    Represents a command that can be executed. Often used to run code in a different Thread.
  • SocketTimeoutException (java.net)
    This exception is thrown when a timeout expired on a socket read or accept operation.
  • SimpleDateFormat (java.text)
    Formats and parses dates in a locale-sensitive manner. Formatting turns a Date into a String, and pa
  • JPanel (javax.swing)
  • CodeWhisperer alternatives
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now