当前位置: 首页>>代码示例>>Java>>正文


Java PrettyPrintWriter类代码示例

本文整理汇总了Java中com.thoughtworks.xstream.io.xml.PrettyPrintWriter的典型用法代码示例。如果您正苦于以下问题:Java PrettyPrintWriter类的具体用法?Java PrettyPrintWriter怎么用?Java PrettyPrintWriter使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


PrettyPrintWriter类属于com.thoughtworks.xstream.io.xml包,在下文中一共展示了PrettyPrintWriter类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: createWriter

import com.thoughtworks.xstream.io.xml.PrettyPrintWriter; //导入依赖的package包/类
public HierarchicalStreamWriter createWriter(Writer out) {
	return new PrettyPrintWriter(out) {
		boolean CDATA = true;
		
		@SuppressWarnings("rawtypes")
		public void startNode(String name, Class clazz) {
			super.startNode(name, clazz);
		}
		protected void writeText(QuickWriter writer, String text) {
			if (CDATA) {
				writer.write("<![CDATA[");
				writer.write(text);
				writer.write("]]>");
			} else {
				writer.write(text);
			}
		}
	};
}
 
开发者ID:Leibnizhu,项目名称:AlipayWechatPlatform,代码行数:20,代码来源:MsgXmlUtil.java

示例2: createWriter

import com.thoughtworks.xstream.io.xml.PrettyPrintWriter; //导入依赖的package包/类
@Override
public HierarchicalStreamWriter createWriter(Writer out) {  
          return new PrettyPrintWriter(out) {  
              // 对所有xml节点的转换都增加CDATA标记  
              boolean cdata = true;  
     
              @Override
		public void startNode(String name, @SuppressWarnings("rawtypes") Class clazz) {  
                  super.startNode(name, clazz);  
              }  
     
              @Override
		protected void writeText(QuickWriter writer, String text) {  
                  if (cdata) {  
                      writer.write("<![CDATA[");  
                      writer.write(text);  
                      writer.write("]]>");  
                  } else {  
                      writer.write(text);  
                  }  
              }  
          };  
      }
 
开发者ID:tojaoomy,项目名称:private-WeChat,代码行数:24,代码来源:MessageUtil.java

示例3: createWriter

import com.thoughtworks.xstream.io.xml.PrettyPrintWriter; //导入依赖的package包/类
public HierarchicalStreamWriter createWriter(Writer out) {
    return new PrettyPrintWriter(out) {
        // 对所有xml节点的转换都增加CDATA标记
        boolean cdata = true;

        @SuppressWarnings("unchecked")
        public void startNode(String name, Class clazz) {
            super.startNode(name, clazz);
        }

        protected void writeText(QuickWriter writer, String text) {
            if (cdata) {
                writer.write("<![CDATA[");
                writer.write(text);
                writer.write("]]>");
            } else {
                writer.write(text);
            }
        }
    };
}
 
开发者ID:Evan1120,项目名称:wechat-api-java,代码行数:22,代码来源:MessageUtil.java

示例4: createWriter

import com.thoughtworks.xstream.io.xml.PrettyPrintWriter; //导入依赖的package包/类
public HierarchicalStreamWriter createWriter(Writer out) {
  return new PrettyPrintWriter(out) {
    // 对所有 xml 节点的转换都增加 CDATA 标记
    boolean cdata = true;

    @SuppressWarnings("rawtypes")
    public void startNode(String name, Class clazz) {
      super.startNode(name, clazz);
    }

    protected void writeText(QuickWriter writer, String text) {
      if (cdata) {
        writer.write("<![CDATA[");
        writer.write(text);
        writer.write("]]>");
      } else {
        writer.write(text);
      }
    }
  };
}
 
开发者ID:CharleyXu,项目名称:tulingchat,代码行数:22,代码来源:MessageUtil.java

示例5: createWriter

import com.thoughtworks.xstream.io.xml.PrettyPrintWriter; //导入依赖的package包/类
public HierarchicalStreamWriter createWriter(Writer out) {
	return new PrettyPrintWriter(out) {
		// 对所有xml节点的转换都增加CDATA标记
		boolean cdata = true;
		public void startNode(String name, @SuppressWarnings("rawtypes") Class clazz) {
			super.startNode(name, clazz);
		}
		protected void writeText(QuickWriter writer, String text) {
			if (cdata) {
				writer.write("<![CDATA[");
				writer.write(text);
				writer.write("]]>");
			} else {
				super.writeText(writer, text);
			}  
		}  
	};  
}
 
开发者ID:ctxsdhy,项目名称:dntown,代码行数:19,代码来源:MessageUtil.java

示例6: createWriter

import com.thoughtworks.xstream.io.xml.PrettyPrintWriter; //导入依赖的package包/类
public HierarchicalStreamWriter createWriter(Writer out) {
    return new PrettyPrintWriter(out) {
        // 对所有xml节点的转换都增加CDATA标记
        boolean cdata = true;

        public void startNode(String name, Class clazz) {
            super.startNode(name, clazz);
        }

        protected void writeText(QuickWriter writer, String text) {
            if (cdata) {
                writer.write("<![CDATA[");
                writer.write(text);
                writer.write("]]>");
            } else {
                writer.write(text);
            }
        }
    };
}
 
开发者ID:151376liujie,项目名称:wechat-core,代码行数:21,代码来源:MessageUtils.java

示例7: createWriter

import com.thoughtworks.xstream.io.xml.PrettyPrintWriter; //导入依赖的package包/类
@Override
public HierarchicalStreamWriter createWriter(Writer out) {
    return new PrettyPrintWriter(out) {
        @Override
        @SuppressWarnings("rawtypes")
        public void startNode(String name, Class clazz) {
            //节点属性 首字母大写 排除xml item
            if (!"xml".equals(name) && !"item".equals(name)) {
                name = name.substring(0, 1).toUpperCase() + name.substring(1);
            }
            super.startNode(name, clazz);
        }

        @Override
        protected void writeText(QuickWriter writer, String text) {
            // 对所有xml节点的转换都增加CDATA标记
            writer.write("<![CDATA[");
            writer.write(text);
            writer.write("]]>");
        }
    };
}
 
开发者ID:xmomen,项目名称:dms-webapp,代码行数:23,代码来源:MessageUtils.java

示例8: serialize

import com.thoughtworks.xstream.io.xml.PrettyPrintWriter; //导入依赖的package包/类
/**
 * Serializes the network state.
 *
 * @param networkManager the network state
 * @return the serialized network state as json {@link String}.
 */
@Override
public void serialize(final ZigBeeNetworkManager networkManager) {
    XStream stream = openStream();

    final List<Object> destinations = new ArrayList<Object>();

    for (ZigBeeNode node : networkManager.getNodes()) {
        ZigBeeNodeDao nodeDao = ZigBeeNodeDao.createFromZigBeeNode(node);
        destinations.add(nodeDao);
    }

    final File file = new File(networkStateFilePath + "/" + networkStateFileName + networkId + ".xml");
    try {
        BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(file), "UTF-8"));
        stream.marshal(destinations, new PrettyPrintWriter(writer));
        writer.flush();
        writer.close();
    } catch (IOException e) {
        logger.error("Error writing network state ", e);
    }

    logger.debug("Saving ZigBee network state: done.");
}
 
开发者ID:openhab,项目名称:org.openhab.binding.zigbee,代码行数:30,代码来源:ZigBeeNetworkStateSerializerImpl.java

示例9: getXstream

import com.thoughtworks.xstream.io.xml.PrettyPrintWriter; //导入依赖的package包/类
protected static XStream getXstream()
{
    if (xstream == null)
    {
        xstream = new XStream(new XppDriver()
        {
            @Override
            public HierarchicalStreamWriter createWriter(Writer out)
            {
                return new PrettyPrintWriter(out)
                {
                    @Override
                    protected void writeText(QuickWriter writer, String text)
                    {
                        writer.write("<![CDATA[");
                        writer.write(text);
                        writer.write("]]>");
                    }
                };
            }
        });
    }

    return xstream;
}
 
开发者ID:edwardluzi,项目名称:spring-social-wechat,代码行数:26,代码来源:Message.java

示例10: createWriter

import com.thoughtworks.xstream.io.xml.PrettyPrintWriter; //导入依赖的package包/类
public HierarchicalStreamWriter createWriter(Writer out) {
	return new PrettyPrintWriter(out) {
		// 对所有 xml 节点的转换都增加 CDATA 标记
		boolean cdata = true;

		@SuppressWarnings("rawtypes")
		public void startNode(String name, Class clazz) {
			super.startNode(name, clazz);
		}

		protected void writeText(QuickWriter writer, String text) {
			if (cdata) {
				writer.write("<![CDATA[");
				writer.write(text);
				writer.write("]]>");
			} else {
				writer.write(text);
			}
		}
	};
}
 
开发者ID:wjg1101766085,项目名称:wechat,代码行数:22,代码来源:MessageUtil.java

示例11: createWriter

import com.thoughtworks.xstream.io.xml.PrettyPrintWriter; //导入依赖的package包/类
public HierarchicalStreamWriter createWriter(Writer out) {
	return new PrettyPrintWriter(out) {
		// 对所有xml节点的转换都增加CDATA标记
		boolean cdata = true;

		public void startNode(String name, @SuppressWarnings("rawtypes") Class clazz) {
			super.startNode(name, clazz);
		}

		protected void writeText(QuickWriter writer, String text) {
			if (cdata) {
				writer.write("<![CDATA[");
				writer.write(text);
				writer.write("]]>");
			} else {
				writer.write(text);
			}
		}
	};
}
 
开发者ID:East196,项目名称:maker,代码行数:21,代码来源:MessageUtil.java

示例12: saveProfileContext

import com.thoughtworks.xstream.io.xml.PrettyPrintWriter; //导入依赖的package包/类
@Override
public synchronized void saveProfileContext(ProfileContext profileContext) {
    this.profileContext = profileContext;

    try (ObjectOutputStream profileContextOutputStream = xmlStream.createObjectOutputStream(
            new PrettyPrintWriter(
                    new OutputStreamWriter(
                            new BufferedOutputStream(
                                    Files.newOutputStream(profilesPath)
                            )
                    )
            )
    )) {
        profileContextOutputStream.writeObject(profileContext);
    } catch (Exception ex) {
        logger.severe(
                () -> String.format(
                        "Error while saving the options: %s",
                        Throwables.toStringWithStackTrace(ex)
                )
        );
    }
}
 
开发者ID:giancosta86,项目名称:EasyPmd,代码行数:24,代码来源:DefaultProfileContextRepository.java

示例13: createWriter

import com.thoughtworks.xstream.io.xml.PrettyPrintWriter; //导入依赖的package包/类
@Override
public HierarchicalStreamWriter createWriter(Writer out) {
	return new PrettyPrintWriter(out) {
		// 对所有xml节点的转换都增加CDATA标记
		boolean cdata = true;

		@SuppressWarnings("rawtypes")
		@Override
		public void startNode(String name, Class clazz) {
			super.startNode(name, clazz);
		}

		@Override
		protected void writeText(QuickWriter writer, String text) {
			if (cdata) {
				writer.write("<![CDATA[");
				writer.write(text);
				writer.write("]]>");
			} else {
				writer.write(text);
			}
		}
	};
}
 
开发者ID:Paleozoic,项目名称:open_wx,代码行数:25,代码来源:MsgUtil.java

示例14: buildXstream

import com.thoughtworks.xstream.io.xml.PrettyPrintWriter; //导入依赖的package包/类
private XStream buildXstream() {
	return new XStream(new XppDriver() {
		public HierarchicalStreamWriter createWriter(Writer out) {
			return new PrettyPrintWriter(out) {
				List<String> cdataFields = asList("title", "author");
				boolean cdata = false;
				
				public void startNode(String name, Class clazz) {
					super.startNode(name, clazz);
					cdata = cdataFields.contains(name);
				}
				protected void writeText(QuickWriter writer, String text) {
					if (cdata) {
						writer.write("<![CDATA[");
						writer.write(text);
						writer.write("]]>");
					} else {
						writer.write(text);
					}
				}
			};
		}
	});
}
 
开发者ID:caelum,项目名称:mamute,代码行数:25,代码来源:QuestionRssEntryFactory.java

示例15: saveToFile

import com.thoughtworks.xstream.io.xml.PrettyPrintWriter; //导入依赖的package包/类
/**
 * writes glossary to xml-file prepend doc-book dtd: <!DOCTYPE glossary PUBLIC "-//OASIS//DTD DocBook XML V4.1.2//EN"
 * "http://www.oasis-open.org/docbook/xml/4.1.2/docbookx.dtd">
 * 
 * @param glossaryFile
 * @param glossaryItemArr
 */
private void saveToFile(VFSLeaf glossaryFile, ArrayList<GlossaryItem> glossaryItemArr) {
    // cdata-tags should be used instead of strings, overwrite writer.
    XStream xstream = new XStream(new XppDriver() {
        @Override
        public HierarchicalStreamWriter createWriter(Writer out) {
            return new PrettyPrintWriter(out) {
                @Override
                protected void writeText(QuickWriter writer, String text) {
                    if (text.contains("<") || text.contains(">") || text.contains("&")) {
                        writer.write("<![CDATA[");
                        writer.write(text);
                        writer.write("]]>");
                    } else {
                        writer.write(text);
                    }
                }
            };
        }
    });

    xstream.alias(XML_GLOSSARY_ITEM_NAME, GlossaryItem.class);
    glossaryItemArr = removeEmptyGlossaryItems(glossaryItemArr);
    XStreamHelper.writeObject(xstream, glossaryFile, glossaryItemArr);
}
 
开发者ID:huihoo,项目名称:olat,代码行数:32,代码来源:GlossaryItemManager.java


注:本文中的com.thoughtworks.xstream.io.xml.PrettyPrintWriter类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。