Java Code Examples for org.apache.commons.text.WordUtils

The following examples show how to use org.apache.commons.text.WordUtils. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
private StringBuilder getRowsBlock(List<String> order, Map<String, ColumnDefinition> columnDefinitions, Row row) {
    List<String[]> textBlocks = new ArrayList<>();
    Map<String, String> columns = row.getColumns();
    int maxHeight = 0;
    for (String columnKey : order) {
        String columnText = columns.get(columnKey);
        String[] blockLines;
        if (StringUtils.isNotBlank(columnText)) {
            int columnWidth = columnDefinitions.get(columnKey).getWidth();
            String columnBlock = WordUtils.wrap(columnText, columnWidth, lineBreaker, true);
            blockLines = columnBlock.split("(" + lineBreaker + "|\r|\n)");
        } else {
            blockLines = new String[]{emptyValue};
        }
        textBlocks.add(blockLines);
        maxHeight = maxHeight < blockLines.length ? blockLines.length : maxHeight;
    }

    return appendTextBlocks(order, columnDefinitions, textBlocks, maxHeight);
}
 
Example 2
Source Project: petscii-bbs   Source File: CsdbReleasesSD2IEC.java    License: Mozilla Public License 2.0 6 votes vote down vote up
private void listPosts(String rssUrl) throws IOException, FeedException {
    cls();
    drawLogo();
    if (isEmpty(posts)) {
        waitOn();
        posts = getPosts(rssUrl, currentPage, pageSize);
        waitOff();
    }
    for (Map.Entry<Integer, ReleaseEntry> entry: posts.entrySet()) {
        int i = entry.getKey();
        ReleaseEntry post = entry.getValue();
        write(WHITE); print(i + "."); write(GREY3);
        final int iLen = 37-String.valueOf(i).length();
        String title = post.title + (isNotBlank(post.releasedBy) ? " (" + post.releasedBy+")" : EMPTY);
        String line = WordUtils.wrap(filterPrintable(HtmlUtils.htmlClean(title)), iLen, "\r", true);
        println(line.replaceAll("\r", "\r " + repeat(" ", 37-iLen)));
    }
    newline();
}
 
Example 3
Source Project: petscii-bbs   Source File: CsdbReleases.java    License: Mozilla Public License 2.0 6 votes vote down vote up
private void listPosts(String rssUrl) throws IOException, FeedException {
    cls();
    drawLogo();
    if (isEmpty(posts)) {
        waitOn();
        posts = getPosts(rssUrl, currentPage, pageSize);
        waitOff();
    }
    for (Map.Entry<Integer, ReleaseEntry> entry: posts.entrySet()) {
        int i = entry.getKey();
        ReleaseEntry post = entry.getValue();
        write(WHITE); print(i + "."); write(GREY3);
        final int iLen = 37-String.valueOf(i).length();
        String title = post.title + (isNotBlank(post.releasedBy) ? " (" + post.releasedBy+")" : EMPTY);
        String line = WordUtils.wrap(filterPrintable(HtmlUtils.htmlClean(title)), iLen, "\r", true);
        println(line.replaceAll("\r", "\r " + repeat(" ", 37-iLen)));
    }
    newline();
}
 
Example 4
Source Project: petscii-bbs   Source File: GoogleBloggerProxy.java    License: Mozilla Public License 2.0 6 votes vote down vote up
protected void listPosts() throws IOException {
    cls();
    drawLogo();
    if (posts == null) {
        waitOn();
        posts = getPosts();
        waitOff();
    }
    for (Map.Entry<Integer, Post> entry: posts.entrySet()) {
        int i = entry.getKey();
        Post post = entry.getValue();
        write(WHITE); print(i + "."); write(GREY3);
        final int iLen = 37-String.valueOf(i).length();
        String line = WordUtils.wrap(filterPrintable(HtmlUtils.htmlClean(post.getTitle())), iLen, "\r", true);
        println(line.replaceAll("\r", "\r " + repeat(" ", 37-iLen)));
    }
    newline();
}
 
Example 5
Source Project: petscii-bbs   Source File: WordpressProxy.java    License: Mozilla Public License 2.0 6 votes vote down vote up
protected void listPosts() throws Exception {
    cls();
    drawLogo();
    if (isEmpty(posts)) {
        waitOn();
        posts = getPosts(currentPage, pageSize);
        waitOff();
    }
    for (Map.Entry<Integer, Post> entry: posts.entrySet()) {
        int i = entry.getKey();
        Post post = entry.getValue();
        write(WHITE); print(i + "."); write(GREY3);
        final int iLen = 37-String.valueOf(i).length();
        String line = WordUtils.wrap(filterPrintable(HtmlUtils.htmlClean(post.title)), iLen, "\r", true);
        println(line.replaceAll("\r", "\r " + repeat(" ", 37-iLen)));
    }
    newline();
}
 
Example 6
Source Project: petscii-bbs   Source File: UserLogon.java    License: Mozilla Public License 2.0 6 votes vote down vote up
public void displayMessage(Message m) throws Exception {
    DateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
    cls();
    write(LOGO_BYTES);
    write(GREY3);
    println("From: "+ m.userFrom);
    println("To:   "+ m.userTo);
    println("Date: "+ df.format(m.dateTime));
    println("Subj: "+ m.subject);
    println(StringUtils.repeat(chr(163),39));
    String[] lines = defaultString(m.message).split("\n");
    for (String line: lines)
        println(WordUtils.wrap(line, 39, "\r", true ));
    markAsRead(m);
    newline();
    print("press "); write(WHITE); print("'R'"); write(GREY3); print(" to REPLY, any key to go back.");
    flush();
    resetInput(); int ch = readKey();
    if (ch == 'r' || ch == 'R') {
        newline();
        newline();
        sendMessageGui(m.userFrom, m.subject);
    }
}
 
Example 7
Source Project: azure-cosmosdb-java   Source File: PartitionKeyDefinition.java    License: MIT License 6 votes vote down vote up
public PartitionKeyDefinitionVersion getVersion() {
    if (this.version == null) {
        Object versionObject = super.getObject(Constants.Properties.PARTITION_KEY_DEFINITION_VERSION, Object.class);
        if (versionObject == null) {
            this.version = null;
        } else {
            String versionStr = String.valueOf(versionObject);
            if (StringUtils.isNumeric(versionStr)) {
                this.version = PartitionKeyDefinitionVersion.valueOf(String.format("V%d", Integer.parseInt(versionStr)));
            } else {
                this.version = !Strings.isNullOrEmpty(versionStr)
                        ? PartitionKeyDefinitionVersion.valueOf(WordUtils.capitalize(versionStr))
                        : null;
            }
        }
    }

    return this.version;
}
 
Example 8
Source Project: azure-cosmosdb-java   Source File: ConflictResolutionPolicy.java    License: MIT License 6 votes vote down vote up
/**
 * Gets the {@link ConflictResolutionMode} in the Azure Cosmos DB service.
 * By default it is {@link ConflictResolutionMode#LastWriterWins}.
 *
 * @return ConflictResolutionMode.
 */
public ConflictResolutionMode getConflictResolutionMode() {

    String strValue = super.getString(Constants.Properties.MODE);

    if (!Strings.isNullOrEmpty(strValue)) {
        try {
            return ConflictResolutionMode.valueOf(WordUtils.capitalize(super.getString(Constants.Properties.MODE)));
        } catch (IllegalArgumentException e) {
            this.getLogger().warn("Invalid ConflictResolutionMode value {}.", super.getString(Constants.Properties.MODE));
            return ConflictResolutionMode.Invalid;
        }
    }

    return ConflictResolutionMode.Invalid;
}
 
Example 9
Source Project: synthea   Source File: SymptomTextExporter.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Add the basic information to the record.
 *
 * @param textRecord
 *          Text format record, as a list of lines
 * @param person
 *          The person to export
 * @param endTime
 *          Time the simulation ended (to calculate age/deceased status)
 */
private static void basicInfo(List<String> textRecord, Person person, long endTime) {
  String name = (String) person.attributes.get(Person.NAME);

  textRecord.add(name);
  textRecord.add(name.replaceAll("[A-Za-z0-9 ]", "=")); // "underline" the characters in the name

  String race = (String) person.attributes.get(Person.RACE);
  String ethnicity = (String) person.attributes.get(Person.ETHNICITY);
  String displayEthnicity;
  if (ethnicity.equals("hispanic")) {
    displayEthnicity = "Hispanic";
  } else {
    displayEthnicity = "Non-Hispanic";
  }
  textRecord.add("Race:                " + WordUtils.capitalize(race));
  textRecord.add("Ethnicity:           " + displayEthnicity);

  textRecord.add("Gender:              " + person.attributes.get(Person.GENDER));

  String birthdate = dateFromTimestamp((long) person.attributes.get(Person.BIRTHDATE));
  textRecord.add("Birth Date:          " + birthdate);
  
}
 
Example 10
Source Project: drftpd   Source File: IMDBAction.java    License: GNU General Public License v2.0 6 votes vote down vote up
@Override
public String exec(CommandRequest request, InodeHandle inode) {
    _failed = false;
    IMDBVFSDataNFO imdbData = new IMDBVFSDataNFO((DirectoryHandle) inode);
    IMDBInfo imdbInfo = imdbData.getIMDBInfoFromCache();
    if (imdbInfo != null) {
        if (imdbInfo.getMovieFound()) {
            StringBuilder sb = new StringBuilder();
            sb.append("#########################################").append(")\n");
            sb.append("# Title # - ").append(imdbInfo.getTitle()).append("\n");
            sb.append("# Year # - ").append(imdbInfo.getYear()).append("\n");
            sb.append("# Runtime # - ").append(imdbInfo.getRuntime()).append(" min").append("\n");
            sb.append("# Language # - ").append(imdbInfo.getLanguage()).append("\n");
            sb.append("# Country # - ").append(imdbInfo.getCountry()).append("\n");
            sb.append("# Director # - ").append(imdbInfo.getDirector()).append("\n");
            sb.append("# Genres # - ").append(imdbInfo.getGenres()).append("\n");
            sb.append("# Plot #\n").append(WordUtils.wrap(imdbInfo.getPlot(), 70));
            sb.append("# Rating # - ");
            sb.append(imdbInfo.getRating() != null ? imdbInfo.getRating() / 10 + "." + imdbInfo.getRating() % 10 + "/10" : "-").append("\n");
            sb.append("# Votes # - ").append(imdbInfo.getVotes()).append("\n");
            sb.append("# URL # - ").append(imdbInfo.getURL()).append("\n");
            return sb.toString();
        }
    }
    return "#########################################\nNO IMDB INFO FOUND FOR: " + inode.getPath();
}
 
Example 11
Source Project: drftpd   Source File: TvMazeAction.java    License: GNU General Public License v2.0 6 votes vote down vote up
@Override
public String exec(CommandRequest request, InodeHandle inode) {
    _failed = false;
    TvMazeVFSData tvmazeData = new TvMazeVFSData((DirectoryHandle) inode);
    TvMazeInfo tvmazeInfo = tvmazeData.getTvMazeInfoFromCache();
    if (tvmazeInfo != null) {
        StringBuilder sb = new StringBuilder();
        sb.append("#########################################").append(")\n");
        sb.append("# Title # - ").append(tvmazeInfo.getName()).append("\n");
        sb.append("# Genre # - ").append(StringUtils.join(Arrays.toString(tvmazeInfo.getGenres()), ", ")).append("\n");
        sb.append("# URL # - ").append(tvmazeInfo.getURL()).append("\n");
        sb.append("# Plot #\n").append(WordUtils.wrap(tvmazeInfo.getSummary(), 70));
        return sb.toString();
    }
    return "#########################################\nNO TvMaze INFO FOUND FOR: " + inode.getPath();
}
 
Example 12
Source Project: drftpd   Source File: IMDBAction.java    License: GNU General Public License v2.0 6 votes vote down vote up
@Override
public String exec(CommandRequest request, InodeHandle inode) {
    _failed = false;
    IMDBVFSDataNFO imdbData = new IMDBVFSDataNFO((DirectoryHandle) inode);
    IMDBInfo imdbInfo = imdbData.getIMDBInfoFromCache();
    if (imdbInfo != null) {
        if (imdbInfo.getMovieFound()) {
            StringBuilder sb = new StringBuilder();
            sb.append("#########################################").append(")\n");
            sb.append("# Title # - ").append(imdbInfo.getTitle()).append("\n");
            sb.append("# Year # - ").append(imdbInfo.getYear()).append("\n");
            sb.append("# Runtime # - ").append(imdbInfo.getRuntime()).append(" min").append("\n");
            sb.append("# Language # - ").append(imdbInfo.getLanguage()).append("\n");
            sb.append("# Country # - ").append(imdbInfo.getCountry()).append("\n");
            sb.append("# Director # - ").append(imdbInfo.getDirector()).append("\n");
            sb.append("# Genres # - ").append(imdbInfo.getGenres()).append("\n");
            sb.append("# Plot #\n").append(WordUtils.wrap(imdbInfo.getPlot(), 70));
            sb.append("# Rating # - ");
            sb.append(imdbInfo.getRating() != null ? imdbInfo.getRating() / 10 + "." + imdbInfo.getRating() % 10 + "/10" : "-").append("\n");
            sb.append("# Votes # - ").append(imdbInfo.getVotes()).append("\n");
            sb.append("# URL # - ").append(imdbInfo.getURL()).append("\n");
            return sb.toString();
        }
    }
    return "#########################################\nNO IMDB INFO FOUND FOR: " + inode.getPath();
}
 
Example 13
Source Project: drftpd   Source File: TvMazeAction.java    License: GNU General Public License v2.0 6 votes vote down vote up
@Override
public String exec(CommandRequest request, InodeHandle inode) {
    _failed = false;
    TvMazeVFSData tvmazeData = new TvMazeVFSData((DirectoryHandle) inode);
    TvMazeInfo tvmazeInfo = tvmazeData.getTvMazeInfoFromCache();
    if (tvmazeInfo != null) {
        StringBuilder sb = new StringBuilder();
        sb.append("#########################################").append(")\n");
        sb.append("# Title # - ").append(tvmazeInfo.getName()).append("\n");
        sb.append("# Genre # - ").append(StringUtils.join(Arrays.toString(tvmazeInfo.getGenres()), ", ")).append("\n");
        sb.append("# URL # - ").append(tvmazeInfo.getURL()).append("\n");
        sb.append("# Plot #\n").append(WordUtils.wrap(tvmazeInfo.getSummary(), 70));
        return sb.toString();
    }
    return "#########################################\nNO TvMaze INFO FOUND FOR: " + inode.getPath();
}
 
Example 14
Source Project: citeproc-java   Source File: TextCase.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Transforms the text of a token
 * @param t the token
 * @return the new token with the transformed text
 */
private Token transform(Token t) {
    String s = t.getText();
    if ("lowercase".equals(textCase)) {
        s = s.toLowerCase();
    } else if ("uppercase".equals(textCase)) {
        s = s.toUpperCase();
    } else if ("capitalize-first".equals(textCase)) {
        s = StringUtils.capitalize(s);
    } else if ("capitalize-all".equals(textCase)) {
        s = WordUtils.capitalize(s);
    } else if ("title".equals(textCase)) {
        s = StringHelper.toTitleCase(s);
    }
    return new Token.Builder(t)
            .text(s)
            .build();
}
 
Example 15
Source Project: Singularity   Source File: MailTemplateHelpers.java    License: Apache License 2.0 6 votes vote down vote up
public List<SingularityMailTaskHistoryUpdate> getJadeTaskHistory(
  Collection<SingularityTaskHistoryUpdate> taskHistory
) {
  List<SingularityMailTaskHistoryUpdate> output = Lists.newArrayListWithCapacity(
    taskHistory.size()
  );

  for (SingularityTaskHistoryUpdate taskUpdate : taskHistory) {
    output.add(
      new SingularityMailTaskHistoryUpdate(
        humanizeTimestamp(taskUpdate.getTimestamp()),
        WordUtils.capitalize(taskUpdate.getTaskState().getDisplayName()),
        taskUpdate.getStatusMessage().orElse("")
      )
    );
  }

  return output;
}
 
Example 16
Source Project: vividus   Source File: EnvironmentConfigurer.java    License: Apache License 2.0 5 votes vote down vote up
@SuppressWarnings("unchecked")
public void init() throws IOException
{
    Collection<DynamicEnvironmentConfigurationProperty> values = new PropertyMappedDataProvider<>(propertyMapper,
            DYNAMIC_PROPERTY_PREFIX, DynamicEnvironmentConfigurationProperty.class).getData().values();
    for (DynamicEnvironmentConfigurationProperty property: values)
    {
        Pattern propertyRegex = property.getPropertyRegex();
        Map<String, String> matchedProperties = new TreeMap<>(propertyParser.getPropertiesByRegex(propertyRegex));
        matchedProperties.forEach((key, value) ->
        {
            Matcher matcher = propertyRegex.matcher(key);
            matcher.matches();
            String descriptionPattern = property.getDescriptionPattern();
            addProperty(property.getCategory(), matcher.groupCount() > 0
                    ? String.format(descriptionPattern, matcher.group(1)) : descriptionPattern, value);
        });
    }

    propertyMapper.readValues(PROPERTY_PREFIX, Map.class).forEach((category, properties) ->
    {
        if (!DYNAMIC.equals(category))
        {
            PropertyCategory propertyCategory = PropertyCategory.valueOf(category.toUpperCase());
            Map<String, String> currentProperties = ENVIRONMENT_CONFIGURATION.get(propertyCategory);
            properties.forEach((k, v) -> currentProperties
                    .put(WordUtils.capitalize(((String) k).replace('-', ' ')), (String) v));
        }
    });
}
 
Example 17
Source Project: spring-native-query   Source File: NativeQueryAccessField.java    License: MIT License 5 votes vote down vote up
public NativeQueryAccessField(Field field) {
    this.name = WordUtils.capitalize(field.getName());
    this.type = field.getType();
    if (field.isAnnotationPresent(NativeQueryParam.class)) {
        this.param = field.getAnnotation(NativeQueryParam.class);
    }
}
 
Example 18
Source Project: sailfish-core   Source File: ServiceActions.java    License: Apache License 2.0 5 votes vote down vote up
public static String convertProperty(String value) {
	if (value.contains(" ")) {
		return WordUtils.uncapitalize(WordUtils.capitalizeFully(value).replaceAll(" ", ""));
	} else {
		return WordUtils.uncapitalize(value);
	}
}
 
Example 19
Source Project: petscii-bbs   Source File: InternetBrowser.java    License: Mozilla Public License 2.0 5 votes vote down vote up
private void listLinks(Document webpage) throws Exception {
    clearForLinks();
    gotoXY(0,4);
    write(ORANGE);
    println("Links On Page:");
    println();

    List<Entry> entries = getAllLinks(webpage);

    if (isEmpty(entries)) {
        write(RED);
        println("Zero result page - press any key");
        flush();
        resetInput();
        readKey();
        return;
    }

    links = getLinksForPage(entries, __currentPage, __pageSize);

    for (Map.Entry<Integer, Entry> entry: links.entrySet()) {
        int i = entry.getKey();
        Entry post = entry.getValue();

        write(WHITE);
        print(i + ".");
        write(GREY3);

        final int iLen = 37 - String.valueOf(i).length(); //I'm guessing something to do with the row width

        String title = post.name;
        String line = WordUtils.wrap(filterPrintable(HtmlUtils.htmlClean(title)), iLen, "\r", true);

        println(line.replaceAll("\r", "\r " + repeat(" ", 37-iLen)));
    }
    newline();
}
 
Example 20
Source Project: petscii-bbs   Source File: InternetBrowser.java    License: Mozilla Public License 2.0 5 votes vote down vote up
protected List<String> wordWrap(String s) {
    String[] cleaned = filterPrintableWithNewline(HtmlUtils.htmlClean(s)).split("\n");
    List<String> result = new ArrayList<>();
    for (String item: cleaned) {
        String[] wrappedLine = WordUtils
                .wrap(item, 39, "\n", true)
                .split("\n");
        result.addAll(asList(wrappedLine));
    }
    return result;
}
 
Example 21
Source Project: petscii-bbs   Source File: TelevideoRai.java    License: Mozilla Public License 2.0 5 votes vote down vote up
protected String[] wordWrap(String s) {
    String[] cleaned = filterPrintableWithNewline(HtmlUtils.htmlClean(s)).replaceAll(" +", " ").split("\n");
    List<String> result = new LinkedList<>();
    for (String item: cleaned) {
        String[] wrappedLine = WordUtils
                .wrap(item, 39, "\n", true)
                .split("\n");
        result.addAll(asList(wrappedLine));
    }
    return Arrays.copyOf(result.toArray(), result.size(), String[].class);
}
 
Example 22
Source Project: petscii-bbs   Source File: ArnoldC64.java    License: Mozilla Public License 2.0 5 votes vote down vote up
private void listPosts(List<Entry> entries) {
    drawLogo();
    posts = getPosts(entries, currentPage, pageSize);
    for (Map.Entry<Integer, Entry> entry: posts.entrySet()) {
        int i = entry.getKey();
        Entry post = entry.getValue();
        write(WHITE); print(i + "."); write(GREY3);
        final int iLen = 37-String.valueOf(i).length();
        String title = post.name;
        String line = WordUtils.wrap(filterPrintable(HtmlUtils.htmlClean(title)), iLen, "\r", true);
        println(line.replaceAll("\r", "\r " + repeat(" ", 37-iLen)));
    }
    newline();
}
 
Example 23
Source Project: petscii-bbs   Source File: GoogleBloggerProxy.java    License: Mozilla Public License 2.0 5 votes vote down vote up
protected List<String> wordWrap(String s) {
    String[] cleaned = filterPrintableWithNewline(HtmlUtils.htmlClean(s)).split("\n");
    List<String> result = new ArrayList<>();
    for (String item: cleaned) {
        String[] wrappedLine = WordUtils
                .wrap(item, 39, "\n", true)
                .split("\n");
        result.addAll(asList(wrappedLine));
    }
    return result;
}
 
Example 24
Source Project: petscii-bbs   Source File: WordpressProxy.java    License: Mozilla Public License 2.0 5 votes vote down vote up
protected List<String> wordWrap(String s) {
    String[] cleaned = filterPrintableWithNewline(HtmlUtils.htmlClean(s)).split("\n");
    List<String> result = new ArrayList<>();
    for (String item: cleaned) {
        String[] wrappedLine = WordUtils
                .wrap(item, 39, "\n", true)
                .split("\n");
        result.addAll(asList(wrappedLine));
    }
    return result;
}
 
Example 25
Source Project: petscii-bbs   Source File: UserLogon.java    License: Mozilla Public License 2.0 5 votes vote down vote up
public void showPrivacyPolicy() throws Exception {
    List<String> rawText = readTextFile("gdpr/privacy-statement.txt");
    List<String> text = new ArrayList<>();
    for (String row: rawText)
        text.addAll(asList(WordUtils.wrap(row, 39, "\n", true).split("\n")));
    if (isEmpty(text)) return;
    int size = text.size();
    int pagesize = 18;
    int offset = 0;
    int cmd = 0;
    do {
        cls();
        write(LOGO_BYTES);
        write(GREY3);
        newline();
        for (int i = offset; i < Math.min(offset + pagesize, size); ++i) {
            println(text.get(i));

        }
        println();
        write(WHITE); print("SPACE");
        write(GREY3); print("=Next page [");
        write(WHITE); print("-");
        write(GREY3); print("]=Prev page [");
        write(WHITE); print(".");
        write(GREY3); print("]=EXIT");
        flush();
        resetInput();
        cmd = readKey();
        if (cmd == '.') {
            return;
        } else if (cmd == '-' && offset > 0) {
            offset -= pagesize;
        } else if (offset + pagesize < size) {
            offset += pagesize;
        }
    } while (true);
}
 
Example 26
Source Project: azure-cosmosdb-java   Source File: IncludedPath.java    License: MIT License 5 votes vote down vote up
private Collection<Index> getIndexCollection() {
    if (this.propertyBag != null && this.propertyBag.has(Constants.Properties.INDEXES)) {
        ArrayNode jsonArray = (ArrayNode) this.propertyBag.get(Constants.Properties.INDEXES);
        Collection<Index> result = new ArrayList<Index>();

        for (int i = 0; i < jsonArray.size(); i++) {
            JsonNode jsonObject = jsonArray.get(i);

            IndexKind indexKind = IndexKind.valueOf(WordUtils.capitalize(
                    jsonObject.get(Constants.Properties.INDEX_KIND).asText()));
            switch (indexKind) {
            case Hash:
                result.add(new HashIndex(jsonObject.toString()));
                break;
            case Range:
                result.add(new RangeIndex(jsonObject.toString()));
                break;
            case Spatial:
                result.add(new SpatialIndex(jsonObject.toString()));
                break;
            }
        }

        return result;
    }

    return null;
}
 
Example 27
Source Project: azure-cosmosdb-java   Source File: RangeIndex.java    License: MIT License 5 votes vote down vote up
/**
 * Gets data type.
 *
 * @return the data type.
 */
public DataType getDataType() {
    DataType result = null;
    try {
        result = DataType.valueOf(WordUtils.capitalize(super.getString(Constants.Properties.DATA_TYPE)));
    } catch (IllegalArgumentException e) {
        this.getLogger().warn("Invalid index dataType value {}.", super.getString(Constants.Properties.DATA_TYPE));
    }
    return result;
}
 
Example 28
Source Project: azure-cosmosdb-java   Source File: IndexingPolicy.java    License: MIT License 5 votes vote down vote up
/**
 * Gets the indexing mode (consistent or lazy).
 *
 * @return the indexing mode.
 */
public IndexingMode getIndexingMode() {
    IndexingMode result = IndexingMode.Lazy;
    try {
        result = IndexingMode.valueOf(WordUtils.capitalize(super.getString(Constants.Properties.INDEXING_MODE)));
    } catch (IllegalArgumentException e) {
        this.getLogger().warn("Invalid indexingMode value {}.", super.getString(Constants.Properties.INDEXING_MODE));
    }
    return result;
}
 
Example 29
Source Project: azure-cosmosdb-java   Source File: Trigger.java    License: MIT License 5 votes vote down vote up
/**
 * Get the type of the trigger.
 *
 * @return the trigger type.
 */
public TriggerType getTriggerType() {
    TriggerType result = TriggerType.Pre;
    try {
        result = TriggerType.valueOf(
                WordUtils.capitalize(super.getString(Constants.Properties.TRIGGER_TYPE)));
    } catch (IllegalArgumentException e) {
        // ignore the exception and return the default
        this.getLogger().warn("Invalid triggerType value {}.", super.getString(Constants.Properties.TRIGGER_TYPE));
    }
    return result;
}
 
Example 30
Source Project: jphp   Source File: PTextWord.java    License: Apache License 2.0 5 votes vote down vote up
@Signature
public PTextWord wrap(Environment env, int lineLength,
                      @Optional("null") Memory newLineString,
                      @Optional("false") boolean wrapLongWords) {
    return new PTextWord(env, WordUtils.wrap(
            text, lineLength, newLineString.isNull() ? null : newLineString.toString(), wrapLongWords
    ));
}