⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 catalogsearchquery.java

📁 基于jxta的文件共享和聊天系统源代码,下载下来分析吧
💻 JAVA
字号:
/* * Created on 10-ott-2006 * * TODO To change the template for this generated file go to * Window - Preferences - Java - Code Style - Code Templates */package catalog_search;import gui.MainWindow;import java.io.InputStream;import java.io.StringWriter;import java.util.Enumeration;import net.jxta.document.Document;import net.jxta.document.Element;import net.jxta.document.MimeMediaType;import net.jxta.document.StructuredDocument;import net.jxta.document.StructuredDocumentFactory;import net.jxta.document.StructuredTextDocument;import net.jxta.document.TextElement;/** * @author magowiz * * TODO To change the template for this generated type comment go to * Window - Preferences - Java - Code Style - Code Templates */public class CatalogSearchQuery {	private String title;	private String description;	private String [] catalog;	private MainWindow mw;	private boolean ow;	private boolean op;		public CatalogSearchQuery(){}		public CatalogSearchQuery(String t,String d,String []c,MainWindow mw,boolean ow, boolean op)	{		title=t;		description=d;		catalog=c;		this.mw=mw;		this.op=op;		this.ow=ow;	}			private String boolToString(boolean b)	{		String a=null;		if(b)			a="true";		if(!b)			a="false";		return a;	}		private boolean StringTobool(String s)	{		boolean r;		if(s.equals("true"))			r=true;		else			r=false;		return r;	}			public Document getDocument(MimeMediaType asMimeType)  		  {		 StructuredDocument document = (StructuredTextDocument) 	          StructuredDocumentFactory.newStructuredDocument(	              asMimeType, "example:ExampleQuery");	      Element element;	      element = document.createElement("searchTitle",title);	      document.appendChild(element);	  	  element=document.createElement("searchDescription",description);	      document.appendChild(element);	      	      element=document.createElement("searchOw",boolToString(ow));	      document.appendChild(element);	      element=document.createElement("searchOp",boolToString(op));	      document.appendChild(element);	      if(catalog!=null){	      for(int i=0;i<catalog.length;i++)	    	  	{	    	  		element=document.createElement("searchCatalog",catalog[i]);	    	  		document.appendChild(element);	      		}	      }	      return document;	  }		public CatalogSearchQuery (InputStream stream) 	 {		StructuredTextDocument document=null;	    try{ 		 document = (StructuredTextDocument) 	         StructuredDocumentFactory.newStructuredDocument(	             new MimeMediaType("text/xml"), stream);	    }	    catch(Exception e){e.printStackTrace();}	    	     Enumeration elements = document.getChildren();	     int i=0;	     int x=0;	     elements = document.getChildren();	     while (elements.hasMoreElements())	     {	    	 	    	 	         Element el = (Element) elements.nextElement();	         TextElement element = (TextElement) el;	         	        	         if(element.getName().equals("searchTitle"))	         {	         	 title = element.getTextValue();	             continue;	         }	         if(element.getName().equals("searchDescription"))	         {	         	 description = element.getTextValue();	         	 	             continue;	         }	         	         if(element.getName().equals("searchOw"))	         {	         	 ow = StringTobool(element.getTextValue());	         	 	             continue;	         }	         if(element.getName().equals("searchOp"))	         {	         	 op = StringTobool(element.getTextValue());	         	 	             continue;	         }	         	         if(element.getName().equals("searchCatalog"))	         {	        	 	         	 String []c= new String[x+1];	         	 if (catalog==null)	         		 {	         		 	catalog = new String[1];	         		 	catalog[0]=element.getTextValue();	         		 }	         	 else {	         		 		for (int a=0;a<catalog.length;a++)	         		 			c[a]=catalog[a];	         		 		c [x]= element.getTextValue();	         		 		catalog=c;	         		 }	         	 	         	 	             x++;	         	 continue;	         }	         	         	         	         	     } 	     	                 		 }		public String toString()	 {	     try	     {	         StringWriter out = new StringWriter();	         StructuredTextDocument doc = 	             (StructuredTextDocument) getDocument(	                 new MimeMediaType("text/xml"));	         doc.sendToWriter(out);	         return out.toString();	     }	     catch (Exception e)	     {	        e.printStackTrace(); 	     	return "";	     }	 }		/**	 * @return the op	 */	public boolean isOp() {		return op;	}	/**	 * @return the ow	 */	public boolean isOw() {		return ow;	}	public String getSearchTitle()	{		return this.title;	}	public String getSearchDescription()	{		return this.description;	}	public String  getSearchCatalog(int x)	{		if(x<catalog.length)			return this.catalog[x];		else			return null;	}		public int getCatN()	{		return this.catalog.length;			}		public MainWindow getMainWindow()	{		return this.mw;	}	}	

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -