Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Deleted unnecessary packages

As a first step to shrinking the repository, deleted all packages which
were not imported by fc.xml.diff or one of its dependencies.
  • Loading branch information...
commit d5641b78cf35bfb330006ac7806fbe63604e8406 1 parent 0f4ce3a
Martin Kleppmann authored
Showing with 0 additions and 12,874 deletions.
  1. +0 −99 src/fc/exper/BareSorting.java
  2. +0 −223 src/fc/exper/CreditCard.java
  3. +0 −145 src/fc/exper/DomBook.java
  4. +0 −143 src/fc/exper/DomToc.java
  5. +0 −346 src/fc/exper/Ebook.java
  6. +0 −307 src/fc/exper/Security.java
  7. +0 −303 src/fc/exper/Sorting.java
  8. +0 −205 src/fc/exper/StructuredSVG.java
  9. +0 −259 src/fc/exper/Toc.java
  10. +0 −57 src/fc/exper/XalanSorting.java
  11. +0 −86 src/fc/raxs/DeltaInputStream.java
  12. +0 −43 src/fc/raxs/DeltaStream.java
  13. +0 −248 src/fc/raxs/DeweyStore.java
  14. +0 −371 src/fc/raxs/IdStore.java
  15. +0 −65 src/fc/raxs/Measurements.java
  16. +0 −46 src/fc/raxs/NoSuchVersionException.java
  17. +0 −68 src/fc/raxs/ParseException.java
  18. +0 −847 src/fc/raxs/RandomAccessXmlStore.java
  19. +0 −399 src/fc/raxs/RaxsConfiguration.java
  20. +0 −86 src/fc/raxs/Store.java
  21. +0 −31 src/fc/raxs/StoreConfiguration.java
  22. +0 −38 src/fc/raxs/StoreCorruptedException.java
  23. +0 −86 src/fc/raxs/VersionHistory.java
  24. +0 −69 src/fc/raxs/VersionHistoryImpl.java
  25. +0 −259 src/fc/raxs/XasStore.java
  26. +0 −55 src/fc/raxs/exper/DeweyStore.java
  27. +0 −58 src/fc/raxs/exper/IdStore.java
  28. +0 −71 src/fc/raxs/exper/MemoryStore.java
  29. +0 −683 src/fc/raxs/exper/RandomEdits.java
  30. +0 −203 src/fc/raxs/exper/ResultLog.java
  31. +0 −109 src/fc/raxs/test/DemoTest.java
  32. +0 −34 src/fc/raxs/test/RaxsAndXmlrSuite.java
  33. +0 −56 src/fc/raxs/test/RootSuite.java
  34. +0 −376 src/fc/raxs/test/VersioningTest.java
  35. +0 −49 src/fc/test/junit/XasTest.java
  36. +0 −63 src/fc/test/junit/XmlData.java
  37. +0 −39 src/fc/util/bytedb/ByteDb.java
  38. +0 −1,236 src/fc/util/bytedb/Sdbm.java
  39. +0 −84 src/fc/util/bytedb/SdbmByteDb.java
  40. +0 −185 src/fc/util/concurrent/BoundedBuffer.java
  41. +0 −37 src/fc/util/concurrent/BoundedChannel.java
  42. +0 −306 src/fc/util/concurrent/Channel.java
  43. +0 −69 src/fc/util/concurrent/Puttable.java
  44. +0 −68 src/fc/util/concurrent/Takable.java
  45. +0 −81 src/fc/util/holder/Holder.java
  46. +0 −154 src/fc/util/io/DelayedInputStream.java
  47. +0 −136 src/fc/util/io/DelayedOutputStream.java
  48. +0 −296 src/fc/xml/xas/security/DecryptSource.java
  49. +0 −144 src/fc/xml/xas/security/DigestItem.java
  50. +0 −56 src/fc/xml/xas/security/DsReference.java
  51. +0 −211 src/fc/xml/xas/security/DsSignature.java
  52. +0 −169 src/fc/xml/xas/security/EncryptedData.java
  53. +0 −124 src/fc/xml/xas/security/EncryptedKey.java
  54. +0 −185 src/fc/xml/xas/security/SecUtil.java
  55. +0 −73 src/fc/xml/xas/security/SignatureItem.java
  56. +0 −51 src/fc/xml/xas/security/TypeAnnotator.java
  57. +0 −71 src/fc/xml/xas/security/TypeAttributeSource.java
  58. +0 −488 src/fc/xml/xas/security/VerifySource.java
  59. +0 −67 src/fc/xml/xas/security/XencDataReference.java
  60. +0 −175 src/fuegocore/examples/util/XmlSerializer.java
  61. +0 −18 src/fuegocore/examples/util/package.html
  62. +0 −142 src/fuegocore/message/encoding/coa/GenericDoaMachine.java
  63. +0 −92 src/fuegocore/message/encoding/coa/GenericEdge.java
  64. +0 −112 src/fuegocore/message/encoding/coa/GenericEoaMachine.java
  65. +0 −271 src/fuegocore/message/encoding/coa/ReaderCoaMachine.java
  66. +0 −75 src/fuegocore/message/encoding/coa/SoapCachePair.java
  67. +0 −227 src/fuegocore/message/encoding/coa/SoapDoaMachine.java
  68. +0 −184 src/fuegocore/message/encoding/coa/SoapEoaMachine.java
  69. +0 −16 src/fuegocore/message/encoding/coa/package.html
  70. +0 −347 src/fuegocore/message/exper/Encoding.java
  71. +0 −283 src/fuegocore/message/exper/ParseComparison.java
  72. +0 −16 src/fuegocore/message/exper/package.html
View
99 src/fc/exper/BareSorting.java
@@ -1,99 +0,0 @@
-/*
- * Copyright 2005--2008 Helsinki Institute for Information Technology
- *
- * This file is a part of Fuego middleware. Fuego middleware is free
- * software; you can redistribute it and/or modify it under the terms
- * of the MIT license, included as the file MIT-LICENSE in the Fuego
- * middleware source distribution. If you did not receive the MIT
- * license with the distribution, write to the Fuego Core project at
- * fuego-xas-users@hoslab.cs.helsinki.fi.
- */
-
-package fc.exper;
-
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
-import java.util.Collections;
-import java.util.List;
-
-import org.kxml2.io.KXmlParser;
-
-import fc.util.Measurer;
-import fc.util.Util;
-import fc.xml.xas.Item;
-import fc.xml.xas.ItemList;
-import fc.xml.xas.XasFragment;
-import fc.xml.xas.XmlOutput;
-import fc.xml.xas.XmlPullSource;
-
-public class BareSorting {
-
- public static void main (String[] args) {
- try {
- if (args.length != 1) {
- System.err.println("Usage: BareSorting <file>");
- System.exit(1);
- }
- Measurer.init(Measurer.TIMING);
- Measurer timer = Measurer.get(Measurer.TIMING);
- String fileName = args[0];
- String outName = fileName.concat(".bsort");
- int end = 10;
- for (int i = 0; i < end; i++ ) {
- Util.runGc();
- long beginMemory = Util.usedMemory();
- Object token = timer.start();
- ItemList list = new ItemList();
- XmlPullSource source = new XmlPullSource(new KXmlParser(),
- new FileInputStream(fileName));
- Item item;
- while ((item = source.next()) != null) {
- list.append(item);
- }
- XasFragment fragment = list.fragment();
- list = null;
- if (i >= end - 2) {
- timer.finish(token, "Reading");
- }
- long spentMemory = Util.usedMemory();
- Util.runGc();
- long endMemory = Util.usedMemory();
- System.out.println("Reading memory: "
- + (spentMemory - beginMemory));
- System.out.println("Fragment size: "
- + (endMemory - beginMemory));
- token = timer.start();
- List<Item> items = fragment.getFragmentContent();
- Collections.sort(items, new Sorting.TagCompare());
- fragment.setFragmentContent(items);
- if (i >= end - 2) {
- timer.finish(token, "Sorting");
- }
- Util.runGc();
- beginMemory = Util.usedMemory();
- XmlOutput out = new XmlOutput(new FileOutputStream(outName),
- source.getEncoding());
- token = timer.start();
- fragment.appendTo(out);
- out.flush();
- if (i >= end - 2) {
- timer.finish(token, "Output");
- }
- spentMemory = Util.usedMemory();
- Util.runGc();
- endMemory = Util.usedMemory();
- System.out.println("Performing output: " + (spentMemory - beginMemory));
- System.out.println("Output left: " + (endMemory - beginMemory));
- if (i >= end -2) {
- timer.output(System.out);
- }
- }
- } catch (Exception ex) {
- ex.printStackTrace();
- System.exit(1);
- }
- }
-
-}
-
-// arch-tag: 9054c8bd-06a8-474a-ad55-6eabb10f5297
View
223 src/fc/exper/CreditCard.java
@@ -1,223 +0,0 @@
-/*
- * Copyright 2005--2008 Helsinki Institute for Information Technology
- *
- * This file is a part of Fuego middleware. Fuego middleware is free
- * software; you can redistribute it and/or modify it under the terms
- * of the MIT license, included as the file MIT-LICENSE in the Fuego
- * middleware source distribution. If you did not receive the MIT
- * license with the distribution, write to the Fuego Core project at
- * fuego-xas-users@hoslab.cs.helsinki.fi.
- */
-
-package fc.exper;
-
-import java.io.BufferedReader;
-import java.io.IOException;
-import java.io.InputStreamReader;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Random;
-
-import fc.xml.xas.EndTag;
-import fc.xml.xas.ItemSource;
-import fc.xml.xas.ItemTarget;
-import fc.xml.xas.Qname;
-import fc.xml.xas.StartTag;
-import fc.xml.xas.XasUtil;
-import fc.xml.xas.typing.Codec;
-import fc.xml.xas.typing.ParsedPrimitive;
-import fc.xml.xas.typing.TypingUtil;
-import fc.xml.xas.typing.ValueCodec;
-
-public class CreditCard {
-
- public static final String EXPER_NS = "http://www.hiit.fi/fuego/fc/exper";
- public static final Qname CARD_TYPE = new Qname(EXPER_NS, "card");
- public static final Qname CARD_LIST_TYPE = new Qname(EXPER_NS, "cardList");
-
- private String name;
- private String number;
- private int expYear;
- private int expMonth;
-
- private static Random random = new Random(19061975L);
- private static List<String> firsts = null;
- private static List<String> lasts = null;
-
- static {
- ClassLoader loader = CreditCard.class.getClassLoader();
- try {
- initLists(loader);
- } catch (IOException ex) {
- throw new Error(ex);
- }
- Codec.registerValueCodec(new CreditCardCodec());
- }
-
- private static List<String> initList (ClassLoader loader, String resource)
- throws IOException {
- BufferedReader r =
- new BufferedReader(new InputStreamReader(loader
- .getResourceAsStream(resource)));
- List<String> value = new ArrayList<String>();
- String line;
- while ((line = r.readLine()) != null) {
- value.add(line);
- }
- return value;
- }
-
- private static void initLists (ClassLoader loader) throws IOException {
- if (firsts == null) {
- firsts = initList(loader, "exper/firsts");
- }
- if (lasts == null) {
- lasts = initList(loader, "exper/lasts");
- }
- }
-
- private static String getRandomName () {
- int fi = random.nextInt(firsts.size());
- int li = random.nextInt(lasts.size());
- return firsts.get(fi) + " " + lasts.get(li);
- }
-
- private static String getRandomNumber () {
- StringBuilder result = new StringBuilder();
- for (int i = 0; i < 4; i++) {
- if (result.length() > 0) {
- result.append("-");
- }
- result.append(random.nextInt(9000) + 1000);
- }
- return result.toString();
- }
-
- private static int getRandomYear () {
- return random.nextInt(5) + 2008;
- }
-
- private static int getRandomMonth () {
- return random.nextInt(12) + 1;
- }
-
- private CreditCard (String name, String number, int expYear, int expMonth) {
- this.name = name;
- this.number = number;
- this.expYear = expYear;
- this.expMonth = expMonth;
- }
-
- public CreditCard () {
- name = getRandomName();
- number = getRandomNumber();
- expYear = getRandomYear();
- expMonth = getRandomMonth();
- }
-
- public String getName () {
- return name;
- }
-
- public String getNumber () {
- return number;
- }
-
- public int getExpYear () {
- return expYear;
- }
-
- public int getExpMonth () {
- return expMonth;
- }
-
- public static class CreditCardCodec implements ValueCodec {
-
- private static final Qname CARD_NAME = new Qname(EXPER_NS, "card");
- private static final EndTag CARD_END = new EndTag(CARD_NAME);
- private static final ParsedPrimitive CARD_ATTRIBUTE =
- new ParsedPrimitive(XasUtil.QNAME_TYPE, CARD_TYPE);
- private static final Qname MONTH_NAME = new Qname(EXPER_NS, "expMonth");
- private static final Qname MONTH_TYPE = XasUtil.INT_TYPE;
- private static final EndTag MONTH_END = new EndTag(MONTH_NAME);
- private static final Qname YEAR_NAME = new Qname(EXPER_NS, "expYear");
- private static final Qname YEAR_TYPE = XasUtil.INT_TYPE;
- private static final EndTag YEAR_END = new EndTag(YEAR_NAME);
- private static final Qname HOLDER_NAME = new Qname(EXPER_NS, "name");
- private static final Qname HOLDER_TYPE = XasUtil.STRING_TYPE;
- private static final EndTag HOLDER_END = new EndTag(HOLDER_NAME);
- private static final Qname NUMBER_NAME = new Qname(EXPER_NS, "number");
- private static final Qname NUMBER_TYPE = XasUtil.STRING_TYPE;
- private static final EndTag NUMBER_END = new EndTag(NUMBER_NAME);
-
- public Object decode (Qname typeName, ItemSource source)
- throws IOException {
- if (CARD_TYPE.equals(typeName)) {
- String name =
- (String) TypingUtil
- .expect(HOLDER_NAME, HOLDER_TYPE, source);
- String number =
- (String) TypingUtil
- .expect(NUMBER_NAME, NUMBER_TYPE, source);
- Integer year =
- (Integer) TypingUtil.expect(YEAR_NAME, YEAR_TYPE, source);
- Integer month =
- (Integer) TypingUtil.expect(MONTH_NAME, MONTH_TYPE, source);
- if (name != null && number != null && year != null
- && month != null) {
- return new CreditCard(name, number, year, month);
- } else {
- return null;
- }
- } else if (CARD_LIST_TYPE.equals(typeName)) {
- ArrayList<CreditCard> result = new ArrayList<CreditCard>();
- CreditCard card;
- while ((card =
- (CreditCard) TypingUtil
- .expect(CARD_NAME, CARD_TYPE, source)) != null) {
- result.add(card);
- }
- if (source.next() != null) {
- result = null;
- }
- return result;
- } else {
- return null;
- }
- }
-
- public void encode (Qname typeName, Object value, ItemTarget target,
- StartTag parent) throws IOException {
- if (CARD_TYPE.equals(typeName)) {
- CreditCard card = (CreditCard) value;
- TypingUtil.appendPrimitiveTo(HOLDER_NAME, HOLDER_TYPE,
- card.name, parent, TypingUtil.STRING_ATTRIBUTE, HOLDER_END,
- target);
- TypingUtil.appendPrimitiveTo(NUMBER_NAME, NUMBER_TYPE,
- card.number, parent, TypingUtil.STRING_ATTRIBUTE,
- NUMBER_END, target);
- TypingUtil.appendPrimitiveTo(YEAR_NAME, YEAR_TYPE,
- card.expYear, parent, TypingUtil.INT_ATTRIBUTE, YEAR_END,
- target);
- TypingUtil.appendPrimitiveTo(MONTH_NAME, MONTH_TYPE,
- card.expMonth, parent, TypingUtil.INT_ATTRIBUTE, MONTH_END,
- target);
- } else if (CARD_LIST_TYPE.equals(typeName)) {
- List list = (List) value;
- for (Object o : list) {
- TypingUtil.appendComplexTo(CARD_NAME, CARD_TYPE, o, parent,
- CARD_ATTRIBUTE, CARD_END, target);
- }
- }
- }
-
- public boolean isKnown (Qname typeName) {
- return CARD_TYPE.equals(typeName)
- || CARD_LIST_TYPE.equals(typeName);
- }
-
- }
-
-}
-
-// arch-tag: c8280ba9-83f5-4975-9a5a-3cbf59712112
View
145 src/fc/exper/DomBook.java
@@ -1,145 +0,0 @@
-/*
- * Copyright 2005--2008 Helsinki Institute for Information Technology
- *
- * This file is a part of Fuego middleware. Fuego middleware is free
- * software; you can redistribute it and/or modify it under the terms
- * of the MIT license, included as the file MIT-LICENSE in the Fuego
- * middleware source distribution. If you did not receive the MIT
- * license with the distribution, write to the Fuego Core project at
- * fuego-xas-users@hoslab.cs.helsinki.fi.
- */
-
-package fc.exper;
-
-import java.util.Random;
-import java.util.Stack;
-
-import javax.xml.parsers.DocumentBuilder;
-import javax.xml.parsers.DocumentBuilderFactory;
-
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-
-import fc.util.Util;
-
-public class DomBook {
-
- private static final long DEFAULT_SEED = 29041978L;
- private static Random random;
- private static final String PREFACE_OPS = "rrrrrrrsss";
- private static final String PRESECTION_OPS = "rrrrrsssss";
- private static final String CHAPTER_OPS = "rrrrrrrrrs";
- private static final String APPENDIX_OPS = "rrrsssssss";
- private static final String SECTION_OPS = "rrrrrrrsss";
- private static final String SUBSECTION_OPS = "rrrrrssspp";
- private static final String IMAGE_OPS = "rrrrrrrrrs";
-
- private static long initialMemory;
- private static long[] skipInfo = new long[8];
-
- public static void main (String[] args) {
- try {
- if (args.length != 1) {
- System.err.println("Usage: DomBook <file>");
- System.exit(1);
- }
- String fileName = args[0];
- int end = 1;
- for (int i = 0; i < end; i++ ) {
- Util.runGc();
- initialMemory = Util.usedMemory();
- random = new Random(DEFAULT_SEED);
- DocumentBuilderFactory factory = DocumentBuilderFactory
- .newInstance();
- factory.setNamespaceAware(true);
- DocumentBuilder builder = factory.newDocumentBuilder();
- Document document = builder.parse(fileName);
- Stack<Node> stack = new Stack<Node>();
- stack.push(document);
- while (!stack.isEmpty()) {
- Node node = stack.pop();
- switch (node.getNodeType()) {
- case Node.DOCUMENT_NODE: {
- NodeList nodes = node.getChildNodes();
- if (nodes != null) {
- int n = nodes.getLength();
- for (int j = n - 1; j >= 0; j-- ) {
- stack.push(nodes.item(j));
- }
- }
- break;
- }
- case Node.ELEMENT_NODE: {
- String name = node.getNodeName();
- Element element = (Element) node;
- String ops = null;
- int index = -1;
- if (name.equals("preface")) {
- ops = PREFACE_OPS;
- index = 0;
- } else if (name.equals("chapter")) {
- ops = CHAPTER_OPS;
- index = 0;
- } else if (name.equals("appendix")) {
- ops = APPENDIX_OPS;
- index = 0;
- } else if (name.equals("sect1")) {
- ops = SECTION_OPS;
- index = 2;
- } else if (name.equals("section")) {
- ops = PRESECTION_OPS;
- index = 2;
- } else if (name.equals("sect2")) {
- ops = SUBSECTION_OPS;
- index = 4;
- } else if (name.equals("imagedata")) {
- ops = IMAGE_OPS;
- index = 6;
- } else if (name.equals("bookinfo")) {
- break;
- } else if (name.equals("glossary")) {
- break;
- }
- if (ops != null) {
- skipInfo[index] += 1;
- Util.runGc();
- System.out.println("Start "
- + element.getAttribute("id") + ": "
- + (Util.usedMemory() - initialMemory));
- char d = ops.charAt(random.nextInt(ops.length()));
- if (d != 'r') {
- break;
- }
- System.out.println("Processing node");
- skipInfo[index + 1] += 1;
- }
- NodeList nodes = node.getChildNodes();
- if (nodes != null) {
- int n = nodes.getLength();
- for (int j = n - 1; j >= 0; j-- ) {
- stack.push(nodes.item(j));
- }
- }
- break;
- }
- }
- }
- System.out.println("Chapters: " + skipInfo[1] + "/"
- + skipInfo[0]);
- System.out.println("Sections: " + skipInfo[3] + "/"
- + skipInfo[2]);
- System.out.println("Subsections: " + skipInfo[5] + "/"
- + skipInfo[4]);
- System.out
- .println("Images: " + skipInfo[7] + "/" + skipInfo[6]);
- }
- } catch (Exception ex) {
- ex.printStackTrace();
- System.exit(1);
- }
- }
-}
-
-// arch-tag: 6c8a365f-cd19-4254-afd9-4301a32a9c8a
View
143 src/fc/exper/DomToc.java
@@ -1,143 +0,0 @@
-/*
- * Copyright 2005--2008 Helsinki Institute for Information Technology
- *
- * This file is a part of Fuego middleware. Fuego middleware is free
- * software; you can redistribute it and/or modify it under the terms
- * of the MIT license, included as the file MIT-LICENSE in the Fuego
- * middleware source distribution. If you did not receive the MIT
- * license with the distribution, write to the Fuego Core project at
- * fuego-xas-users@hoslab.cs.helsinki.fi.
- */
-
-package fc.exper;
-
-import java.io.FileOutputStream;
-import java.util.Stack;
-
-import javax.xml.parsers.DocumentBuilder;
-import javax.xml.parsers.DocumentBuilderFactory;
-
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-
-import com.sun.org.apache.xml.internal.serialize.OutputFormat;
-import com.sun.org.apache.xml.internal.serialize.XMLSerializer;
-
-import fc.util.Measurer;
-import fc.util.Util;
-
-public class DomToc {
-
- public static void main (String[] args) {
- try {
- if (args.length != 1) {
- System.err.println("Usage: DomToc <file>");
- System.exit(1);
- }
- Measurer.init(Measurer.TIMING);
- Measurer timer = Measurer.get(Measurer.TIMING);
- String fileName = args[0];
- String outName = fileName.concat(".dtoc");
- int end = 10;
- for (int i = 0; i < end; i++ ) {
- Util.runGc();
- long beginMemory = Util.usedMemory();
- DocumentBuilderFactory factory = DocumentBuilderFactory
- .newInstance();
- factory.setNamespaceAware(true);
- DocumentBuilder builder = factory.newDocumentBuilder();
- Object token = timer.start();
- Document document = builder.parse(fileName);
- Element tocNode = null;
- Element chapter = null;
- Element section = null;
- Stack<Node> stack = new Stack<Node>();
- stack.push(document);
- while (!stack.isEmpty()) {
- Node node = stack.pop();
- switch (node.getNodeType()) {
- case Node.DOCUMENT_NODE: {
- NodeList nodes = node.getChildNodes();
- if (nodes != null) {
- int n = nodes.getLength();
- for (int j = n - 1; j >= 0; j-- ) {
- stack.push(nodes.item(j));
- }
- }
- break;
- }
- case Node.ELEMENT_NODE: {
- String name = node.getNodeName();
- Element element = (Element) node;
- if (name.equals("toc")) {
- tocNode = element;
- } else if (name.equals("chapter")) {
- String id = element.getAttribute("id");
- if (id != null) {
- chapter = document.createElement("tocchap");
- chapter.setAttribute("ref", "#" + id);
- tocNode.appendChild(chapter);
- }
- } else if (name.equals("sect1")) {
- String id = element.getAttribute("id");
- if (id != null) {
- section = document.createElement("tocsect1");
- section.setAttribute("ref", "#" + id);
- chapter.appendChild(section);
- }
- } else if (name.equals("sect2")) {
- String id = element.getAttribute("id");
- if (id != null) {
- Element subsection = document
- .createElement("tocsect2");
- subsection.setAttribute("ref", "#" + id);
- section.appendChild(subsection);
- }
- break;
- }
- NodeList nodes = node.getChildNodes();
- if (nodes != null) {
- int n = nodes.getLength();
- for (int j = n - 1; j >= 0; j-- ) {
- stack.push(nodes.item(j));
- }
- }
- break;
- }
- }
- }
- if (i >= end - 2) {
- timer.finish(token, "TOC construction");
- }
- long endMemory = Util.usedMemory();
- System.out.println("TOC memory: " + (endMemory - beginMemory));
- Util.runGc();
- endMemory = Util.usedMemory();
- System.out.println("Document size: " + (endMemory - beginMemory));
- Util.runGc();
- beginMemory = Util.usedMemory();
- token = timer.start();
- OutputFormat format = new OutputFormat();
- XMLSerializer ser = new XMLSerializer(new FileOutputStream(
- outName), format);
- ser.serialize(document);
- if (i >= end - 2) {
- timer.finish(token, "Output");
- }
- endMemory = Util.usedMemory();
- System.out.println("Output memory: " + (endMemory - beginMemory));
- if (i >= end - 2) {
- timer.output(System.out);
- }
- }
- } catch (Exception ex) {
- ex.printStackTrace();
- System.exit(1);
- }
- }
-
-}
-
-// arch-tag: 98a1fa5e-d570-42cd-9a85-06af49054626
View
346 src/fc/exper/Ebook.java
@@ -1,346 +0,0 @@
-/*
- * Copyright 2005--2008 Helsinki Institute for Information Technology
- *
- * This file is a part of Fuego middleware. Fuego middleware is free
- * software; you can redistribute it and/or modify it under the terms
- * of the MIT license, included as the file MIT-LICENSE in the Fuego
- * middleware source distribution. If you did not receive the MIT
- * license with the distribution, write to the Fuego Core project at
- * fuego-xas-users@hoslab.cs.helsinki.fi.
- */
-
-package fc.exper;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.ArrayList;
-import java.util.Random;
-import java.util.Stack;
-
-import fc.util.Util;
-import fc.xml.xas.EndTag;
-import fc.xml.xas.Item;
-import fc.xml.xas.Qname;
-import fc.xml.xas.StartTag;
-import fc.xml.xas.index.DeweyKey;
-import fc.xml.xas.index.Index;
-import fc.xml.xas.index.KeyIterator;
-import fc.xml.xas.index.LazyFragment;
-import fc.xml.xas.index.SeekableKXmlSource;
-
-public class Ebook {
-
- private static final Qname BOOK_NAME = new Qname("", "book");
- private static final Qname BOOKINFO_NAME = new Qname("", "bookinfo");
- private static final Qname PREFACE_NAME = new Qname("", "preface");
- private static final Qname PRESECTION_NAME = new Qname("", "section");
- private static final Qname CHAPTER_NAME = new Qname("", "chapter");
- private static final Qname APPENDIX_NAME = new Qname("", "appendix");
- private static final Qname GLOSSARY_NAME = new Qname("", "glossary");
- private static final Qname SECTION_NAME = new Qname("", "sect1");
- private static final Qname SUBSECTION_NAME = new Qname("", "sect2");
- private static final Qname IMAGE_NAME = new Qname("", "imagedata");
- private static final Qname ID_ATT_NAME = new Qname("", "id");
-
- private static final long DEFAULT_SEED = 29041978L;
- private static Random random;
- private static final String PREFACE_OPS = "rrrrrrrsss";
- private static final String PRESECTION_OPS = "rrrrrsssss";
- private static final String CHAPTER_OPS = "rrrrrrrrrs";
- private static final String APPENDIX_OPS = "rrrsssssss";
- private static final String SECTION_OPS = "rrrrrrrsss";
- private static final String SUBSECTION_OPS = "rrrrrssspp";
- private static final String IMAGE_OPS = "rrrrrrrrrs";
-
- private static SeekableKXmlSource source = null;
- private static StartTag bookTag = null;
- private static LazyFragment chapFrag = null;
- private static LazyFragment sectFrag = null;
- private static ArrayList<LazyFragment> sectFrags = new ArrayList<LazyFragment>();
- private static ArrayList<LazyFragment> subsectFrags = new ArrayList<LazyFragment>();
- private static long initialMemory;
-
- private static long[] skipInfo = new long[8];
-
- private static Index buildIndex (String fileName) throws Exception {
- source = new SeekableKXmlSource(fileName);
- Index index = new Index(source);
- StartTag context = null;
- Stack<StartTag> sts = new Stack<StartTag>();
- sts.push(null);
- Stack<Integer> ps = new Stack<Integer>();
- Item item;
- KeyIterator ki = new KeyIterator();
- while ((item = source.next()) != null) {
- if (Item.isStartTag(item)) {
- context = (StartTag) item;
- sts.push(context);
- ps.push(source.getPreviousPosition());
- if (((StartTag) item).getName().equals(BOOK_NAME)) {
- bookTag = (StartTag) item;
- }
- } else if (Item.isEndTag(item)) {
- sts.pop();
- context = sts.peek();
- Integer pos = ps.pop();
- Qname name = ((EndTag) item).getName();
- if (name.equals(BOOK_NAME) || name.equals(BOOKINFO_NAME)
- || name.equals(PREFACE_NAME)
- || name.equals(PRESECTION_NAME)
- || name.equals(CHAPTER_NAME)
- || name.equals(APPENDIX_NAME)
- || name.equals(GLOSSARY_NAME)
- || name.equals(SECTION_NAME)
- || name.equals(SUBSECTION_NAME)
- || name.equals(IMAGE_NAME)) {
- index.insert(ki.current().up(), pos, source
- .getCurrentPosition(), context);
- }
- }
- ki.update(item);
- }
- return index;
- }
-
- public static void main (String[] args) {
- try {
- if (args.length != 1) {
- System.err.println("Usage: Ebook <file>");
- System.exit(1);
- }
- String fileName = args[0];
- Index index = null;
- int end = 1;
- for (int i = 0; i < end; i++ ) {
- index = null;
- Util.runGc();
- long beginMemory = Util.usedMemory();
- index = buildIndex(fileName);
- Util.runGc();
- long endMemory = Util.usedMemory();
- System.out.println("Index size: " + (endMemory - beginMemory));
- }
- source = new SeekableKXmlSource(fileName);
- index.setSource(source);
- random = new Random(DEFAULT_SEED);
- Util.runGc();
- initialMemory = Util.usedMemory();
- LazyFragment document = new LazyFragment(index, DeweyKey.initial(),
- bookTag);
- document.force(1);
- Util.runGc();
- long endMemory = Util.usedMemory();
- System.out.println("Unforced document size: "
- + (endMemory - initialMemory));
- int n = document.length();
- for (int i = 0; i < n; i++ ) {
- Item item = document.get(i);
- if (item instanceof LazyFragment) {
- LazyFragment fragment = (LazyFragment) item;
- StartTag st = (StartTag) fragment.get(0);
- Qname name = st.getName();
- if (name.equals(PREFACE_NAME)) {
- processChapter((String) st
- .getAttributeValue(ID_ATT_NAME), fragment,
- PREFACE_OPS);
- } else if (name.equals(CHAPTER_NAME)) {
- processChapter((String) st
- .getAttributeValue(ID_ATT_NAME), fragment,
- CHAPTER_OPS);
- } else if (name.equals(APPENDIX_NAME)) {
- processChapter((String) st
- .getAttributeValue(ID_ATT_NAME), fragment,
- APPENDIX_OPS);
- }
- }
- }
- System.out.println("Chapters: " + skipInfo[1] + "/" + skipInfo[0]);
- System.out.println("Sections: " + skipInfo[3] + "/" + skipInfo[2]);
- System.out.println("Subsections: " + skipInfo[5] + "/"
- + skipInfo[4]);
- System.out.println("Images: " + skipInfo[7] + "/" + skipInfo[6]);
- } catch (Exception ex) {
- ex.printStackTrace();
- System.exit(1);
- }
- }
-
- private static void processChapter (String id, LazyFragment fragment,
- String ops) throws IOException {
- skipInfo[0] += 1;
- if (chapFrag != null) {
- chapFrag.unforce();
- sectFrags.clear();
- subsectFrags.clear();
- }
- Util.runGc();
- System.out.println("Chapter " + id + " start: "
- + (Util.usedMemory() - initialMemory));
- char d = ops.charAt(random.nextInt(ops.length()));
- if (d == 'r') {
- skipInfo[1] += 1;
- System.out.println("Forcing fragment");
- fragment.force(1);
- chapFrag = fragment;
- processCurrentChapter();
- }
- Util.runGc();
- System.out.println("Chapter " + id + " end: "
- + (Util.usedMemory() - initialMemory));
- }
-
- private static void processCurrentChapter () throws IOException {
- int n = chapFrag.length();
- for (int i = 0; i < n; i++ ) {
- Item item = chapFrag.get(i);
- if (item instanceof LazyFragment) {
- LazyFragment fragment = (LazyFragment) item;
- StartTag st = (StartTag) fragment.get(0);
- Qname name = st.getName();
- if (name.equals(SECTION_NAME)) {
- processSection((String) st.getAttributeValue(ID_ATT_NAME),
- fragment, SECTION_OPS);
- } else if (name.equals(PRESECTION_NAME)) {
- processSection((String) st.getAttributeValue(ID_ATT_NAME),
- fragment, PRESECTION_OPS);
- }
- }
- }
- }
-
- private static void processSection (String id, LazyFragment fragment,
- String ops) throws IOException {
- skipInfo[2] += 1;
- if (sectFrag != null) {
- sectFrag.unforce();
- sectFrags.add(sectFrag);
- subsectFrags.clear();
- }
- Util.runGc();
- System.out.println("Section " + id + " start: "
- + (Util.usedMemory() - initialMemory));
- char d = ops.charAt(random.nextInt(ops.length()));
- if (d == 'r') {
- skipInfo[3] += 1;
- System.out.println("Forcing fragment");
- fragment.force(1);
- sectFrag = fragment;
- processCurrentSection();
- }
- Util.runGc();
- System.out.println("Section " + id + " end: "
- + (Util.usedMemory() - initialMemory));
- }
-
- private static void processCurrentSection () throws IOException {
- int n = sectFrag.length();
- for (int i = 0; i < n; i++ ) {
- Item item = sectFrag.get(i);
- if (item instanceof LazyFragment) {
- LazyFragment fragment = (LazyFragment) item;
- StartTag st = (StartTag) fragment.get(0);
- String id = (String) st.getAttributeValue(ID_ATT_NAME);
- Qname name = st.getName();
- if (name.equals(IMAGE_NAME)) {
- skipInfo[6] += 1;
- Util.runGc();
- System.out.println("Image start: "
- + (Util.usedMemory() - initialMemory));
- char d = IMAGE_OPS.charAt(random
- .nextInt(IMAGE_OPS.length()));
- if (d == 'r') {
- skipInfo[7] += 1;
- Index.Entry entry = fragment.getIndex().find(
- fragment.getKey());
- if (entry != null) {
- System.out.println("Reading bytes");
- source.setPosition(entry.getOffset(), entry
- .getContext());
- InputStream in = source.getInputStream();
- byte[] buffer = new byte[2048];
- int len = entry.getLength();
- int left = len > buffer.length ? buffer.length
- : len;
- int s;
- while ((s = in.read(buffer, 0, left)) > 0) {
- left -= s;
- }
- } else {
- System.out.println("Forcing fragment");
- fragment.force(1);
- }
- }
- Util.runGc();
- System.out.println("Image end: "
- + (Util.usedMemory() - initialMemory));
-
- } else if (name.equals(SUBSECTION_NAME)) {
- skipInfo[4] += 1;
- subsectFrags.add(fragment);
- Util.runGc();
- System.out.println("Subsection " + id + " start: "
- + (Util.usedMemory() - initialMemory));
- char d = SUBSECTION_OPS.charAt(random
- .nextInt(SUBSECTION_OPS.length()));
- if (d == 'r') {
- skipInfo[5] += 1;
- System.out.println("Forcing fragment");
- fragment.force(1);
- processSubsection(fragment);
- Util.runGc();
- System.out.println("Subsection " + id + " end: "
- + (Util.usedMemory() - initialMemory));
- }
- }
- }
- }
- }
-
- private static void processSubsection (LazyFragment fragment)
- throws IOException {
- int n = fragment.length();
- for (int i = 0; i < n; i++ ) {
- Item item = fragment.get(i);
- if (item instanceof LazyFragment) {
- LazyFragment lf = (LazyFragment) item;
- StartTag st = (StartTag) lf.get(0);
- Qname name = st.getName();
- if (name.equals(IMAGE_NAME)) {
- skipInfo[6] += 1;
- Util.runGc();
- System.out.println("Image start: "
- + (Util.usedMemory() - initialMemory));
- char d = IMAGE_OPS.charAt(random
- .nextInt(IMAGE_OPS.length()));
- if (d == 'r') {
- skipInfo[7] += 1;
- Index.Entry entry = lf.getIndex().find(lf.getKey());
- if (entry != null) {
- System.out.println("Reading bytes");
- source.setPosition(entry.getOffset(), entry
- .getContext());
- InputStream in = source.getInputStream();
- byte[] buffer = new byte[2048];
- int len = entry.getLength();
- int left = len > buffer.length ? buffer.length
- : len;
- int s;
- while ((s = in.read(buffer, 0, left)) > 0) {
- left -= s;
- }
- } else {
- System.out.println("Forcing fragment");
- lf.force(1);
- }
- }
- Util.runGc();
- System.out.println("Image end: "
- + (Util.usedMemory() - initialMemory));
-
- }
- }
- }
- }
-}
-
-// arch-tag: b30ed7bb-0cf7-46c9-9559-a9064fe2b1e5
View
307 src/fc/exper/Security.java
@@ -1,307 +0,0 @@
-/*
- * Copyright 2005--2008 Helsinki Institute for Information Technology
- *
- * This file is a part of Fuego middleware. Fuego middleware is free
- * software; you can redistribute it and/or modify it under the terms
- * of the MIT license, included as the file MIT-LICENSE in the Fuego
- * middleware source distribution. If you did not receive the MIT
- * license with the distribution, write to the Fuego Core project at
- * fuego-xas-users@hoslab.cs.helsinki.fi.
- */
-
-package fc.exper;
-
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.math.BigInteger;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Random;
-
-import org.bouncycastle.crypto.AsymmetricCipherKeyPair;
-import org.bouncycastle.crypto.params.RSAKeyParameters;
-import org.kxml2.io.KXmlParser;
-
-import fc.test.junit.XmlData;
-import fc.util.Measurer;
-import fc.util.Util;
-import fc.xml.xas.EndDocument;
-import fc.xml.xas.EndTag;
-import fc.xml.xas.Item;
-import fc.xml.xas.ItemSource;
-import fc.xml.xas.MutableFragmentPointer;
-import fc.xml.xas.ParserSource;
-import fc.xml.xas.Qname;
-import fc.xml.xas.StartDocument;
-import fc.xml.xas.StartTag;
-import fc.xml.xas.XasFragment;
-import fc.xml.xas.XasUtil;
-import fc.xml.xas.XmlOutput;
-import fc.xml.xas.XmlPullSource;
-import fc.xml.xas.security.DecryptSource;
-import fc.xml.xas.security.DsSignature;
-import fc.xml.xas.security.EncryptedKey;
-import fc.xml.xas.security.SecUtil;
-import fc.xml.xas.security.TypeAttributeSource;
-import fc.xml.xas.security.VerifySource;
-import fc.xml.xas.typing.Codec;
-import fc.xml.xas.typing.ParsedPrimitive;
-import fc.xml.xas.typing.TypedItem;
-import fc.xml.xas.typing.TypingUtil;
-import fc.xml.xas.typing.XmlCodec;
-
-public class Security {
-
- private static final String TEST_NS = "http://www.hiit.fi/fuego/fc/xml/wss";
- private static final Qname CARD_NAME = new Qname(TEST_NS, "item");
- private static final EndTag CARD_END = new EndTag(CARD_NAME);
-
- private static final String SOAP_NS =
- "http://schemas.xmlsoap.org/soap/envelope/";
- private static final Qname ENVELOPE_NAME = new Qname(SOAP_NS, "Envelope");
- private static final EndTag ENVELOPE_END = new EndTag(ENVELOPE_NAME);
- private static final Qname HEADER_NAME = new Qname(SOAP_NS, "Header");
- private static final EndTag HEADER_END = new EndTag(HEADER_NAME);
- private static final Qname BODY_NAME = new Qname(SOAP_NS, "Body");
- private static final EndTag BODY_END = new EndTag(BODY_NAME);
-
- private static final String WSSE_NS =
- "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd";
- private static final Qname SECURITY_NAME = new Qname(WSSE_NS, "Security");
- private static final EndTag SECURITY_END = new EndTag(SECURITY_NAME);
- private static final Qname BINARY_NAME =
- new Qname(WSSE_NS, "BinarySecurityToken");
- private static final EndTag BINARY_END = new EndTag(BINARY_NAME);
-
- private static final int CUTOFF = 5;
- private static final int ITERS = 10;
-
- private static byte[] userBytes =
- { 48, -126, 3, 12, 48, -126, 1, -12, -96, 3, 2, 1, 2, 2, 16, 51, -90,
- 4, 127, -79, 85, 99, 31, -19, 103, 33, 23, -127, 80, -88, -103, 48,
- 13, 6, 9, 42, -122, 72, -122, -9, 13, 1, 1, 5, 5, 0, 48, 48, 49,
- 14, 48, 12, 6, 3, 85, 4, 10, 12, 5, 79, 65, 83, 73, 83, 49, 30, 48,
- 28, 6, 3, 85, 4, 3, 12, 21, 79, 65, 83, 73, 83, 32, 73, 110, 116,
- 101, 114, 111, 112, 32, 84, 101, 115, 116, 32, 67, 65, 48, 30, 23,
- 13, 48, 53, 48, 51, 49, 57, 48, 48, 48, 48, 48, 48, 90, 23, 13, 49,
- 56, 48, 51, 49, 57, 50, 51, 53, 57, 53, 57, 90, 48, 66, 49, 14, 48,
- 12, 6, 3, 85, 4, 10, 12, 5, 79, 65, 83, 73, 83, 49, 32, 48, 30, 6,
- 3, 85, 4, 11, 12, 23, 79, 65, 83, 73, 83, 32, 73, 110, 116, 101,
- 114, 111, 112, 32, 84, 101, 115, 116, 32, 67, 101, 114, 116, 49,
- 14, 48, 12, 6, 3, 85, 4, 3, 12, 5, 65, 108, 105, 99, 101, 48, -127,
- -97, 48, 13, 6, 9, 42, -122, 72, -122, -9, 13, 1, 1, 1, 5, 0, 3,
- -127, -115, 0, 48, -127, -119, 2, -127, -127, 0, -94, -88, -67,
- -12, 28, -75, 85, -118, 52, 104, 122, -28, 40, 35, 83, -32, 57, 8,
- -128, -14, -1, 74, 6, -95, 109, -30, -99, 26, 26, -37, -69, 114,
- -74, 92, 110, -38, -83, -16, -3, -74, -94, 1, 32, -93, 31, -83,
- 126, 6, -89, -35, 13, 37, -81, 57, 1, 93, 114, -120, -37, 4, -54,
- -6, -66, -103, 73, -52, -92, -41, 10, -100, -75, -53, 58, 57, 19,
- -104, -64, -86, 13, -122, -37, -111, -24, 73, -107, 115, -25, 105,
- 98, -13, -67, -17, -90, 91, 74, 73, 116, -4, 109, 127, 122, -37,
- 15, -125, -46, -3, -64, 80, 34, -5, 105, -114, 106, -61, 1, 79, 21,
- -79, -110, -109, -16, 51, 121, 43, 44, -2, 17, -101, 2, 3, 1, 0, 1,
- -93, -127, -109, 48, -127, -112, 48, 9, 6, 3, 85, 29, 19, 4, 2, 48,
- 0, 48, 51, 6, 3, 85, 29, 31, 4, 44, 48, 42, 48, 40, -94, 38, -122,
- 36, 104, 116, 116, 112, 58, 47, 47, 105, 110, 116, 101, 114, 111,
- 112, 46, 98, 98, 116, 101, 115, 116, 46, 110, 101, 116, 47, 99,
- 114, 108, 47, 99, 97, 46, 99, 114, 108, 48, 14, 6, 3, 85, 29, 15,
- 1, 1, -1, 4, 4, 3, 2, 4, -80, 48, 29, 6, 3, 85, 29, 14, 4, 22, 4,
- 20, 10, -30, 93, 19, 80, 118, 117, 65, 93, -43, -39, 11, 101, 44,
- -48, -26, -8, -6, 49, -120, 48, 31, 6, 3, 85, 29, 35, 4, 24, 48,
- 22, -128, 20, -64, -99, 40, -4, -63, -21, 53, -95, 29, -42, -86,
- -86, -96, 28, 26, 77, -62, 73, 15, 15, 48, 13, 6, 9, 42, -122, 72,
- -122, -9, 13, 1, 1, 5, 5, 0, 3, -126, 1, 1, 0, 5, 58, -87, 58,
- -101, -42, -5, -84, -85, 45, 124, -108, -108, -3, -79, 37, -79, 36,
- -94, 21, -57, 35, -109, -106, -64, -91, -91, 120, -26, -3, -122,
- 89, 33, 90, 123, 84, 106, 87, -36, 20, -30, 64, -127, 76, -121,
- -33, 68, -45, -92, 121, 93, -49, 29, 126, -68, -83, -117, 63, 56,
- 104, 80, 82, -104, 28, 77, 72, -55, 11, -24, -112, 19, 118, 38, 49,
- 78, -21, -128, 80, -70, 64, -118, -99, -104, 101, 116, -76, 79,
- -60, 104, 95, -111, 55, 113, 66, 7, 95, -26, -80, -118, -1, 8, 119,
- -59, 91, 25, 8, -44, -33, -72, -61, 102, -108, 3, 58, -108, -32,
- 32, -15, 7, 110, 13, -88, 119, 88, 86, 105, 16, 13, 44, -38, 124,
- 16, 104, 35, 80, 76, -45, 35, 36, 47, 45, 106, -3, 66, 6, -66, -66,
- 19, -111, 64, -101, 3, -41, 63, -70, 73, -58, 127, 69, -61, -45,
- -105, 71, 42, -101, 68, 14, 47, -37, 46, -40, -91, -79, -92, 27,
- 97, -120, -11, 75, -50, 31, 14, -110, 26, -9, -8, 21, 20, -83,
- -124, -61, 14, -33, -106, 27, -90, 41, 6, -80, -72, -79, -34, -16,
- 44, 93, 101, -94, -30, -68, 31, 84, -26, 51, 64, -83, 14, 20, -13,
- 98, -11, 19, 2, 81, -44, -121, -45, -87, -67, -72, -75, -100, -110,
- 32, -79, -114, -117, 52, 21, 3, -125, 100, 79, 101, -32, 4, -58,
- -53, -37, 61, -124, -43, 112, -81, 35, -119, 79 };
-
- private static Random random = new Random(19061975L);
- private static AsymmetricCipherKeyPair keyPair;
- private static byte[] key;
-
- private static void initSecurity () {
- BigInteger modulus =
- new BigInteger(
- "114223138481062383818743472854345446729415521820579721478671411120076686448918620302220709845014730631814478188984612465856840519852245805751892337820823145686311359090114506894126920369485682523288840662511969165284005936035859388250282090838456799125935768645086141305672131191153192376610593502582005436827");
- BigInteger pub = new BigInteger("65537");
- BigInteger priv =
- new BigInteger(
- "70156155961948275567326563815950795233214260644274158546789757111501088844901677266662957312531515817361615431606536850758127492036749476157451855811245452516036408423715290481767027536732741413397901727264890487785997545700283017129062803344411768517700818077537872436050914359831030152123534899150431708577");
- RSAKeyParameters privParam = new RSAKeyParameters(true, modulus, priv);
- RSAKeyParameters pubParam = new RSAKeyParameters(true, modulus, pub);
- keyPair = new AsymmetricCipherKeyPair(pubParam, privParam);
- key = new byte[16];
- random.nextBytes(key);
- }
-
- private static void addCard (List<Item> list, StartTag parent,
- ClassLoader loader) throws IOException {
- StartTag card = new StartTag(CARD_NAME, parent);
- list.add(card);
- list.add(new TypedItem(CreditCard.CARD_TYPE, new CreditCard()));
- list.add(CARD_END);
- }
-
- private static XasFragment buildMessage (int size, ClassLoader loader)
- throws IOException {
- List<Item> list = new ArrayList<Item>();
- list.add(StartDocument.instance());
- StartTag envelope = new StartTag(ENVELOPE_NAME);
- envelope.addPrefix(SOAP_NS, "soap");
- envelope.addPrefix(XasUtil.XSI_NS, "xsi");
- envelope.addPrefix(XasUtil.XSD_NS, "xsd");
- envelope.addPrefix(WSSE_NS, "wsse");
- envelope.addPrefix(SecUtil.DS_NS, "ds");
- envelope.addPrefix(SecUtil.XENC_NS, "xenc");
- list.add(envelope);
- StartTag header = new StartTag(HEADER_NAME, envelope);
- list.add(header);
- StartTag security = new StartTag(SECURITY_NAME, header);
- list.add(security);
- StartTag binaryToken = new StartTag(BINARY_NAME, security);
- list.add(binaryToken);
- list.add(new ParsedPrimitive(XasUtil.BASE64_BINARY_TYPE, userBytes));
- list.add(BINARY_END);
- DsSignature sigItem =
- new DsSignature(keyPair.getPrivate(), security,
- SecUtil.RSA_SIGNATURE);
- list.add(sigItem);
- EncryptedKey encKey = new EncryptedKey(keyPair.getPublic(), security);
- list.add(encKey);
- list.add(SECURITY_END);
- list.add(HEADER_END);
- StartTag body = new StartTag(BODY_NAME, envelope);
- list.add(body);
- List<Item> bodyList = new ArrayList<Item>();
- Qname rootName = new Qname(TEST_NS, "message");
- StartTag root = new StartTag(rootName, body);
- root.addPrefix(TEST_NS, "fc");
- bodyList.add(root);
- int sigStart = bodyList.size();
- Qname cardsName = new Qname(TEST_NS, "cards");
- StartTag cards = new StartTag(cardsName, root);
- cards.addPrefix(TEST_NS, "fc");
- cards.addPrefix(CreditCard.EXPER_NS, "exp");
- cards.addPrefix(XasUtil.XSI_NS, "xsi");
- bodyList.add(cards);
- for (int i = 0; i < size; i++) {
- addCard(bodyList, cards, loader);
- }
- bodyList.add(new EndTag(cardsName));
- int sigEnd = bodyList.size();
- int encStart = bodyList.size();
- cards = new StartTag(cardsName, root);
- cards.addPrefix(TEST_NS, "fc");
- cards.addPrefix(CreditCard.EXPER_NS, "exp");
- cards.addPrefix(XasUtil.XSI_NS, "xsi");
- bodyList.add(cards);
- for (int i = 0; i < size; i++) {
- addCard(bodyList, cards, loader);
- }
- bodyList.add(new EndTag(cardsName));
- int encEnd = bodyList.size();
- bodyList.add(new EndTag(rootName));
- XasFragment fragment = new XasFragment(bodyList, bodyList.get(0));
- MutableFragmentPointer pointer = fragment.pointer();
- sigItem.addSignature(pointer, sigStart, sigEnd - sigStart,
- SecUtil.SHA_1_DIGEST);
- encKey.addDataReference(pointer, encStart, encEnd - encStart);
- encKey.setKey(key);
- list.add(fragment);
- list.add(BODY_END);
- list.add(ENVELOPE_END);
- list.add(EndDocument.instance());
- return new XasFragment(list, list.get(0));
- }
-
- public static void main (String[] args) {
- try {
- if (args.length > 1) {
- System.err.println("Usage: Security [<size>]");
- System.exit(1);
- }
- int size = args.length > 0 ? Integer.parseInt(args[0]) : 10;
- initSecurity();
- ClassLoader loader = Security.class.getClassLoader();
- Codec.registerPrimitiveCodec(new XmlCodec());
- Measurer timer = Measurer.get(Measurer.TIMING);
- Measurer memory = Measurer.get(Measurer.MEMORY);
- ByteArrayOutputStream bout = new ByteArrayOutputStream();
- int end = ITERS + CUTOFF;
- int totalSize = 0;
- for (int i = 0; i < end; i++) {
- if (i == end - ITERS) {
- Measurer.initAll();
- }
- XasFragment fragment = buildMessage(size, loader);
- bout.reset();
- XmlOutput target = new XmlOutput(bout, "UTF-8");
- Util.runGc();
- Object memoryToken = memory.start();
- Object timeToken = timer.start();
- fragment.appendTo(target);
- target.flush();
- if (i >= end - ITERS) {
- timer.finish(timeToken, "Total serializing time");
- memory.finish(memoryToken, "Total serializing memory");
- totalSize += bout.size();
- }
- byte[] result = bout.toByteArray();
- ByteArrayInputStream bin = new ByteArrayInputStream(result);
- KXmlParser parser = new KXmlParser();
- XmlPullSource source = new XmlPullSource(parser, bin);
- ParserSource typeSource = new TypeAttributeSource(source);
- ItemSource decodeSource =
- TypingUtil.typedSource(typeSource, XasUtil.XML_MIME_TYPE,
- "UTF-8");
- ItemSource decryptSource =
- new DecryptSource(decodeSource, XmlData.getKeyPair()
- .getPrivate());
- VerifySource verifySource =
- new VerifySource(XasUtil.XML_MIME_TYPE, decryptSource,
- XmlData.getKeyPair().getPublic());
- Util.runGc();
- memoryToken = memory.start();
- timeToken = timer.start();
- while (verifySource.next() != null) {
- // do nothing
- }
- if (i >= end - ITERS) {
- timer.finish(timeToken, "Total parsing time");
- memory.finish(memoryToken, "Total parsing memory");
- }
- int numVerify = verifySource.numberSuccesses();
- if (numVerify != 2) {
- System.err.println("Verified " + numVerify
- + " signatures, expected 2");
- }
- }
- timer.outputFull(System.out);
- memory.outputFull(System.out);
- System.out.println("Total size: " + totalSize + " ("
- + (end - CUTOFF) + ")");
- } catch (Exception ex) {
- ex.printStackTrace();
- System.exit(1);
- }
- }
-
-}
-
-// arch-tag: 6517aaa4-b213-4968-a186-2680ab51da3a
View
303 src/fc/exper/Sorting.java
@@ -1,303 +0,0 @@
-/*
- * Copyright 2005--2008 Helsinki Institute for Information Technology
- *
- * This file is a part of Fuego middleware. Fuego middleware is free
- * software; you can redistribute it and/or modify it under the terms
- * of the MIT license, included as the file MIT-LICENSE in the Fuego
- * middleware source distribution. If you did not receive the MIT
- * license with the distribution, write to the Fuego Core project at
- * fuego-xas-users@hoslab.cs.helsinki.fi.
- */
-
-package fc.exper;
-
-import java.io.BufferedInputStream;
-import java.io.BufferedOutputStream;
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
-import java.io.InputStream;
-import java.io.ObjectInputStream;
-import java.io.ObjectOutputStream;
-import java.util.Collections;
-import java.util.Comparator;
-import java.util.List;
-
-import fc.util.Measurer;
-import fc.util.Util;
-import fc.util.log.Log;
-import fc.xml.xas.AttributeNode;
-import fc.xml.xas.FragmentItem;
-import fc.xml.xas.Item;
-import fc.xml.xas.Qname;
-import fc.xml.xas.StartTag;
-import fc.xml.xas.XmlOutput;
-import fc.xml.xas.index.DeweyKey;
-import fc.xml.xas.index.Index;
-import fc.xml.xas.index.LazyFragment;
-import fc.xml.xas.index.SeekableKXmlSource;
-
-public class Sorting {
-
- private static SeekableKXmlSource source = null;
-
- private static DeweyKey parseKey (String keyStr, DeweyKey current,
- int index) {
- if (keyStr.length() <= index) {
- return current;
- } else {
- int i = keyStr.indexOf('/', index);
- if (i > index) {
- int c = Integer.parseInt(keyStr.substring(index, i));
- return parseKey(keyStr, current.child(c), i + 1);
- } else {
- int c = Integer.parseInt(keyStr.substring(index));
- return current.child(c);
- }
- }
- }
-
- public static void main (String[] args) {
- try {
- if (args.length < 2 || args.length > 5) {
- System.err.println("Usage: Sorting <file> <key>"
- + " [<index type> [<index depth> [<index file>]]]");
- System.exit(1);
- }
- Measurer.init(Measurer.TIMING);
- Measurer timer = Measurer.get(Measurer.TIMING);
- String fileStr = args[0];
- String outStr = fileStr + ".out";
- String keyStr = args[1];
- boolean elem = args.length > 2 && args[2].equals("elem");
- int depth = args.length > 3 ? Integer.parseInt(args[3])
- : Integer.MAX_VALUE;
- if (depth <= 0) {
- depth = Integer.MAX_VALUE;
- }
- File indexFile = null;
- if (args.length > 4) {
- indexFile = new File(args[4]);
- }
- DeweyKey key = parseKey(keyStr, DeweyKey.root(), 1);
- Log.log("Key", Log.INFO, key);
- byte[] input = null;
- int end = 10;
- for (int i = 0; i < end; i++ ) {
- Util.runGc();
- long beginMemory = Util.usedMemory();
- Index index;
- Object totalToken = timer.start();
- Object token = timer.start();
- if (indexFile != null && indexFile.exists()) {
- InputStream base = null;
- if (System.getProperty("fc.test.slurp") != null) {
- ByteArrayOutputStream bout = new ByteArrayOutputStream();
- FileInputStream fin = new FileInputStream(indexFile);
- byte[] buffer = new byte[4096];
- int n;
- while ((n = fin.read(buffer, 0, buffer.length)) > 0) {
- bout.write(buffer, 0, n);
- }
- base = new ByteArrayInputStream(bout.toByteArray());
- } else {
- base = new BufferedInputStream(new FileInputStream(
- indexFile), 4096);
- }
- ObjectInputStream in = new ObjectInputStream(base);
- index = (Index) in.readObject();
- in.close();
- } else {
- if (System.getProperty("fc.test.slurp") != null) {
- ByteArrayOutputStream bout = new ByteArrayOutputStream();
- FileInputStream fin = new FileInputStream(fileStr);
- byte[] buffer = new byte[4096];
- int n;
- while ((n = fin.read(buffer, 0, buffer.length)) > 0) {
- bout.write(buffer, 0, n);
- }
- input = bout.toByteArray();
- source = new SeekableKXmlSource(input, 0, input.length);
- } else {
- source = new SeekableKXmlSource(fileStr);
- }
- index = elem ? Index.buildElement(source, depth) : Index
- .buildFull(source, depth);
- }
- if (i >= end - 2) {
- timer.finish(token, "Index building");
- timer.finish(totalToken, "Total time");
- }
- long spentMemory = Util.usedMemory();
- Util.runGc();
- long endMemory = Util.usedMemory();
- if (i >= end - 2) {
- System.out.println("Index building: " + (spentMemory - beginMemory));
- System.out.println("Index size: "
- + (endMemory - beginMemory));
- // System.out.println("RIS: " + fc.util.RaInputStream.count);
- // System.out.println("U8R: " + fc.util.Utf8Reader.count);
- if (Log.isEnabled(Log.TRACE)) {
- Log.log("Index", Log.TRACE, index);
- } else {
- Log.log("Indexed entries", Log.INFO, index.size());
- }
- }
- totalToken = timer.start();
- if (input != null) {
- source = new SeekableKXmlSource(input, 0, input.length);
- } else {
- source = new SeekableKXmlSource(fileStr);
- }
- index.setSource(source);
- if (i >= end - 2) {
- timer.finish(totalToken, "Total time");
- }
- Util.runGc();
- beginMemory = Util.usedMemory();
- totalToken = timer.start();
- token = timer.start();
- Item firstItem = source.next();
- DeweyKey firstKey = DeweyKey.initial();
- DeweyKey prevKey = firstKey;
- while (!Item.isStartTag(firstItem)) {
- prevKey = firstKey;
- firstItem = source.next();
- firstKey = firstKey.next();
- }
- source.setPosition(source.getPreviousPosition(), null);
- LazyFragment fragment = new LazyFragment(index, prevKey, firstItem);
- if (i >= end - 2) {
- timer.finish(token, "Lazy fragment building");
- timer.finish(totalToken, "Total time");
- }
- spentMemory = Util.usedMemory();
- Util.runGc();
- endMemory = Util.usedMemory();
- if (i >= end - 2) {
- System.out.println("Lazy fragment building: " + (spentMemory - beginMemory));
- System.out.println("Lazy fragment size: "
- + (endMemory - beginMemory));
- }
- Log.log("Fragment", Log.DEBUG, fragment);
- Util.runGc();
- beginMemory = Util.usedMemory();
- totalToken = timer.start();
- token = timer.start();
- FragmentItem sortable = fragment.force(key);
- if (i >= end - 2) {
- timer.finish(token, "Fragment forcing");
- timer.finish(totalToken, "Total time");
- }
- spentMemory = Util.usedMemory();
- Util.runGc();
- endMemory = Util.usedMemory();
- if (i >= end - 2) {
- System.out.println("Fragment forcing: " + (spentMemory - beginMemory));
- System.out.println("Forced fragment size: "
- + (endMemory - beginMemory));
- Log.log("Forced fragment", Log.DEBUG, sortable);
- // System.out.println("RIS: " + fc.util.RaInputStream.count);
- // System.out.println("U8R: " + fc.util.Utf8Reader.count);
- }
- totalToken = timer.start();
- token = timer.start();
- if (sortable != null) {
- List<Item> items = sortable.getFragmentContent();
- if (items != null) {
- Collections.sort(items, new TagCompare());
- sortable.setFragmentContent(items);
- }
- }
- if (i >= end - 2) {
- timer.finish(token, "Sorting in place");
- timer.finish(totalToken, "Total time");
- Log.log("Sorted fragment", Log.DEBUG, sortable);
- }
- Util.runGc();
- beginMemory = Util.usedMemory();
- XmlOutput out = new XmlOutput(new FileOutputStream(outStr),
- source.getEncoding());
- totalToken = timer.start();
- token = timer.start();
- fragment.appendTo(out);
- out.flush();
- if (i >= end - 2) {
- timer.finish(token, "Output");
- }
- if (indexFile != null && !indexFile.exists()) {
- token = timer.start();
- ObjectOutputStream oos = new ObjectOutputStream(
- new BufferedOutputStream(new FileOutputStream(
- indexFile), 4096));
- oos.writeObject(index);
- oos.flush();
- oos.close();
- if (i >= end - 2) {
- timer.finish(token, "Index output");
- }
- }
- if (i >= end - 2) {
- timer.finish(totalToken, "Total time");
- }
- spentMemory = Util.usedMemory();
- Util.runGc();
- endMemory = Util.usedMemory();
- if (i >= end - 2) {
- System.out.println("Performing output: " + (spentMemory - beginMemory));
- System.out.println("Output left: " + (endMemory - beginMemory));
- timer.output(System.out);
- // System.out.println("RIS: " + fc.util.RaInputStream.count);
- // System.out.println("U8R: " + fc.util.Utf8Reader.count);
- }
- }
- } catch (Exception ex) {
- ex.printStackTrace();
- System.exit(1);
- }
- }
-
- static class TagCompare implements Comparator<Item> {
-
- private static final String keyAttribute = System.getProperty(
- "fc.test.xassortkey", "key");
- private static final Qname NAME_NAME = new Qname("", keyAttribute);
-
- public int compare (Item i1, Item i2) {
- int t1 = i1.getType();
- int t2 = i2.getType();
- if (t1 != t2) {
- return t1 - t2;
- } else if (FragmentItem.isFragment(i1)) {
- return compare(((FragmentItem) i1).get(0), ((FragmentItem) i2)
- .get(0));
- } else if (Item.isStartTag(i1)) {
- StartTag st1 = (StartTag) i1;
- StartTag st2 = (StartTag) i2;
- AttributeNode a1 = st1.getAttribute(NAME_NAME);
- AttributeNode a2 = st2.getAttribute(NAME_NAME);
- if (a1 == null) {
- return a2 == null ? 0 : -1;
- } else if (a2 == null) {
- return 1;
- } else {
- String v1 = (String) a1.getValue();
- String v2 = (String) a2.getValue();
- return v1.compareTo(v2);
- }
- } else {
- return 0;
- }
- }
-
- public boolean equals (Object o) {
- return o instanceof TagCompare;
- }
-
- }
-
-}
-
-// arch-tag: d58d88e2-3899-41eb-9b43-601df2626885
View
205 src/fc/exper/StructuredSVG.java
@@ -1,205 +0,0 @@
-/*
- * Copyright 2005--2008 Helsinki Institute for Information Technology
- *
- * This file is a part of Fuego middleware. Fuego middleware is free
- * software; you can redistribute it and/or modify it under the terms
- * of the MIT license, included as the file MIT-LICENSE in the Fuego
- * middleware source distribution. If you did not receive the MIT
- * license with the distribution, write to the Fuego Core project at
- * fuego-xas-users@hoslab.cs.helsinki.fi.
- */
-
-package fc.exper;
-
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.LinkedList;
-import java.util.List;
-
-import org.kxml2.io.KXmlParser;
-
-import fc.util.log.Log;
-import fc.util.log.SysoutLogger;
-import fc.xml.xas.AttributeNode;
-import fc.xml.xas.EndTag;
-import fc.xml.xas.Item;
-import fc.xml.xas.ItemSource;
-import fc.xml.xas.ItemTarget;
-import fc.xml.xas.ItemTransform;
-import fc.xml.xas.ParserSource;
-import fc.xml.xas.Qname;
-import fc.xml.xas.StartTag;
-import fc.xml.xas.Text;
-import fc.xml.xas.TransformSource;
-import fc.xml.xas.XmlOutput;
-import fc.xml.xas.XmlPullSource;
-
-public class StructuredSVG implements ItemTransform {
-
- private static final Qname PATH_TAG_NAME = new Qname(
- "http://www.w3.org/2000/svg", "path");
-
- private static final Qname LINETO_TAG_NAME = new Qname(
- "http://www.w3.org/2000/svg", "lineto");
-
- private static final Qname MOVETO_TAG_NAME = new Qname(
- "http://www.w3.org/2000/svg", "moveto");
-
- private static final Qname CURVETO_TAG_NAME = new Qname(
- "http://www.w3.org/2000/svg", "curveto");
-
- private static final Qname CLOSE_TAG_NAME = new Qname(
- "http://www.w3.org/2000/svg", "closepath");
-
- private static final Qname POINT_TAG_NAME = new Qname(
- "http://www.w3.org/2000/svg", "coord");
-
- private static final Qname X_TAG_NAME = new Qname(
- "http://www.w3.org/2000/svg", "x");
-
- private static final Qname Y_TAG_NAME = new Qname(
- "http://www.w3.org/2000/svg", "y");
-
-
- private static final Qname PATH_ATTR = new Qname("", "d");
-
-
- boolean firstItem = true;
- LinkedList<Item> q = new LinkedList<Item>();
-
- public static void main(String[] args) throws Exception {
- Log.setLogger(new SysoutLogger());
- FileInputStream svgIn = new FileInputStream(args[0]);
- ParserSource pr = new XmlPullSource(new KXmlParser(), svgIn);
- FileOutputStream svgOut = new FileOutputStream(args[1]);
- ItemTarget t = new XmlOutput(svgOut, "UTF-8");
- ItemSource is = new TransformSource(pr, new StructuredSVG());
- long maxItem = Integer.MAX_VALUE;
- for (Item i = null; (i=is.next()) != null; ) {
- //System.out.println(i);
- t.append(i);
- if (maxItem-- < 0) {
- break;
- }
- }
- svgOut.close();
- }
-
- public void append(Item i) throws IOException {
- if (i.getType() == Item.START_TAG &&
- PATH_TAG_NAME.equals(((StartTag) i).getName())) {
- StartTag pathTag = (StartTag) i;
- AttributeNode pathAttr = pathTag.getAttribute(PATH_ATTR);
- pathTag.removeAttribute(PATH_ATTR);
- String path = pathAttr.getValue().toString();
- q.add(pathTag);
- emitPath(path, pathTag);
- } else {
- q.add(i);
- }
- }
-
- enum State { COMMAND, // Expecting command at this point
- POINTSCAN, // Scanning whitespace for number
- POINT // Scanning number
- };
-
- private void emitPath(String path, StartTag ctx) {
- State state = State.COMMAND;
- EndTag opened = null;
- int expectedCoords = -1;
- List<Double> points = new ArrayList<Double>(2);
- StringBuilder pointBuf = new StringBuilder();
- for (int i=0; i <= path.length(); i++) {
- char ch = i < path.length() ? path.charAt(i) : '\u0000';
- if (state == State.COMMAND) {
- if (opened != null) {
- q.add(opened);
- opened = null;
- }
- switch (ch) {
- case 'L': // lineto
- q.add(new StartTag(LINETO_TAG_NAME, ctx));
- opened = new EndTag(LINETO_TAG_NAME);
- expectedCoords = 1;
- state = State.POINTSCAN;
- break;
- case 'M': // moveto
- q.add(new StartTag(MOVETO_TAG_NAME, ctx));
- opened = new EndTag(MOVETO_TAG_NAME);
- expectedCoords = 1;
- state = State.POINTSCAN;
- break;
- case 'C': // curveto
- q.add(new StartTag(CURVETO_TAG_NAME, ctx));
- opened = new EndTag(CURVETO_TAG_NAME);
- expectedCoords = 3;
- state = State.POINTSCAN;
- break;
- case 'z': // closepath
- q.add(new StartTag(CLOSE_TAG_NAME, ctx));
- q.add(new EndTag(CLOSE_TAG_NAME));
- break;
- case '\u0000': // end-of-string
- break;
- default:
- Log.error("Unknown command at " + path.substring(i));
- }
- } else if (state == State.POINTSCAN) {
- if (Character.isDigit(ch) || ch == '-' || ch == '+' || ch == '.') {
- pointBuf.append(ch);
- state = State.POINT;
- } else if (!Character.isWhitespace(ch)) {
- Log.error("Expected point, got " + path.substring(i));
- }
- } else if (state == State.POINT) {
- if (!Character.isDigit(ch) && ch != '-' && ch != '+' && ch != '.') {
- double point = -0.0;
- try {
- point = Double.parseDouble(pointBuf.toString());
- pointBuf.setLength(0);
- } catch (NumberFormatException ex) {
- Log.error("Bad number: " + pointBuf.toString());
- }
- points.add(point);
- if (points.size() == 2) {
- q.add(new StartTag(POINT_TAG_NAME, ctx));
- q.add(new StartTag(X_TAG_NAME, ctx));
- //q.add(new TypedItem(XasUtil.DOUBLE_TYPE, points.get(0)));
- q.add(new Text(points.get(0).toString()));
- q.add(new EndTag(X_TAG_NAME));
- q.add(new StartTag(Y_TAG_NAME, ctx));
- //q.add(new TypedItem(XasUtil.DOUBLE_TYPE, points.get(1)));
- q.add(new Text(points.get(1).toString()));
- q.add(new EndTag(Y_TAG_NAME));
- q.add(new EndTag(POINT_TAG_NAME));
- points.clear();
- expectedCoords --;
- }
- state = expectedCoords == 0 ? state.COMMAND : state.POINTSCAN;
- i--; // Go back 1 and parse as command/point
- } else {
- pointBuf.append(ch);
- }
- } else {
- Log.error("Unknown state " + state);
- }
- }
- if (points.size() > 0 || pointBuf.length() > 0) {
- Log.error("Path ended with un-emitted coordinates " + points + ", "+ pointBuf);
- }
- }
-
- public boolean hasItems() {
- return !q.isEmpty();
- }
-
- public Item next() throws IOException {
- return q.removeFirst();
- }
-
-}
-// arch-tag: 5fb81a2c-6ab7-4b84-9536-4e0b03baf1c6
-//
View
259 src/fc/exper/Toc.java
@@ -1,259 +0,0 @@
-/*
- * Copyright 2005--2008 Helsinki Institute for Information Technology
- *
- * This file is a part of Fuego middleware. Fuego middleware is free
- * software; you can redistribute it and/or modify it under the terms
- * of the MIT license, included as the file MIT-LICENSE in the Fuego
- * middleware source distribution. If you did not receive the MIT
- * license with the distribution, write to the Fuego Core project at
- * fuego-xas-users@hoslab.cs.helsinki.fi.
- */
-
-package fc.exper;
-
-import java.io.FileOutputStream;
-import java.util.ArrayList;
-import java.util.Stack;
-
-import fc.util.Measurer;
-import fc.util.Util;
-import fc.xml.xas.EndDocument;
-import fc.xml.xas.EndTag;
-import fc.xml.xas.Item;
-import fc.xml.xas.ItemList;
-import fc.xml.xas.MutablePointer;
-import fc.xml.xas.Qname;
-import fc.xml.xas.StartDocument;
-import fc.xml.xas.StartTag;
-import fc.xml.xas.XasFragment;
-import fc.xml.xas.XmlOutput;
-import fc.xml.xas.index.DeweyKey;
-import fc.xml.xas.index.Index;
-import fc.xml.xas.index.LazyFragment;
-import fc.xml.xas.index.SeekableKXmlSource;
-
-public class Toc {
-
- private static final Qname TOC_NAME = new Qname("", "toc");
- private static final Qname CHAPTER_NAME = new Qname("", "chapter");
- private static final Qname SECTION_NAME = new Qname("", "sect1");
- private static final Qname SUBSECTION_NAME = new Qname("", "sect2");
- private static final Qname TOCCHAP_NAME = new Qname("", "tocchap");
- private static final Qname TOCSECT_NAME = new Qname("", "tocsect1");
- private static final Qname TOCSUBSECT_NAME = new Qname("", "tocsect2");
- private static final Qname ID_ATT_NAME = new Qname("", "id");
- private static final Qname REF_ATT_NAME = new Qname("", "ref");
-
- private static SeekableKXmlSource source = null;
-
- private static Index buildIndex (String fileName) throws Exception {
- source = new SeekableKXmlSource(fileName);
- Index index = new Index(source);
- DeweyKey k = DeweyKey.initial();
- StartTag context = null;
- Stack<StartTag> sts = new Stack<StartTag>();
- sts.push(null);
- Stack<Integer> ps = new Stack<Integer>();
- boolean isText = false;
- Item item;
- while ((item = source.next()) != null) {
- if (isText && !Item.isContent(item)) {
- k = k.next();
- isText = false;
- }
- if (Item.isStartTag(item)) {
- context = (StartTag) item;
- sts.push(context);
- ps.push(source.getPreviousPosition());
- k = k.down();
- } else if (Item.isEndTag(item)) {
- sts.pop();
- context = sts.peek();
- k = k.up();
- Integer pos = ps.pop();
- Qname name = ((EndTag) item).getName();
- if (name.equals(CHAPTER_NAME) || name.equals(SECTION_NAME)
- || name.equals(SUBSECTION_NAME)) {
- index.insert(k, pos, source.getCurrentPosition(), context);
- }
- k = k.next();
- } else if (Item.isContent(item)) {
- isText = true;
- } else if (Item.isDocumentDelimiter(item)) {
- isText = false;
- continue;
- } else {
- k = k.next();
- }
- }
- return index;
- }
-
- public static void main (String[] args) {
- try {
- if (args.length != 1 && args.length != 2) {
- System.err.println("Usage: Toc <file> [<with index>]");
- System.exit(1);
- }
- Measurer.init(Measurer.TIMING);
- Measurer timer = Measurer.get(Measurer.TIMING);
- String fileName = args[0];
- String outName = fileName.concat(".toc");
- int end = 10;
- Index index = null;
- for (int i = 0; i < end; i++) {
- index = null;
- Util.runGc();
- long beginMemory = Util.usedMemory();
- Object token = timer.start();
- index = args.length == 2 ? buildIndex(fileName) : null;
- if (i >= end - 2) {
- timer.finish(token, "Index building");
- }
- Util.runGc();
- long endMemory = Util.usedMemory();
- System.out.println("Index size: " + (endMemory - beginMemory));
- source = new SeekableKXmlSource(fileName);
- ItemList list = new ItemList();
- list.append(StartDocument.instance());
- Item item;
- DeweyKey k = DeweyKey.initial();
- DeweyKey tocKey = null;
- boolean isText = false;
- boolean passing = false;
- ItemList tocList = new ItemList();
- ItemList chapList = new ItemList();
- ItemList sectList = new ItemList();
- StartTag tocTag = null;
- StartTag chapTag = null;
- StartTag sectTag = null;
- Util.runGc();
- beginMemory = Util.usedMemory();
- token = timer.start();
- while ((item = source.next()) != null) {
- if (isText && !Item.isContent(item)) {
- k = k.next();
- isText = false;
- }
- if (Item.isStartTag(item)) {
- StartTag st = (StartTag) item;
- Qname name = st.getName();
- if (name.equals(TOC_NAME)) {
- tocKey = k;
- tocTag = new StartTag(TOC_NAME, st.getContext());
- tocList.append(tocTag);
- } else if (name.equals(CHAPTER_NAME)) {
- String id = (String) st
- .getAttributeValue(ID_ATT_NAME);
- if (id != null) {
- chapTag = new StartTag(TOCCHAP_NAME, tocTag);
- chapTag.addAttribute(REF_ATT_NAME, "#" + id);
- chapList.append(chapTag);
- } else {
- chapTag = null;
- }
- } else if (name.equals(SECTION_NAME)) {
- String id = (String) st
- .getAttributeValue(ID_ATT_NAME);
- if (id != null) {
- sectTag = new StartTag(TOCSECT_NAME, chapTag);
- sectTag.addAttribute(REF_ATT_NAME, "#" + id);
- sectList.append(sectTag);
- } else {
- sectTag = null;
- }
- } else if (name.equals(SUBSECTION_NAME)) {
- String id = (String) st
- .getAttributeValue(ID_ATT_NAME);
- if (id != null) {
- StartTag sst = new StartTag(TOCSUBSECT_NAME,
- sectTag);
- sst.addAttribute(REF_ATT_NAME, "#" + id);
- EndTag set = new EndTag(TOCSUBSECT_NAME);
- ArrayList<Item> l = new ArrayList<Item>(2);
- l.add(sst);
- l.add(set);
- sectList.append(new XasFragment(l, sst));
- }
- if (index != null) {
- Index.Entry entry = index.find(k);
- if (entry != null) {
- list
- .append(new LazyFragment(index, k, item));
- passing = true;
- }
- }
- }
- k = k.down();
- } else if (Item.isEndTag(item)) {
- k = k.up();
- if (k != null) {
- k = k.next();
- }
- Qname name = ((EndTag) item).getName();
- if (chapTag != null && name.equals(CHAPTER_NAME)) {
- chapList.append(new EndTag(TOCCHAP_NAME));
- tocList.append(chapList.fragment());
- chapList = new ItemList();
- } else if (sectTag != null && name.equals(SECTION_NAME)) {
- sectList.append(new EndTag(TOCSECT_NAME));
- chapList.append(sectList.fragment());
- sectList = new ItemList();
- } else if (passing && name.equals(SUBSECTION_NAME)) {
- passing = false;
- continue;
- }
- } else if (Item.isContent(item)) {
- isText = true;
- } else if (Item.isDocumentDelimiter(item)) {
- isText = false;
- continue;
- } else {
- k = k.next();
- }
- if (!passing) {
- list.append(item);
- }
- }
- list.append(EndDocument.instance());
- XasFragment fragment = list.fragment();
- if (tocKey != null && !tocList.isEmpty()) {
- tocList.append(new EndTag(TOC_NAME));
- MutablePointer p = fragment.query(tocKey.deconstruct());
- p.set(tocList.fragment());
- }
- if (i >= end - 2) {
- timer.finish(token, "TOC construction");
- }
- endMemory = Util.usedMemory();
- System.out.println("TOC memory: " + (endMemory - beginMemory));
- Util.runGc();
- endMemory = Util.usedMemory();
- System.out.println("Document size: "
- + (endMemory - beginMemory));
- Util.runGc();
- beginMemory = Util.usedMemory();
- token = timer.start();
- XmlOutput xout = new XmlOutput(new FileOutputStream(outName),
- source.getEncoding());
- fragment.appendTo(xout);
- xout.flush();
- if (i >= end - 2) {
- timer.finish(token, "Output");
- }
- endMemory = Util.usedMemory();
- System.out.println("Output memory: "
- + (endMemory - beginMemory));
- if (i >= end - 2) {
- timer.output(System.out);
- }
- }
- } catch (Exception ex) {
- ex.printStackTrace();
- System.exit(1);
- }
- }
-
-}
-
-// arch-tag: ce668ae6-cb4d-4457-8266-3dcddeb63d09
View
57 src/fc/exper/XalanSorting.java
@@ -1,57 +0,0 @@
-/*
- * Copyright 2005--2008 Helsinki Institute for Information Technology
- *
- * This file is a part of Fuego middleware. Fuego middleware is free
- * software; you can redistribute it and/or modify it under the terms
- * of the MIT license, included as the file MIT-LICENSE in the Fuego
- * middleware source distribution. If you did not receive the MIT
- * license with the distribution, write to the Fuego Core project at
- * fuego-xas-users@hoslab.cs.helsinki.fi.
- */
-
-package fc.exper;
-
-import javax.xml.transform.Transformer;
-import javax.xml.transform.TransformerFactory;
-import javax.xml.transform.stream.StreamResult;
-import javax.xml.transform.stream.StreamSource;
-
-import fc.util.Measurer;
-import fc.util.Util;
-
-public class XalanSorting {
-
- public static void main (String[] args) {
- try {
- if (args.length != 3) {
- System.err.println("Usage: XalanSorting <xsl> <in> <out>");
- System.exit(1);
- }
- Measurer.init(Measurer.TIMING);
- Measurer timer = Measurer.get(Measurer.TIMING);
- TransformerFactory factory = TransformerFactory.newInstance();
- Transformer transformer = factory.newTransformer(new StreamSource(
- args[0]));
- int end = 10;
- for (int i = 0; i < end; i++ ) {
- Util.runGc();
- long beginMemory = Util.usedMemory();
- Object token = timer.start();
- transformer.transform(new StreamSource(args[1]),
- new StreamResult(args[2]));
- if (i >= end - 2) {
- timer.finish(token, "Transform");
- long endMemory = Util.usedMemory();
- System.out.println("Memory: " + (endMemory - beginMemory));
- timer.output(System.out);
- }
- }
- } catch (Exception ex) {
- ex.printStackTrace();
- System.exit(1);
- }
- }
-
-}
-
-// arch-tag: 7e41090a-42c8-4b31-a9bc-f8abd763b325
View
86 src/fc/raxs/DeltaInputStream.java
@@ -1,86 +0,0 @@
-/*
- * Copyright 2005--2008 Helsinki Institute for Information Technology
- *
- * This file is a part of Fuego middleware. Fuego middleware is free
- * software; you can redistribute it and/or modify it under the terms
- * of the MIT license, included as the file MIT-LICENSE in the Fuego
- * middleware source distribution. If you did not receive the MIT
- * license with the distribution, write to the Fuego Core project at