[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r21064 - in gnunet-java/src/org/gnunet: construct statistic
From: |
gnunet |
Subject: |
[GNUnet-SVN] r21064 - in gnunet-java/src/org/gnunet: construct statistics |
Date: |
Sun, 22 Apr 2012 12:43:40 +0200 |
Author: dold
Date: 2012-04-22 12:43:40 +0200 (Sun, 22 Apr 2012)
New Revision: 21064
Modified:
gnunet-java/src/org/gnunet/construct/ByteFill.java
gnunet-java/src/org/gnunet/construct/Construct.java
gnunet-java/src/org/gnunet/statistics/Statistics.java
Log:
added some documentation
Modified: gnunet-java/src/org/gnunet/construct/ByteFill.java
===================================================================
--- gnunet-java/src/org/gnunet/construct/ByteFill.java 2012-04-22 10:05:43 UTC
(rev 21063)
+++ gnunet-java/src/org/gnunet/construct/ByteFill.java 2012-04-22 10:43:40 UTC
(rev 21064)
@@ -8,6 +8,8 @@
/**
* Fills a byte array with the remaining data in the current frame.
* Annotation target must be of type "byte[]"
+ *
+ * Deprecated, you should use @IntegerFill(false, 8), or @FillWith @UInt8 once
it is available.
*
* @author Florian Dold
*/
Modified: gnunet-java/src/org/gnunet/construct/Construct.java
===================================================================
--- gnunet-java/src/org/gnunet/construct/Construct.java 2012-04-22 10:05:43 UTC
(rev 21063)
+++ gnunet-java/src/org/gnunet/construct/Construct.java 2012-04-22 10:43:40 UTC
(rev 21064)
@@ -11,8 +11,32 @@
import java.nio.ByteBuffer;
import java.util.*;
+
+
+/*
+Wanted syntax (not fully implemented yet)
+- @(U)Int<n> => signed or unsigned fixnum, represented by n bits
+- @NestedMessage => nested message
+- @FillWith @(U)Int<n> => fill the rest of the message with the specified
fixnum, annotation valid on primitive arrays
+- @FillWith @NestedMessage => fill the rest of the message with the specified
fixnum, annotation valid on message arrays
+ of the wanted type
+- @VariableSizeArray(lengthField = "<field>") => same syntax as @FillWith
+- @FixedSizeArray(length = n) => same syntax as @FillWith
+- @Double / @Float => floating point number, should also work with the array
annotations
+- @FrameSize => specifies the fixnum that determines the containing frame's
size
+- @ZeroTerminatedString => self-explanatory
+- @Constructable => annotation on a class that implements the
ConstructableMessage interface,
+ providing methods to serialize/unserialize itself.
+ */
+
+
+
/**
+ * Parse and write the binary representation of java classes, as defined by
org.gnunet.construct.*-Annotations
+ * on their members.
+ *
* @author Christian Grothoff
+ * @author Florian Dold
*/
public class Construct {
private static final Logger logger = LoggerFactory
@@ -21,15 +45,26 @@
private static HashMap<Class<? extends Message>, Parser> parserCache = new
HashMap<Class<? extends Message>, Parser>(100);
-
/**
* Information the root of the parser, if the target is nested in another
message.
*/
- public static class ParserContext {
+ private static class ParserContext {
+ ArrayList<Field> frameSizePath = new ArrayList<Field>();
+ ArrayList<Field> parserPath = new ArrayList<Field>();
+ @Override
+ public boolean equals(Object other) {
+ // parsers with an equal parserPath also always have the same
frameSizePath
+ return this.parserPath.equals(((ParserContext)other).parserPath);
+ }
+
+ @Override
+ public int hashCode() {
+ return parserPath.hashCode();
+ }
}
- public static class RootedParser {
+ private static class RootedParser {
// null if target itself is root
ParserContext root;
Parser parser;
@@ -341,6 +376,19 @@
vsa.lengthField(), old_c));
}
}
+
+ /*
+ * We override this to improve the error message, otherwise obfuscated
by internal java proxy objects
+ */
+ @Override
+ public void visitDefault(Object obj) {
+ if (obj instanceof Annotation) {
+ Annotation ann = (Annotation) obj;
+ throw new AssertionError("invalid Construct annotation: " +
ann.annotationType().getName());
+ } else {
+ throw new AssertionError();
+ }
+ }
}
/**
Modified: gnunet-java/src/org/gnunet/statistics/Statistics.java
===================================================================
--- gnunet-java/src/org/gnunet/statistics/Statistics.java 2012-04-22
10:05:43 UTC (rev 21063)
+++ gnunet-java/src/org/gnunet/statistics/Statistics.java 2012-04-22
10:43:40 UTC (rev 21064)
@@ -314,7 +314,6 @@
@Override
public void onDone() {
- logger.info("done getting statistics");
statistics.destroy(false);
}
});
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r21064 - in gnunet-java/src/org/gnunet: construct statistics,
gnunet <=