Java 8 Characters - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Java 8 Characters class.

This code example shows how to use the following methods:getData, isCData, isIgnorableWhiteSpace
			} 
		} 
	} 
 
	private void handleCharacters(Characters characters) throws SAXException {
		char[] data = characters.getData().toCharArray();
		if (getContentHandler() != null && characters.isIgnorableWhiteSpace()) {
			getContentHandler().ignorableWhitespace(data, 0, data.length);
			return; 
		} 
		if (characters.isCData() && getLexicalHandler() != null) {
			getLexicalHandler().startCDATA(); 
		} 
		if (getContentHandler() != null) { 
			getContentHandler().characters(data, 0, data.length);
		} 
		if (characters.isCData() && getLexicalHandler() != null) {
			getLexicalHandler().endCDATA(); 
		} 
	} 

7
CodeRank
This code example shows how to use the following methods:getData, isCData, isIgnorableWhiteSpace, isWhiteSpace
    if (this == o)
      return true; 
 
    Characters characters = (Characters) o;
 
    return getData().equals(characters.getData()) &&
           isCData() == characters.isCData() &&
           isIgnorableWhiteSpace() == characters.isIgnorableWhiteSpace() &&
           isWhiteSpace() == characters.isWhiteSpace();
  } 
} 
 
6
CodeRank
This code example shows how to use the following methods:getData, isCData, isIgnorableWhiteSpace, isWhiteSpace
	public void testCharactersCData() throws XMLStreamException {
		XMLStreamReader reader = createXmlStreamReader("<alice>bob</alice>");
		reader.next();
		Characters characters = eventAllocator.allocate(reader).asCharacters();
		verify(characters, XMLStreamConstants.CHARACTERS, "bob");
		Assert.assertEquals("bob", characters.getData());
		Assert.assertFalse(characters.isCData());
		Assert.assertFalse(characters.isWhiteSpace());
		Assert.assertFalse(characters.isIgnorableWhiteSpace());
 
		reader = createXmlStreamReader("<alice><![CDATA[bob]]></alice>");
		reader.next();
		characters = eventAllocator.allocate(reader).asCharacters();
		verify(characters, XMLStreamConstants.CDATA, "<![CDATA[bob]]>");
		Assert.assertEquals("bob", characters.getData());
		Assert.assertTrue(characters.isCData());
 
		reader = createXmlStreamReader("<alice><![CDATA[ ]]></alice>");
		reader.next();
		characters = eventAllocator.allocate(reader).asCharacters();
6
CodeRank
This code example shows how to use the following methods:isIgnorableWhiteSpace, isWhiteSpace
 
	@Test
	public void testCreateSpace() throws XMLStreamException {
		Characters event = factory.createSpace(" ");
		verify(event, XMLStreamConstants.CHARACTERS, " ");
		Assert.assertTrue(event.isWhiteSpace());
		Assert.assertFalse(event.isIgnorableWhiteSpace());
	} 
 
	@Test
	public void testCreateIgnorableSpace() throws XMLStreamException {
		Characters event = factory.createIgnorableSpace(" ");
		verify(event, XMLStreamConstants.SPACE, "");
		Assert.assertTrue(event.isWhiteSpace());
		Assert.assertTrue(event.isIgnorableWhiteSpace());
	} 
 
	@Test
	public void testCreateStartDocument() throws XMLStreamException {
		StartDocument event = factory.createStartDocument();
5
CodeRank
This code example shows how to use the following methods:getData, isIgnorableWhiteSpace, isWhiteSpace
    private void collectEventInfo(Characters characters) {
        if (currentObjects.size() == 0) { 
            return; 
        } 
 
        if (characters.isIgnorableWhiteSpace() || characters.isWhiteSpace()) {
            return; 
        } 
 
        String text = characters.getData();
 
        if (currentObjects.peek().containsKey(parents.peek().getName().getLocalPart() + "_value")) {
            String oldText = (String) currentObjects.peek().get(parents.peek().getName().getLocalPart() + "_value");
            text = oldText + text;
        } 
 
        currentObjects.peek().put(parents.peek().getName().getLocalPart() + "_value", text);
    } 
 
    @SuppressWarnings("unchecked") 
4
CodeRank
This code example shows how to use the following methods:getData
            xmlEventReader = xmlInputFactory.createFilteredReader(xmlEventReader, new EventFilter() {
                public boolean accept(XMLEvent xmlEvent) {
                    // We are going to disregard characters that are new line and whitespace 
                    if (xmlEvent.isCharacters()) {
                        Characters chars = xmlEvent.asCharacters();
                        String data = chars.getData();
                        data = valid(data) ? data.trim() : null;
                        return valid(data);
                    } else { 
                        return xmlEvent.isStartElement() || xmlEvent.isEndElement();
                    } 
                } 
 
                private boolean valid(String str) {
                    return str != null && str.length() > 0;
                } 
            }); 
        } catch (XMLStreamException e) {
            throw logger.parserException(e);
        } 
4
CodeRank
This code example shows how to use the following methods:getData
	 */ 
	PrettyXMLWhitespaceHandler(final XMLStreamWriter writer, String indentation, String newline) {
		this(indentation, newline, new WhitespaceWriter() {
			@Override 
			public void add(Characters event) throws XMLStreamException {
				writer.writeCharacters(event.getData());
			} 
		}); 
	} 
 
	/** 
	 * Create whitespace handler for an {@link XMLEventWriter}. 
	 *  
	 * @param writer 
	 *            event writer 
	 * @param indentation 
	 *            line indentation 
	 * @param newline 
	 *            line separator 
	 */ 
4
CodeRank
This code example shows how to use the following methods:getData
            return null; 
        return parseDouble(attribute.getValue());
    } 
 
    private String extractValue(Characters chars, String value) {
        String append = trim(chars.getData());
        if (append == null)
            return value;
        if (value == null)
            return append;
        return value + append;
    } 
 
    private Wgs84Position processPosition(StartElement startElement) {
        return asWgs84Position(extractValue(startElement, X_ATTRIBUTE), extractValue(startElement, Y_ATTRIBUTE));
    } 
 
    private List<MagicMapsIktRoute> process(XMLEventReader eventReader) throws XMLStreamException {
        boolean hasValidRoot = false, nextIsProjectName = false, nextIsDescription = false, nextIsName = false;
        String projectName = null, description = null, name = null;
4
CodeRank
This code example shows how to use the following methods:getData
      this.real = real;
    } 
 
    @Override 
    public String getData() {
      return real.getData();
    } 
 
  } 
 
} 
3
CodeRank
This code example shows how to use the following methods:getData
    } 
 
    private void handleCDATA(Characters event) throws SAXExceptionthis.filter.startCDATA();
        this.filter.characters(event.getData().toCharArray(), 0, event.getData().length());
        this.filter.endCDATA();
    } 
} 
4
CodeRank
See Code Examples for Java 8 Characters Methods: