當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。