Пример #1
0
 /** Set the text of an XML element, safely encode it if needed. */
 @NotNull
 public static Element setSafeXmlText(@NotNull Element element, @NotNull String text) {
   final Character first = firstCharacter(text);
   final Character last = lastCharacter(text);
   if (!StringHelper.isXmlCharacterData(text)
       || first != null && Character.isWhitespace(first)
       || last != null && Character.isWhitespace(last)) {
     element.setAttribute("encoding", "base64");
     final String encoded = new String(Base64.encodeBase64(text.getBytes()));
     element.setText(encoded);
   } else {
     element.setText(text);
   }
   return element;
 }
Пример #2
0
 /** Append the supplied text to any existing text. */
 public void addText(@NotNull String text) {
   addKeys(StringHelper.stringToKeys(text));
 }
Пример #3
0
 public Register(char name, @NotNull SelectionType type, @NotNull String text) {
   this.name = name;
   this.type = type;
   this.keys = StringHelper.stringToKeys(text);
 }
Пример #4
0
  private static boolean shouldIgnoreCase(@NotNull String pattern, boolean noSmartCase) {
    boolean sc = !noSmartCase && Options.getInstance().isSet("smartcase");
    boolean ic = Options.getInstance().isSet("ignorecase");

    return ic && !(sc && StringHelper.containsUpperCase(pattern));
  }
Пример #5
0
 @Nullable
 private static String getSafeChildText(@NotNull Element element, @NotNull String name) {
   final Element child = element.getChild(name);
   return child != null ? StringHelper.getSafeXmlText(child) : null;
 }
Пример #6
0
 @NotNull
 private static Element createElementWithText(@NotNull String name, @NotNull String text) {
   return StringHelper.setSafeXmlText(new Element(name), text);
 }