Examples of StringDocument


Examples of com.couchbase.client.java.document.StringDocument

        converter = new StringTranscoder();
    }

    @Test
    public void shouldEncodeString() {
        StringDocument document = StringDocument.create("id", "value");
        Tuple2<ByteBuf, Integer> encoded = converter.encode(document);

        assertEquals("value", encoded.value1().toString(CharsetUtil.UTF_8));
        assertEquals(TranscoderUtils.STRING_COMPAT_FLAGS, (long) encoded.value2());
    }
View Full Code Here

Examples of com.couchbase.client.java.document.StringDocument

    }

    @Test
    public void shouldDecodeCommonString() {
        ByteBuf content = Unpooled.copiedBuffer("value", CharsetUtil.UTF_8);
        StringDocument decoded = converter.decode("id", content, 0, 0, TranscoderUtils.STRING_COMMON_FLAGS,
            ResponseStatus.SUCCESS);

        assertEquals("value", decoded.content());
    }
View Full Code Here

Examples of com.couchbase.client.java.document.StringDocument

    }

    @Test
    public void shouldDecodeLegacyString() {
        ByteBuf content = Unpooled.copiedBuffer("value", CharsetUtil.UTF_8);
        StringDocument decoded = converter.decode("id", content, 0, 0, 0,
            ResponseStatus.SUCCESS);

        assertEquals("value", decoded.content());
    }
View Full Code Here

Examples of com.couchbase.client.java.document.StringDocument

    }

    @Test
    public void shouldReleaseBufferWhenDecoded() {
        ByteBuf content = Unpooled.copiedBuffer("value", CharsetUtil.UTF_8);
        StringDocument decoded = converter.decode("id", content, 0, 0, TranscoderUtils.STRING_COMMON_FLAGS,
            ResponseStatus.SUCCESS);
        assertEquals(0, content.refCnt());
    }
View Full Code Here

Examples of edu.ucla.sspace.text.StringDocument

                // process it as a single document.  For consistency, strip off
                // the USENET threading formatting, e.g. >>>, from the front of
                // each line.
                while ((line = usenetReader.readLine()) != null) {
                    if (line.contains(END_OF_DOCUMENT))
                        return new StringDocument(cleanDoc(content.toString()));
                    else {
                        int lineStart = 0;
                        // Find the first non '>' or ' ' in the line to
                        // determine where the auto-threading formatting stops.
                        for (char c = line.charAt(lineStart);
View Full Code Here

Examples of edu.ucla.sspace.text.StringDocument

                        context.append("|||| ");
                        tokens[i] = lemma;
                    }
                    context.append(tokens[i]).append(" ");
                }
                contexts.add(new StringDocument(context.toString()));
                context.setLength(0);
            }
        }
View Full Code Here

Examples of edu.ucla.sspace.text.StringDocument

                inHead = false;
            else if (name.equals("lexelt"))
                inLexElement = false;
            else if (name.equals("context")) {
                inContext = false;
                contexts.add(new StringDocument(context.toString()));
                context.setLength(0);
            }
        }
View Full Code Here

Examples of edu.ucla.sspace.text.StringDocument

                        // that substring.
                        if (endIndex > startIndex) {
                            String extractedContent =
                                line.substring(startIndex, endIndex);
                            extractedContent = cleanDoc(extractedContent);
                            return new StringDocument(extractedContent);
                        }
                        // Otherwise create a new builder and everything
                        // appearing after the content tag.
                        else  {
                            content = new StringBuilder(line.substring(
                                        startIndex));
                            inContent = true;
                        }
                    } else if (line.contains("</content>")) {
                        inContent = false;
                        // If this is the end of the content, extract everything
                        // before it and return the total amount of text
                        // extracted.
                        int endIndex = line.lastIndexOf("<");
                        content.append(line.substring(0, endIndex));

                        return new StringDocument(cleanDoc(content.toString()));
                    } else if (line.contains("<updated>") && content != null) {
                        // When the line has an updated tag and content is not
                        // null, we need to extract the date time and prepend it
                        // to the content.
                        int startIndex = line.indexOf(">")+1;
                        int endIndex = line.lastIndexOf("<");
                        String date = line.substring(startIndex, endIndex);
                        long dateTime = date.equals("")
                            ? 0 :
                            Timestamp.valueOf(date).getTime();
                        String doc = String.format(
                                "%d %s", dateTime,
                                cleanDoc(content.toString()));
                        return new StringDocument(doc);
                    } else if (inContent && content != null) {
                        // If the content builder has been created, we know this
                        // line contains content.  Add it to the builder.
                        content.append(line);
                    }
View Full Code Here

Examples of edu.ucla.sspace.text.StringDocument

                    addTextFromUtterance((Element) utterances.item(i),
                                         utteranceBuilder);
                    utteranceBuilder.append(". ");
                }
            }
            return new StringDocument(utteranceBuilder.toString());
        }
View Full Code Here

Examples of edu.ucla.sspace.text.StringDocument

        /**
         * {@inheritDoc}
         */
        public synchronized Document next() {
            Document doc = new StringDocument(currentDoc);
            currentDoc = advance();
            return doc;
        }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.