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

📄 configurationinfo.java

📁 We intend to develop a wifi enabled p2p file sharing system on a linux platform using jxta and java.
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
				Element elem = null;
				// max uploads per hour
				elem = doc.createElement(xmlMaxUploadsPerHourTag);
				elem.appendChild(doc.createTextNode(String.valueOf(maxUploadsPerHour)));
				root.appendChild(elem);

				// known nodes only
				int nVal = 0;
				elem = doc.createElement(xmlKnownNodesOnlyTag);
				nVal = 0;
				if (knownNodesOnly)
					nVal = 1;
				elem.appendChild(doc.createTextNode(String.valueOf(nVal)));
				root.appendChild(elem);

				// autodownload
				elem = doc.createElement(xmlAutoDownloadModeTag);
				nVal = 0;
				if (autoDownloadMode)
					nVal = 1;
				elem.appendChild(doc.createTextNode(String.valueOf(nVal)));
				root.appendChild(elem);

				// music profiles
				//PopulateMP();
				//////////////////////
				Element mfnode = doc.createElement(xmlMusicProfilesTag);
				root.appendChild(mfnode);

				if (musicProfileVector != null) {
					Iterator mfiter = musicProfileVector.iterator();
					MusicProfile mfcurr = null;
					while(mfiter.hasNext()) {
						mfcurr = (MusicProfile)mfiter.next();
						mfnode.appendChild(mfcurr.xmlNode(doc));
					}
				}


				OutputFormat    format  = new OutputFormat(doc);   //Serialize DOM
				StringWriter  stringOut = new StringWriter();        //Writer will be a String
				XMLSerializer    serial = new XMLSerializer(stringOut, format);
				serial.asDOMSerializer();                            // As a DOM Serializer
				serial.serialize(doc.getDocumentElement());
				DebugOut("OBJECT STRXML = " + stringOut.toString());
				return stringOut.toString();
			}
			catch(Exception ex) {
				DebugOut("ERROR: creating XML");
				ex.printStackTrace();
			}
			return "<error/>";
		}
	// -----------------------------------------------------------------------


    // -----------------------------------------------------------------------
    /**

		 * Write all configuration information to the config file

		 * @return success

     */
	public boolean save()

	{
	    boolean success=false;
	    FileIOHelper fileIOHelperObject = new FileIOHelper();
	    success = fileIOHelperObject.FileWrite(ConfigFilename, xml());
	    return(success);
	}
	// -----------------------------------------------------------------------



	// -----------------------------------------------------------------------
    /**

     * Gets the music profile vector

     * @return a vector of MusicProfiles

     */
    public Vector getMusicProfileVector()

    {
		if (musicProfileVector == null)
			musicProfileVector = new Vector();
        return(musicProfileVector);
    }
	// -----------------------------------------------------------------------


	// -----------------------------------------------------------------------
    /**

     * Gets the maximum uploads per hour allowed by this user

     * @return an integer representing the number of uploads in one hour

     */
	public int getMaxUploadsPerHour()

	{
	    return(maxUploadsPerHour);
	}
	// -----------------------------------------------------------------------


	// -----------------------------------------------------------------------
    /**

     * Gets a string vector ipaddress listing of the known nodes

     * @return a string vector representing the ipAddresses of the "known" nodes

     */
	public Vector getKnownNodesVector()

	{
	    return(knownNodesVector);
	}
	// -----------------------------------------------------------------------


	// -----------------------------------------------------------------------
    /**

     * Gets the upload mode that the user has specified

     * if the user specifices that he only wants to communicate with

     * "privledged" known nodes, then this function will return true

     * @return true = known nodes allowed only

     *         false = all nodes allowed

     */
	public boolean getKnownNodesOnly()

	{
	    return(knownNodesOnly);
	}
	// -----------------------------------------------------------------------


	// -----------------------------------------------------------------------
    /**

     * Gets a string vector listing all the directories that are shared

     * @return a string vector representing all the directories that are shared

     * for example: "/documents/songs" or "/documents/songs/*"

     */

	public Vector getUploadDirectories()

	{
	    return(uploadDirectories);
	}
	// -----------------------------------------------------------------------

	public Vector getDownloadDirectories()

	{
	    return(downloadDirectories);
	}


	// -----------------------------------------------------------------------
    /**

     * Gets a string (delimited) listing all the directories that are shared

     * @return a string vector representing all the directories that are shared

     * for example: "/documents/songs" or "/documents/songs/*"

     */

	public String getUploadDirectoriesDelimited()

	{
		return getDirectoriesDelimited(uploadDirectories);
	}

	public String getDownloadDirectoriesDelimited()
	{
			return getDirectoriesDelimited(downloadDirectories);
	}

	public String getDirectoriesDelimited(Vector dirs)

	{
		String s = "";
		int nCnt = 0;
		String Dir;
		if (dirs != null) {
			Iterator directories = dirs.iterator();
			while(directories.hasNext()) {
				nCnt++;
				Dir = (String)directories.next();
				if (nCnt > 1)
					s += DirListDelim;
				s += Dir;
			}
		}
	    return s;
	}

	// -----------------------------------------------------------------------


	// -----------------------------------------------------------------------
    /**

     * Gets the download mode to be automatic or manual based on user preferences

     * @return true = auto drive

     *         false = manual selection downloads

     */

	public boolean isModeAutoDrive()

	{
	    return(autoDownloadMode);
	}
	// -----------------------------------------------------------------------


	// -----------------------------------------------------------------------

    /**

     * Sets the music profile vector

     * @param a vector of MusicProfiles

     */
    public void setMusicProfileVector(Vector aMusicProfileVector)
    {
        musicProfileVector = aMusicProfileVector;
    }
	// -----------------------------------------------------------------------


	// -----------------------------------------------------------------------
    /**

     * Sets the maximum uploads per hour allowed by this user

     * @param an integer representing the number of uploads in one hour

     */
	public void setMaxUploadsPerHour(int a)

	{
	    maxUploadsPerHour = a;
	}
	// -----------------------------------------------------------------------


	// -----------------------------------------------------------------------
    /**

     * Sets a string vector ipaddress listing of the known nodes

     * @param a KnownNodesObject vector representing the ipAddresses and usernames of the "known" nodes

     */

	public void setKnownNodesVector(Vector a)
	{

	    knownNodesVector = a;

	}
	// -----------------------------------------------------------------------


	// -----------------------------------------------------------------------
    /**

     * Sets the upload mode that the user has specified

     * @param true = known nodes allowed only

     *         false = all nodes allowed

     */

	public void setKnownNodesOnly(boolean a)
	{
	    knownNodesOnly=a;
	}
	// -----------------------------------------------------------------------


	// -----------------------------------------------------------------------
    /**

     * Sets a string vector listing all the directories that are shared

     * @param a string vector representing all the directories that are shared

     * for example: "/documents/songs" or "/documents/songs/*"

     */
	public void setUploadDirectories(Vector a)

	{
	    uploadDirectories=a;
	}

	public void setDownloadDirectories(Vector a)
	{
		    downloadDirectories=a;
	}
	// -----------------------------------------------------------------------

	// -----------------------------------------------------------------------
	    /**

	     * Sets a string vector listing all the directories that are shared from a delimited list

	     * @param a string representing all the directories that are shared

	     * for example: "/documents/songs" or "/documents/songs/*"

	     */
		public void setUploadDirectoriesDelimited(String s)

		{
			 setDirectoriesDelimited(s, uploadDirectories);
		}

		public void setDownloadDirectoriesDelimited(String s)
		{
			setDirectoriesDelimited(s, downloadDirectories);
		}

	public void setDirectoriesDelimited(String s, Vector Dirs)

	{

		if (Dirs!= null)
			Dirs.clear();
		else
			Dirs = new Vector();

		StringTokenizer tokenizer = new StringTokenizer(s, DirListDelim);
		DebugOut(s);
		while (tokenizer.hasMoreTokens()){
			Dirs.add(tokenizer.nextToken());
		}
	}

	// -----------------------------------------------------------------------
	public String getConfigFilename() {
		return ConfigFilename;
	}

	// -----------------------------------------------------------------------
    /**

     * Sets the download mode to be automatic or manual based on user preferences

     * @param true = auto drive

     *         false = manual selection downloads

     */
	public void setModeToAutoDrive(boolean a)

	{
	    autoDownloadMode = a;
	}
	// -----------------------------------------------------------------------




	private void DebugOut(String sStr)
	{
		if (DEBUG)
			System.out.println(sStr);
	}

}

⌨️ 快捷键说明

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