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

How to use
StrUtils
in
org.apache.solr.common.util

Best Java code snippets using org.apache.solr.common.util.StrUtils (Showing top 20 results out of 315)

origin: org.apache.solr/solr-solrj

public static List<String> splitSmart(String s, char separator) {
 ArrayList<String> lst = new ArrayList<>(4);
 splitSmart(s, separator, lst);
 return lst;
}
/**
origin: com.hynnet/solr-solrj

 @Override
 public String toString() {
  StringBuilder sb = new StringBuilder(128);
  try {
   boolean first=true;

   for (Map.Entry<String,String> entry : map.entrySet()) {
    String key = entry.getKey();
    Object val = entry.getValue();
    if (val instanceof String[]) {
     String[] strings = (String[]) val;
     val =  StrUtils.join(Arrays.asList(strings),',');
    }
    if (!first) sb.append('&');
    first=false;
    sb.append(key);
    sb.append('=');
    StrUtils.partialURLEncodeVal(sb, val==null ? "" : String.valueOf(val));
   }
  }
  catch (IOException e) {throw new RuntimeException(e);}  // can't happen

  return sb.toString();
 }
}
origin: org.apache.solr/solr-solrj

/** 
 * Returns the Boolean value of the field param,
 * or the value for param, or null if neither is set. 
 * Use this method only when you want to be explicit 
 * about absence of a value (<code>null</code>) vs the default value <code>false</code>.  
 * @see #getFieldBool(String, String, boolean) 
 * @see #getPrimitiveFieldBool(String, String)    
 **/
public Boolean getFieldBool(String field, String param) {
 String val = getFieldParam(field, param);
 return val==null ? null : StrUtils.parseBool(val);
}

origin: org.dspace.dependencies.solr/dspace-solr-core

private static List<List<String>> getSynList(String str, String separator, TokenizerFactory tokFactory) {
 List<String> strList = StrUtils.splitSmart(str, separator, false);
 // now split on whitespace to get a list of token strings
 List<List<String>> synList = new ArrayList<List<String>>();
 for (String toks : strList) {
  List<String> tokList = tokFactory == null ?
   StrUtils.splitWS(toks, true) : splitByTokenizer(toks, tokFactory);
  synList.add(tokList);
 }
 return synList;
}
origin: org.apache.solr/solr-solrj

 shard = parse(SHARD, m);
 if (m.get(REPLICA) == null) {
  throw new IllegalArgumentException(formatString("'replica' is required in {0}", toJSONString(m)));
 throw new RuntimeException("Invalid op, must have one and only one tag other than collection, shard,replica " + toJSONString(m));
if (tag.name.startsWith(Clause.METRICS_PREFIX)) {
 List<String> ss = StrUtils.splitSmart(tag.name, ':');
 if (ss.size() < 3 || ss.size() > 4) {
  throw new RuntimeException("Invalid metrics: param in " + toJSONString(m) + " must have at 2 or 3 segments after 'metrics:' separated by ':'");
origin: org.apache.solr/solr-common

 @Override
 public String toString() {
  StringBuilder sb = new StringBuilder(128);
  try {
   boolean first=true;

   for (Map.Entry<String,String> entry : map.entrySet()) {
    String key = entry.getKey();
    String val = entry.getValue();

    if (!first) sb.append('&');
    first=false;
    sb.append(key);
    sb.append('=');
    StrUtils.partialURLEncodeVal(sb, val==null ? "" : val);
   }
  }
  catch (IOException e) {throw new RuntimeException(e);}  // can't happen

  return sb.toString();
 }
}
origin: org.apache.solr/solr-solrj

} else if (varType.type == String.class) {
 if (isRuleVal && !varType.vals.isEmpty() && !varType.vals.contains(val))
  throw new RuntimeException(name + ": " + val + " must be one of " + StrUtils.join(varType.vals, ','));
 return val;
} else {
origin: org.apache.solr/solr-solrj

/** 
 * Creates a new copy of the string with the separator backslash escaped.
 * @see #join
 */
public static String escapeTextWithSeparator(String item, char separator) {
 StringBuilder sb = new StringBuilder(item.length() * 2);
 appendEscapedTextToBuilder(sb, item, separator);
 return sb.toString();
}  
origin: org.apache.cocoon.optional/cocoon-optional

@Override
public void startElement(String uri, String localName, String qName, Attributes atts) throws SAXException {
  if (FIELD.equals(localName)) {
    this.text = new StringBuilder();
    this.boost = 1.0f;
    if (atts.getValue(NAME) != null) {
      this.name = atts.getValue(NAME);
    }
    if (atts.getValue(BOOST) != null) {
      this.boost = Float.parseFloat(atts.getValue(BOOST));
    }
    if (atts.getValue(NULL) != null) {
      this.isNull = StrUtils.parseBoolean(atts.getValue(NULL));
    }
  }
  this.getSAXConsumer().startElement(uri, localName, qName, atts);
}
origin: org.apache.solr/solr-common

@Override
public String toString() {
 StringBuilder sb = new StringBuilder(128);
 try {
  boolean first=true;
  for (Map.Entry<String,String[]> entry : map.entrySet()) {
   String key = entry.getKey();
   String[] valarr = entry.getValue();
   for (String val : valarr) {
    if (!first) sb.append('&');
    first=false;
    sb.append(key);
    sb.append('=');
    StrUtils.partialURLEncodeVal(sb, val==null ? "" : val);
   }
  }
 }
 catch (IOException e) {throw new RuntimeException(e);}  // can't happen
 return sb.toString();
}
origin: org.dspace.dependencies.solr/dspace-solr-core

 ids.add(shardDoc.id.toString());
sreq.params.add(TermVectorParams.DOC_IDS, StrUtils.join(ids, ','));
origin: com.hynnet/solr-solrj

/** 
 * Creates a new copy of the string with the separator backslash escaped.
 * @see #join
 */
public static String escapeTextWithSeparator(String item, char separator) {
 StringBuilder sb = new StringBuilder(item.length() * 2);
 appendEscapedTextToBuilder(sb, item, separator);
 return sb.toString();
}  
origin: org.dspace.dependencies.solr/dspace-solr-core

String attrVal = parser.getAttributeValue(i);
if ("fromPending".equals(attrName)) {
 deleteCmd.fromPending = StrUtils.parseBoolean(attrVal);
} else if ("fromCommitted".equals(attrName)) {
 deleteCmd.fromCommitted = StrUtils.parseBoolean(attrVal);
} else {
 XmlUpdateRequestHandler.log.warn("unexpected attribute delete/@" + attrName);
origin: org.apache.solr/solr-solrj

private static List<String> splitCollections(String collections) {
 return Collections.unmodifiableList(StrUtils.splitSmart(collections, ",", true));
}
origin: org.apache.solr/solr-dataimporthandler

 public DebugInfo(Map<String,Object> requestParams) {
  verbose = StrUtils.parseBool((String) requestParams.get("verbose"), false);
  debugVerboseOutput = new NamedList<>();
 }
}
origin: com.hynnet/solr-solrj

@Override
public String toString() {
 StringBuilder sb = new StringBuilder(128);
 try {
  boolean first=true;
  for (Map.Entry<String,String[]> entry : map.entrySet()) {
   String key = entry.getKey();
   String[] valarr = entry.getValue();
   for (String val : valarr) {
    if (!first) sb.append('&');
    first=false;
    sb.append(key);
    sb.append('=');
    StrUtils.partialURLEncodeVal(sb, val==null ? "" : val);
   }
  }
 }
 catch (IOException e) {throw new RuntimeException(e);}  // can't happen
 return sb.toString();
}
origin: org.apache.solr/solr-solrj

params.add("group", StrUtils.join(groups, ','));
params.add("prefix", StrUtils.join(prefixes, ','));
origin: org.apache.solr/solr-solrj

/** 
 * Creates a backslash escaped string, joining all the items. 
 * @see #escapeTextWithSeparator
 */
public static String join(Collection<?> items, char separator) {
 if (items == null) return "";
 StringBuilder sb = new StringBuilder(items.size() << 3);
 boolean first=true;
 for (Object o : items) {
  String item = String.valueOf(o);
  if (first) {
   first = false;
  } else {
   sb.append(separator);
  }
  appendEscapedTextToBuilder(sb, item, separator);
 }
 return sb.toString();
}
origin: org.dspace.dependencies.solr/dspace-solr-core

 boost = Float.parseFloat(attrVal);
} else if ("null".equals(attrName)) {
 isNull = StrUtils.parseBoolean(attrVal);
} else {
 XmlUpdateRequestHandler.log.warn("Unknown attribute doc/field/@" + attrName);
origin: org.apache.solr/solr-solrj

public static List<String> getPathSegments(String path) {
 if (path == null || path.isEmpty()) return emptyList();
 List<String> parts = new ArrayList<String>() {
  @Override
  public boolean add(String s) {
   if (s == null || s.isEmpty()) return false;
   return super.add(s);
  }
 };
 StrUtils.splitSmart(path, '/', parts);
 return parts;
}
org.apache.solr.common.utilStrUtils

Most used methods

  • splitSmart
    Splits a backslash escaped string on the separator. Current backslash escaping supported: \n \t \r \
  • partialURLEncodeVal
    URLEncodes a value, replacing only enough chars so that the URL may be unambiguously pasted back int
  • join
    Creates a backslash escaped string, joining all the items.
  • parseBool
    NullPointerException and SolrException free version of #parseBool(String)
  • appendEscapedTextToBuilder
    writes chars from item to out, backslash escaping as needed based on separator -- but does not appen
  • parseBoolean
    Return if a string starts with '1', 't', or 'T' and return false otherwise.
  • formatString
    Format using MesssageFormat but with the ROOT locale
  • splitFileNames
    Splits file names separated by comma character. File names can contain comma characters escaped by b
  • splitWS

Popular in Java

  • Creating JSON documents from java classes using gson
  • getContentResolver (Context)
  • getSystemService (Context)
  • getOriginalFilename (MultipartFile)
    Return the original filename in the client's filesystem.This may contain path information depending
  • System (java.lang)
    Provides access to system-related information and resources including standard input and output. Ena
  • SocketException (java.net)
    This SocketException may be thrown during socket creation or setting options, and is the superclass
  • Format (java.text)
    The base class for all formats. This is an abstract base class which specifies the protocol for clas
  • LinkedHashMap (java.util)
    LinkedHashMap is an implementation of Map that guarantees iteration order. All optional operations a
  • Annotation (javassist.bytecode.annotation)
    The annotation structure.An instance of this class is returned bygetAnnotations() in AnnotationsAttr
  • JButton (javax.swing)
  • Best IntelliJ plugins
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