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

How to use
OrgStringUtils
in
com.orgzly.org

Best Java code snippets using com.orgzly.org.OrgStringUtils (Showing top 17 results out of 315)

origin: orgzly/org-java

public static int stringWidth(String str) {
  int total = 0;
  for (int i = 0; i < str.length(); ) {
    int cp = str.codePointAt(i);
    int width = codePointWidth(cp);
    // System.out.printf("Code point %c width: %d\n", cp, width);
    total += width;
    i += Character.charCount(cp);
  }
  return total;
}
origin: orgzly/org-java

public void setTags(String[] tags) {
  if (tags == null) {
    throw new IllegalArgumentException("Tags passed to setTags cannot be null");
  }
  this.tags = new ArrayList<>();
  /* Only add non-null and non-empty strings. */
  for (String tag: tags) {
    if (!OrgStringUtils.isEmpty(tag)) {
      this.tags.add(tag);
    }
  }
}
origin: orgzly/org-java

  public String toString() {
    return OrgStringUtils.join(this, DELIMITER);
  }
}
origin: orgzly/org-java

@Test
public void testCharacterWidth() {
  String str = "A";
  Assert.assertEquals(1, OrgStringUtils.stringWidth(str));
}
origin: orgzly/org-java

/**
 * Make sure content ends with at least 2 new-line characters, unless it's empty.
 * Required so notes can be just appended to it.
 *
 * @param content Preface
 * @return preface ready for appending
 */
public String whiteSpacedFilePreface(String content) {
  if (content == null || content.length() == 0) {
    return "";
  } else {
    return OrgStringUtils.trimLines(content) + "\n\n";
  }
}
origin: orgzly/org-java

@Test
public void testSurrogatePairWidth() {
  String str = "𥑮";
  Assert.assertEquals(2, OrgStringUtils.stringWidth(str));
}
origin: orgzly/org-java

  /**
   * Removes empty lines before and after the content.
   * Called before every announcement.
   */
  private void setTrimmedPreface(OrgFile file, String preface) {
    file.setPreface(OrgStringUtils.trimLines(preface));
  }
}
origin: orgzly/org-java

@Test
public void testWideWidth() {
  String str = "漢";
  Assert.assertEquals(2, OrgStringUtils.stringWidth(str));
}
@Test
origin: orgzly/org-java

public static OrgDateTime parseOrNull(String str) {
  if (OrgStringUtils.isEmpty(str)) {
    return null;
  }
  OrgDateTime time = new OrgDateTime();
  time.string = str;
  return time;
}
origin: orgzly/org-java

/**
 * Removes empty lines before and after the content.
 * Called before every announcement.
 */
private void trimContent(OrgHead head) {
  head.setContent(OrgStringUtils.trimLines(head.getContent()));
}
origin: orgzly/org-java

/**
 * Given a sets of to do and done keywords, builds a regex for matching against heading.
 *
 * @return {@link Pattern} or null if no valid keywords were found.
 */
private Pattern buildStatePattern(Set<String> todoKeywords, Set<String> doneKeywords) {
  Set<String> allKeywords = new HashSet<>();
  if (todoKeywords != null) {
    for (String keyword: todoKeywords) {
      allKeywords.add(Pattern.quote(keyword));
    }
  }
  if (doneKeywords != null) {
    for (String keyword: doneKeywords) {
      allKeywords.add(Pattern.quote(keyword));
    }
  }
  if (allKeywords.size() > 0) {
    return Pattern.compile("^(" + OrgStringUtils.join(allKeywords, "|") + ")(.*)");
  }
  return null;
}
origin: orgzly/org-java

  @Test
  public void testStringWidth() {
    String str = "A漢字𥑮";
    Assert.assertEquals(7, OrgStringUtils.stringWidth(str));
  }
}
origin: orgzly/org-java

public static OrgRange parseOrNull(String str) {
  if (OrgStringUtils.isEmpty(str)) {
    return null;
  }
  return parse(str);
}
origin: orgzly/org-java

int padding = Math.abs(settings.tagsColumn) - OrgStringUtils.stringWidth(s.toString());
  padding -= OrgStringUtils.stringWidth(ts);
origin: orgzly/org-java

private void parseTimeOfDay(String str) {
  Matcher m = OrgPatterns.TIME_OF_DAY_P.matcher(str);
  if (! m.find()) {
    matchFailed(str, OrgPatterns.TIME_OF_DAY_P);
  }
  cal.set(Calendar.HOUR_OF_DAY, Integer.valueOf(m.group(2)));
  cal.set(Calendar.MINUTE, Integer.valueOf(m.group(3)));
  hasTime = true;
  if (! OrgStringUtils.isEmpty(m.group(4))) { // End time exists
    endCal = Calendar.getInstance();
    endCal.setTime(cal.getTime());
    endCal.set(Calendar.HOUR_OF_DAY, Integer.valueOf(m.group(6)));
    endCal.set(Calendar.MINUTE, Integer.valueOf(m.group(7)));
    endCal.set(Calendar.SECOND, 0);
    endCal.set(Calendar.MILLISECOND, 0);
  }
}
origin: orgzly/org-java

cal.set(Calendar.DAY_OF_MONTH, Integer.valueOf(m.group(4)));
if (! OrgStringUtils.isEmpty(m.group(6))) { // Has time of day.
  parseTimeOfDay(string.substring(m.start(6)));
} else {
origin: orgzly/org-java

public static OrgRepeater parse(String str) {
  OrgRepeater repeater = new OrgRepeater();
  Matcher m = OrgPatterns.REPEATER.matcher(str);
  if (m.find()) {
    if (m.groupCount() == 7) {
      repeater.setTypeFromString(m.group(2));
      repeater.setValue(m.group(3));
      repeater.setUnit(m.group(4));
      if (! OrgStringUtils.isEmpty(m.group(6))) {
        repeater.habitDeadline = new OrgInterval();
        repeater.habitDeadline.setValue(m.group(6));
        repeater.habitDeadline.setUnit(m.group(7));
      }
    } else {
      throw new IllegalArgumentException("Expected 7 groups (got " + m.groupCount() +
                        ") when matching repeater " + str + " against " + OrgPatterns.REPEATER);
    }
  } else {
    throw new IllegalArgumentException("Failed matching repeater " +
                      str + " against " + OrgPatterns.REPEATER);
  }
  return repeater;
}
com.orgzly.orgOrgStringUtils

Most used methods

  • stringWidth
  • codePointWidth
  • isEmpty
  • join
  • trimLines

Popular in Java

  • Start an intent from android
  • startActivity (Activity)
  • onCreateOptionsMenu (Activity)
  • getResourceAsStream (ClassLoader)
  • Point (java.awt)
    A point representing a location in (x,y) coordinate space, specified in integer precision.
  • MessageFormat (java.text)
    Produces concatenated messages in language-neutral way. New code should probably use java.util.Forma
  • BlockingQueue (java.util.concurrent)
    A java.util.Queue that additionally supports operations that wait for the queue to become non-empty
  • CountDownLatch (java.util.concurrent)
    A synchronization aid that allows one or more threads to wait until a set of operations being perfor
  • ThreadPoolExecutor (java.util.concurrent)
    An ExecutorService that executes each submitted task using one of possibly several pooled threads, n
  • Project (org.apache.tools.ant)
    Central representation of an Ant project. This class defines an Ant project with all of its targets,
  • 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