org.apache.batik.xml.XMLUtilities.isXMLSpace()方法的使用及代码示例

x33g5p2x  于2022-02-03 转载在 其他  
字(8.9k)|赞(0)|评价(0)|浏览(188)

本文整理了Java中org.apache.batik.xml.XMLUtilities.isXMLSpace()方法的一些代码示例,展示了XMLUtilities.isXMLSpace()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。XMLUtilities.isXMLSpace()方法的具体详情如下:
包路径:org.apache.batik.xml.XMLUtilities
类名称:XMLUtilities
方法名:isXMLSpace

XMLUtilities.isXMLSpace介绍

[英]Tests whether the given character is a valid space.
[中]测试给定字符是否为有效空格。

代码示例

代码示例来源:origin: fr.avianey.apache-xmlgraphics/batik

  1. /**
  2. * Tells whether the given character represents white spaces.
  3. */
  4. protected boolean isWhiteSpace(char[] text) {
  5. for (int i = 0; i < text.length; i++) {
  6. if (!XMLUtilities.isXMLSpace(text[i])) {
  7. return false;
  8. }
  9. }
  10. return true;
  11. }

代码示例来源:origin: apache/batik

  1. /**
  2. * Tells whether the given character represents white spaces.
  3. */
  4. protected boolean isWhiteSpace(char[] text) {
  5. for (char aText : text) {
  6. if (!XMLUtilities.isXMLSpace(aText)) {
  7. return false;
  8. }
  9. }
  10. return true;
  11. }

代码示例来源:origin: fr.avianey.apache-xmlgraphics/batik

  1. protected int skipSpaces() {
  2. do {
  3. nextChar();
  4. } while (current != -1 && XMLUtilities.isXMLSpace((char)current));
  5. return current;
  6. }

代码示例来源:origin: apache/batik

  1. protected int skipSpaces() {
  2. do {
  3. nextChar();
  4. } while (current != -1 && XMLUtilities.isXMLSpace((char)current));
  5. return current;
  6. }

代码示例来源:origin: fr.avianey.apache-xmlgraphics/batik

  1. /**
  2. * Returns the next lexical unit in the context of a start tag.
  3. */
  4. private int scanElement() {
  5. //position = position + 1; // to skip the first <
  6. while (current != -1) {
  7. if (current == '>') {
  8. return CHARACTER_DATA_CONTEXT;
  9. } else if (XMLUtilities.isXMLSpace((char)current)) {
  10. return ATTRIBUTE_NAME_CONTEXT;
  11. }
  12. nextChar();
  13. }
  14. if (current == -1) {
  15. return EOF_CONTEXT;
  16. }
  17. return ELEMENT_CONTEXT;
  18. }

代码示例来源:origin: apache/batik

  1. /**
  2. * Returns the next lexical unit in the context of a start tag.
  3. */
  4. private int scanElement() {
  5. //position = position + 1; // to skip the first <
  6. while (current != -1) {
  7. if (current == '>') {
  8. return CHARACTER_DATA_CONTEXT;
  9. } else if (XMLUtilities.isXMLSpace((char)current)) {
  10. return ATTRIBUTE_NAME_CONTEXT;
  11. }
  12. nextChar();
  13. }
  14. if (current == -1) {
  15. return EOF_CONTEXT;
  16. }
  17. return ELEMENT_CONTEXT;
  18. }

代码示例来源:origin: org.apache.xmlgraphics/batik-dom

  1. /**
  2. * Splits a whitespace separated string into tokens.
  3. */
  4. protected String[] split(String s) {
  5. List a = new ArrayList(8);
  6. StringBuffer sb;
  7. int i = 0;
  8. int len = s.length();
  9. while (i < len) {
  10. char c = s.charAt(i++);
  11. if (XMLUtilities.isXMLSpace(c)) {
  12. continue;
  13. }
  14. sb = new StringBuffer();
  15. sb.append(c);
  16. while (i < len) {
  17. c = s.charAt(i++);
  18. if (XMLUtilities.isXMLSpace(c)) {
  19. a.add(sb.toString());
  20. break;
  21. }
  22. sb.append(c);
  23. }
  24. if (i == len) {
  25. a.add(sb.toString());
  26. }
  27. }
  28. return (String[]) a.toArray(new String[a.size()]);
  29. }
  30. }

代码示例来源:origin: fr.avianey.apache-xmlgraphics/batik

  1. /**
  2. * Splits a whitespace separated string into tokens.
  3. */
  4. protected String[] split(String s) {
  5. List a = new ArrayList(8);
  6. StringBuffer sb;
  7. int i = 0;
  8. int len = s.length();
  9. while (i < len) {
  10. char c = s.charAt(i++);
  11. if (XMLUtilities.isXMLSpace(c)) {
  12. continue;
  13. }
  14. sb = new StringBuffer();
  15. sb.append(c);
  16. while (i < len) {
  17. c = s.charAt(i++);
  18. if (XMLUtilities.isXMLSpace(c)) {
  19. a.add(sb.toString());
  20. break;
  21. }
  22. sb.append(c);
  23. }
  24. if (i == len) {
  25. a.add(sb.toString());
  26. }
  27. }
  28. return (String[]) a.toArray(new String[a.size()]);
  29. }
  30. }

代码示例来源:origin: org.apache.xmlgraphics/batik-dom

  1. /**
  2. * <b>DOM</b>: Implements
  3. * {@link org.w3c.dom.Text#isElementContentWhitespace()}.
  4. */
  5. public boolean isElementContentWhitespace() {
  6. int len = nodeValue.length();
  7. for (int i = 0; i < len; i++) {
  8. if (!XMLUtilities.isXMLSpace(nodeValue.charAt(i))) {
  9. return false;
  10. }
  11. }
  12. Node p = getParentNode();
  13. if (p.getNodeType() == Node.ELEMENT_NODE) {
  14. String sp = XMLSupport.getXMLSpace((Element) p);
  15. return !sp.equals(XMLConstants.XML_PRESERVE_VALUE);
  16. }
  17. return true;
  18. }

代码示例来源:origin: fr.avianey.apache-xmlgraphics/batik

  1. /**
  2. * <b>DOM</b>: Implements
  3. * {@link org.w3c.dom.Text#isElementContentWhitespace()}.
  4. */
  5. public boolean isElementContentWhitespace() {
  6. int len = nodeValue.length();
  7. for (int i = 0; i < len; i++) {
  8. if (!XMLUtilities.isXMLSpace(nodeValue.charAt(i))) {
  9. return false;
  10. }
  11. }
  12. Node p = getParentNode();
  13. if (p.getNodeType() == Node.ELEMENT_NODE) {
  14. String sp = XMLSupport.getXMLSpace((Element) p);
  15. return !sp.equals(XMLConstants.XML_PRESERVE_VALUE);
  16. }
  17. return true;
  18. }

代码示例来源:origin: apache/batik

  1. /**
  2. * <b>DOM</b>: Implements
  3. * {@link org.w3c.dom.Text#isElementContentWhitespace()}.
  4. */
  5. public boolean isElementContentWhitespace() {
  6. int len = nodeValue.length();
  7. for (int i = 0; i < len; i++) {
  8. if (!XMLUtilities.isXMLSpace(nodeValue.charAt(i))) {
  9. return false;
  10. }
  11. }
  12. Node p = getParentNode();
  13. if (p.getNodeType() == Node.ELEMENT_NODE) {
  14. String sp = XMLSupport.getXMLSpace((Element) p);
  15. return !sp.equals(XMLConstants.XML_PRESERVE_VALUE);
  16. }
  17. return true;
  18. }

代码示例来源:origin: fr.avianey.apache-xmlgraphics/batik

  1. /**
  2. * Returns the next lexical unit in the context of an enumeration.
  3. */
  4. protected int nextInEnumeration() throws IOException, XMLException {
  5. switch (current) {
  6. case 0x9:
  7. case 0xA:
  8. case 0xD:
  9. case 0x20:
  10. do {
  11. nextChar();
  12. } while (current != -1 && XMLUtilities.isXMLSpace((char)current));
  13. return LexicalUnits.S;
  14. case '|':
  15. nextChar();
  16. return LexicalUnits.PIPE;
  17. case ')':
  18. nextChar();
  19. context = ATTLIST_CONTEXT;
  20. return LexicalUnits.RIGHT_BRACE;
  21. default:
  22. return readNmtoken();
  23. }
  24. }

代码示例来源:origin: org.apache.xmlgraphics/batik-xml

  1. /**
  2. * Returns the next lexical unit in the context of an enumeration.
  3. */
  4. protected int nextInEnumeration() throws IOException, XMLException {
  5. switch (current) {
  6. case 0x9:
  7. case 0xA:
  8. case 0xD:
  9. case 0x20:
  10. do {
  11. nextChar();
  12. } while (current != -1 && XMLUtilities.isXMLSpace((char)current));
  13. return LexicalUnits.S;
  14. case '|':
  15. nextChar();
  16. return LexicalUnits.PIPE;
  17. case ')':
  18. nextChar();
  19. context = ATTLIST_CONTEXT;
  20. return LexicalUnits.RIGHT_BRACE;
  21. default:
  22. return readNmtoken();
  23. }
  24. }

代码示例来源:origin: apache/batik

  1. /**
  2. * Returns the next lexical unit in the context of an enumeration.
  3. */
  4. protected int nextInEnumeration() throws IOException, XMLException {
  5. switch (current) {
  6. case 0x9:
  7. case 0xA:
  8. case 0xD:
  9. case 0x20:
  10. do {
  11. nextChar();
  12. } while (current != -1 && XMLUtilities.isXMLSpace((char)current));
  13. return LexicalUnits.S;
  14. case '|':
  15. nextChar();
  16. return LexicalUnits.PIPE;
  17. case ')':
  18. nextChar();
  19. context = ATTLIST_CONTEXT;
  20. return LexicalUnits.RIGHT_BRACE;
  21. default:
  22. return readNmtoken();
  23. }
  24. }

代码示例来源:origin: org.apache.xmlgraphics/batik-xml

  1. /**
  2. * Returns the next lexical unit in the context of a end tag.
  3. */
  4. protected int nextInEndTag() throws IOException, XMLException {
  5. switch (current) {
  6. case 0x9:
  7. case 0xA:
  8. case 0xD:
  9. case 0x20:
  10. do {
  11. nextChar();
  12. } while (current != -1 &&
  13. XMLUtilities.isXMLSpace((char)current));
  14. return LexicalUnits.S;
  15. case '>':
  16. if (--depth < 0) {
  17. throw createXMLException("unexpected.end.tag");
  18. } else if (depth == 0) {
  19. context = TOP_LEVEL_CONTEXT;
  20. } else {
  21. context = CONTENT_CONTEXT;
  22. }
  23. nextChar();
  24. return LexicalUnits.END_CHAR;
  25. default:
  26. throw createXMLException("invalid.character");
  27. }
  28. }

代码示例来源:origin: fr.avianey.apache-xmlgraphics/batik

  1. /**
  2. * Returns the next lexical unit in the context of a end tag.
  3. */
  4. protected int nextInEndTag() throws IOException, XMLException {
  5. switch (current) {
  6. case 0x9:
  7. case 0xA:
  8. case 0xD:
  9. case 0x20:
  10. do {
  11. nextChar();
  12. } while (current != -1 &&
  13. XMLUtilities.isXMLSpace((char)current));
  14. return LexicalUnits.S;
  15. case '>':
  16. if (--depth < 0) {
  17. throw createXMLException("unexpected.end.tag");
  18. } else if (depth == 0) {
  19. context = TOP_LEVEL_CONTEXT;
  20. } else {
  21. context = CONTENT_CONTEXT;
  22. }
  23. nextChar();
  24. return LexicalUnits.END_CHAR;
  25. default:
  26. throw createXMLException("invalid.character");
  27. }
  28. }

代码示例来源:origin: apache/batik

  1. /**
  2. * Returns the next lexical unit in the context of a end tag.
  3. */
  4. protected int nextInEndTag() throws IOException, XMLException {
  5. switch (current) {
  6. case 0x9:
  7. case 0xA:
  8. case 0xD:
  9. case 0x20:
  10. do {
  11. nextChar();
  12. } while (current != -1 &&
  13. XMLUtilities.isXMLSpace((char)current));
  14. return LexicalUnits.S;
  15. case '>':
  16. if (--depth < 0) {
  17. throw createXMLException("unexpected.end.tag");
  18. } else if (depth == 0) {
  19. context = TOP_LEVEL_CONTEXT;
  20. } else {
  21. context = CONTENT_CONTEXT;
  22. }
  23. nextChar();
  24. return LexicalUnits.END_CHAR;
  25. default:
  26. throw createXMLException("invalid.character");
  27. }
  28. }

代码示例来源:origin: fr.avianey.apache-xmlgraphics/batik

  1. /**
  2. * Returns the next lexical unit in the context of a notation type.
  3. */
  4. protected int nextInNotationType() throws IOException, XMLException {
  5. switch (current) {
  6. case 0x9:
  7. case 0xA:
  8. case 0xD:
  9. case 0x20:
  10. do {
  11. nextChar();
  12. } while (current != -1 && XMLUtilities.isXMLSpace((char)current));
  13. return LexicalUnits.S;
  14. case '|':
  15. nextChar();
  16. return LexicalUnits.PIPE;
  17. case '(':
  18. nextChar();
  19. return LexicalUnits.LEFT_BRACE;
  20. case ')':
  21. nextChar();
  22. context = ATTLIST_CONTEXT;
  23. return LexicalUnits.RIGHT_BRACE;
  24. default:
  25. return readName(LexicalUnits.NAME);
  26. }
  27. }

代码示例来源:origin: org.apache.xmlgraphics/batik-xml

  1. /**
  2. * Returns the next lexical unit in the context of a notation type.
  3. */
  4. protected int nextInNotationType() throws IOException, XMLException {
  5. switch (current) {
  6. case 0x9:
  7. case 0xA:
  8. case 0xD:
  9. case 0x20:
  10. do {
  11. nextChar();
  12. } while (current != -1 && XMLUtilities.isXMLSpace((char)current));
  13. return LexicalUnits.S;
  14. case '|':
  15. nextChar();
  16. return LexicalUnits.PIPE;
  17. case '(':
  18. nextChar();
  19. return LexicalUnits.LEFT_BRACE;
  20. case ')':
  21. nextChar();
  22. context = ATTLIST_CONTEXT;
  23. return LexicalUnits.RIGHT_BRACE;
  24. default:
  25. return readName(LexicalUnits.NAME);
  26. }
  27. }

代码示例来源:origin: apache/batik

  1. /**
  2. * Returns the next lexical unit in the context of a notation type.
  3. */
  4. protected int nextInNotationType() throws IOException, XMLException {
  5. switch (current) {
  6. case 0x9:
  7. case 0xA:
  8. case 0xD:
  9. case 0x20:
  10. do {
  11. nextChar();
  12. } while (current != -1 && XMLUtilities.isXMLSpace((char)current));
  13. return LexicalUnits.S;
  14. case '|':
  15. nextChar();
  16. return LexicalUnits.PIPE;
  17. case '(':
  18. nextChar();
  19. return LexicalUnits.LEFT_BRACE;
  20. case ')':
  21. nextChar();
  22. context = ATTLIST_CONTEXT;
  23. return LexicalUnits.RIGHT_BRACE;
  24. default:
  25. return readName(LexicalUnits.NAME);
  26. }
  27. }

相关文章