r27108 - trunk/freenet/src/freenet/client

[email protected] Mon, 20 Apr 2009 19:50:56 +0000
Newsgroups gmane.network.freenet.cvs
Message-ID <[email protected]>
Author: saces
Date: 2009-04-20 19:50:55 +0000 (Mon, 20 Apr 2009)
New Revision: 27108

Modified:
   trunk/freenet/src/freenet/client/Metadata.java
Log:
refactor out a haseFlags(), a single list for read and write
public for KeyExplorer

Modified: trunk/freenet/src/freenet/client/Metadata.java
===================================================================
--- trunk/freenet/src/freenet/client/Metadata.java	2009-04-20 19:48:40 UTC (rev 27107)
+++ trunk/freenet/src/freenet/client/Metadata.java	2009-04-20 19:50:55 UTC (rev 27108)
@@ -208,8 +208,7 @@
 		if(logMINOR) Logger.minor(this, "Document type: "+documentType);
 		
 		boolean compressed = false;
-		if((documentType == SIMPLE_REDIRECT) || (documentType == MULTI_LEVEL_METADATA)
-				|| (documentType == ARCHIVE_MANIFEST) || (documentType == ARCHIVE_INTERNAL_REDIRECT)) {
+		if(haveFlags()) {
 			short flags = dis.readShort();
 			splitfile = (flags & FLAGS_SPLITFILE) == FLAGS_SPLITFILE;
 			dbr = (flags & FLAGS_DBR) == FLAGS_DBR;
@@ -813,8 +812,7 @@
 		dos.writeLong(FREENET_METADATA_MAGIC);
 		dos.writeShort(0); // version
 		dos.writeByte(documentType);
-		if((documentType == SIMPLE_REDIRECT) || (documentType == MULTI_LEVEL_METADATA)
-				|| (documentType == ARCHIVE_MANIFEST) || (documentType == ARCHIVE_INTERNAL_REDIRECT)) {
+		if(haveFlags()) {
 			short flags = 0;
 			if(splitfile) flags |= FLAGS_SPLITFILE;
 			if(dbr) flags |= FLAGS_DBR;
@@ -931,6 +929,14 @@
 	}
 
 	/**
+	 * have this metadata flags?
+	 */
+	public boolean haveFlags() {
+		return ((documentType == SIMPLE_REDIRECT) || (documentType == MULTI_LEVEL_METADATA)
+				|| (documentType == ARCHIVE_MANIFEST) || (documentType == ARCHIVE_INTERNAL_REDIRECT));
+	}
+
+	/**
 	 * Get the splitfile type.
 	 */
 	public short getSplitfileType() {