예제 #1
0
        public override void service(ServletRequest request, ServletResponse response)

        {
            HttpServletRequest  req = (HttpServletRequest)request;
            HttpServletResponse res = (HttpServletResponse)response;

            res.setContentType("text/html");

            if (_path == null)
            {
                res.sendError(HttpServletResponse.SC_FORBIDDEN);
                return;
            }

            string fileName = req.getParameter("file");

            if (fileName != null)
            {
                printFile(fileName, req, res);
                return;
            }

            PrintWriter @out = res.getWriter();

            @out.println("<pre>");

            printPath(@out, _path, 0);

            @out.println("</pre>");
        }
예제 #2
0
        private static void exportFst(Fst fst, string text)
        {
            FileWriter  fileWriter  = new FileWriter(text);
            PrintWriter printWriter = new PrintWriter(fileWriter);
            State       start       = fst.getStart();

            printWriter.println(new StringBuilder().append(start.getId()).append("\t").append(start.getFinalWeight()).toString());
            int numStates = fst.getNumStates();

            for (int i = 0; i < numStates; i++)
            {
                State state = fst.getState(i);
                if (state.getId() != fst.getStart().getId())
                {
                    printWriter.println(new StringBuilder().append(state.getId()).append("\t").append(state.getFinalWeight()).toString());
                }
            }
            string[] isyms = fst.getIsyms();
            string[] osyms = fst.getOsyms();
            numStates = fst.getNumStates();
            for (int j = 0; j < numStates; j++)
            {
                State state2  = fst.getState(j);
                int   numArcs = state2.getNumArcs();
                for (int k = 0; k < numArcs; k++)
                {
                    Arc    arc   = state2.getArc(k);
                    string text2 = (isyms == null) ? Integer.toString(arc.getIlabel()) : isyms[arc.getIlabel()];
                    string text3 = (osyms == null) ? Integer.toString(arc.getOlabel()) : osyms[arc.getOlabel()];
                    printWriter.println(new StringBuilder().append(state2.getId()).append("\t").append(arc.getNextState().getId()).append("\t").append(text2).append("\t").append(text3).append("\t").append(arc.getWeight()).toString());
                }
            }
            printWriter.close();
        }
예제 #3
0
 public virtual void save(string name)
 {
     try
     {
         PrintWriter printWriter = new PrintWriter(new FileWriter(name));
         printWriter.println(new StringBuilder().append(this.ngauss).append(" ").append(this.ncoefs).toString());
         for (int i = 0; i < this.ngauss; i++)
         {
             printWriter.println(new StringBuilder().append("gauss ").append(i).append(' ').append(this.getWeight(i)).toString());
             for (int j = 0; j < this.ncoefs; j++)
             {
                 printWriter.print(new StringBuilder().append(this.means[i][j]).append(" ").toString());
             }
             printWriter.println();
             for (int j = 0; j < this.ncoefs; j++)
             {
                 printWriter.print(new StringBuilder().append(this.getVar(i, j)).append(" ").toString());
             }
             printWriter.println();
         }
         printWriter.println(this.nT);
         printWriter.close();
     }
     catch (IOException ex)
     {
         Throwable.instancehelper_printStackTrace(ex);
     }
 }
예제 #4
0
        private void DoTest(Random random, PrintWriter @out, bool useCompoundFiles, int MAX_DOCS)
        {
            Directory         directory = newDirectory();
            Analyzer          analyzer  = new MockAnalyzer(random);
            IndexWriterConfig conf      = newIndexWriterConfig(TEST_VERSION_CURRENT, analyzer);
            MergePolicy       mp        = conf.MergePolicy;

            mp.NoCFSRatio = useCompoundFiles ? 1.0 : 0.0;
            IndexWriter writer = new IndexWriter(directory, conf);

            if (VERBOSE)
            {
                Console.WriteLine("TEST: now build index MAX_DOCS=" + MAX_DOCS);
            }

            for (int j = 0; j < MAX_DOCS; j++)
            {
                Document d = new Document();
                d.Add(newTextField(PRIORITY_FIELD, HIGH_PRIORITY, Field.Store.YES));
                d.Add(newTextField(ID_FIELD, Convert.ToString(j), Field.Store.YES));
                writer.addDocument(d);
            }
            writer.Dispose();

            // try a search without OR
            IndexReader   reader   = DirectoryReader.Open(directory);
            IndexSearcher searcher = newSearcher(reader);

            Query query = new TermQuery(new Term(PRIORITY_FIELD, HIGH_PRIORITY));

            @out.println("Query: " + query.ToString(PRIORITY_FIELD));
            if (VERBOSE)
            {
                Console.WriteLine("TEST: search query=" + query);
            }

            Sort sort = new Sort(SortField.FIELD_SCORE, new SortField(ID_FIELD, SortField.Type.INT));

            ScoreDoc[] hits = searcher.Search(query, null, MAX_DOCS, sort).scoreDocs;
            PrintHits(@out, hits, searcher);
            CheckHits(hits, MAX_DOCS, searcher);

            // try a new search with OR
            searcher = newSearcher(reader);
            hits     = null;

            BooleanQuery booleanQuery = new BooleanQuery();

            booleanQuery.Add(new TermQuery(new Term(PRIORITY_FIELD, HIGH_PRIORITY)), BooleanClause.Occur_e.SHOULD);
            booleanQuery.Add(new TermQuery(new Term(PRIORITY_FIELD, MED_PRIORITY)), BooleanClause.Occur_e.SHOULD);
            @out.println("Query: " + booleanQuery.ToString(PRIORITY_FIELD));

            hits = searcher.search(booleanQuery, null, MAX_DOCS, sort).scoreDocs;
            PrintHits(@out, hits, searcher);
            CheckHits(hits, MAX_DOCS, searcher);

            reader.Close();
            directory.Close();
        }
예제 #5
0
 private void PrintHits(PrintWriter @out, ScoreDoc[] hits, IndexSearcher searcher)
 {
     @out.println(hits.Length + " total results\n");
     for (int i = 0; i < hits.Length; i++)
     {
         if (i < 10 || (i > 94 && i < 105))
         {
             Document d = searcher.Doc(hits[i].Doc);
             @out.println(i + " " + d.Get(ID_FIELD));
         }
     }
 }
예제 #6
0
        private void saveMixtureWeightsAscii(GaussianWeights gaussianWeights, string text, bool append)
        {
            this.logger.info("Saving mixture weights to: ");
            this.logger.info(text);
            OutputStream outputStream = StreamFactory.getOutputStream(this.location, text, append);

            if (outputStream == null)
            {
                string text2 = new StringBuilder().append("Error trying to write file ").append(this.location).append(text).toString();

                throw new IOException(text2);
            }
            PrintWriter printWriter = new PrintWriter(outputStream, true);

            printWriter.print("mixw ");
            int statesNum = gaussianWeights.getStatesNum();

            printWriter.print(new StringBuilder().append(statesNum).append(" ").toString());
            int streamsNum = gaussianWeights.getStreamsNum();

            printWriter.print(new StringBuilder().append(streamsNum).append(" ").toString());
            int gauPerState = gaussianWeights.getGauPerState();

            printWriter.println(gauPerState);
            for (int i = 0; i < statesNum; i++)
            {
                for (int j = 0; j < streamsNum; j++)
                {
                    printWriter.print(new StringBuilder().append("mixw [").append(i).append(" ").append(j).append("] ").toString());
                    float[] array  = new float[gauPerState];
                    float[] array2 = new float[gauPerState];
                    for (int k = 0; k < gauPerState; k++)
                    {
                        array2[k] = gaussianWeights.get(i, j, k);
                    }
                    this.logMath.logToLinear(array2, array);
                    float num = 0f;
                    for (int l = 0; l < gauPerState; l++)
                    {
                        num += array[l];
                    }
                    printWriter.println(num);
                    printWriter.print("\n\t");
                    for (int l = 0; l < gauPerState; l++)
                    {
                        printWriter.print(new StringBuilder().append(" ").append(array[l]).toString());
                    }
                    printWriter.println();
                }
            }
            outputStream.close();
        }
예제 #7
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: public void dumpIndexFile(String filename) throws java.io.IOException, java.io.FileNotFoundException
        public virtual void dumpIndexFile(string filename)
        {
            PrintWriter @out = new PrintWriter(new System.IO.FileStream(filename, System.IO.FileMode.Create, System.IO.FileAccess.Write));

            @out.println("  Start    Size       Name");
            string[] files     = listDirectory("");
            long     totalSize = dumpIndexRecursive(@out, "", files);
            long     imageSize = ((long)numSectors) * sectorLength;

            @out.println(string.Format("Total Size {0,10:D}", totalSize));
            @out.println(string.Format("Image Size {0,10:D}", imageSize));
            @out.println(string.Format("Missing    {0,10:D} ({1:D} sectors)", imageSize - totalSize, numSectors - (totalSize / sectorLength)));
            @out.close();
        }
예제 #8
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Override protected void writeLog(@Nonnull PrintWriter out, @Nonnull String message)
        protected internal override void WriteLog(PrintWriter @out, string message)
        {
            @out.write(_prefix);
            @out.write(": ");
            @out.write(message);
            @out.println();
        }
예제 #9
0
        public virtual void dumpDot(PrintWriter @out)
        {
            @out.write("digraph \"CART Tree\" {\n");
            @out.write("rankdir = LR\n");
            DecisionTree.Node[] array = this.cart;
            int num = array.Length;

            for (int i = 0; i < num; i++)
            {
                DecisionTree.Node node = array[i];
                @out.println(new StringBuilder().append("\t\"node").append(Object.instancehelper_hashCode(node)).append("\" [ label=\"").append(Object.instancehelper_toString(node)).append("\", color=").append(this.dumpDotNodeColor(node)).append(", shape=").append(this.dumpDotNodeShape(node)).append(" ]\n").toString());
                if (node is DecisionTree.DecisionNode)
                {
                    DecisionTree.DecisionNode decisionNode = (DecisionTree.DecisionNode)node;
                    if (decisionNode.qtrue < this.cart.Length && this.cart[decisionNode.qtrue] != null)
                    {
                        @out.write(new StringBuilder().append("\t\"node").append(Object.instancehelper_hashCode(node)).append("\" -> \"node").append(Object.instancehelper_hashCode(this.cart[decisionNode.qtrue])).append("\" [ label=TRUE ]\n").toString());
                    }
                    if (decisionNode.qfalse < this.cart.Length && this.cart[decisionNode.qfalse] != null)
                    {
                        @out.write(new StringBuilder().append("\t\"node").append(Object.instancehelper_hashCode(node)).append("\" -> \"node").append(Object.instancehelper_hashCode(this.cart[decisionNode.qfalse])).append("\" [ label=FALSE ]\n").toString());
                    }
                }
            }
            @out.write("}\n");
            @out.close();
        }
예제 #10
0
        private void Write(RotatingFileOutputStreamSupplier supplier, string line)
        {
            PrintWriter writer = new PrintWriter(supplier.Get());

            writer.println(line);
            writer.flush();
        }
예제 #11
0
        private void DoTestSearch(Random random, PrintWriter @out, bool useCompoundFile)
        {
            Directory         directory = newDirectory();
            Analyzer          analyzer  = new MockAnalyzer(random);
            IndexWriterConfig conf      = newIndexWriterConfig(TEST_VERSION_CURRENT, analyzer);
            MergePolicy       mp        = conf.MergePolicy;

            mp.NoCFSRatio = useCompoundFile ? 1.0 : 0.0;
            IndexWriter writer = new IndexWriter(directory, conf);

            string[] docs = new string[] { "a b c d e", "a b c d e a b c d e", "a b c d e f g h i j", "a c e", "e c a", "a c e a c e", "a c e a b c" };
            for (int j = 0; j < docs.Length; j++)
            {
                Document d = new Document();
                d.add(newTextField("contents", docs[j], Field.Store.YES));
                d.add(newStringField("id", "" + j, Field.Store.NO));
                writer.addDocument(d);
            }
            writer.close();

            IndexReader   reader   = DirectoryReader.open(directory);
            IndexSearcher searcher = newSearcher(reader);

            ScoreDoc[] hits = null;

            Sort sort = new Sort(SortField.FIELD_SCORE, new SortField("id", SortField.Type.INT));

            foreach (Query query in BuildQueries())
            {
                @out.println("Query: " + query.ToString("contents"));
                if (VERBOSE)
                {
                    Console.WriteLine("TEST: query=" + query);
                }

                hits = searcher.search(query, null, 1000, sort).scoreDocs;

                @out.println(hits.Length + " total results");
                for (int i = 0; i < hits.Length && i < 10; i++)
                {
                    Document d = searcher.doc(hits[i].doc);
                    @out.println(i + " " + hits[i].score + " " + d.get("contents"));
                }
            }
            reader.close();
            directory.close();
        }
예제 #12
0
 public virtual void ToString(PrintWriter writer)
 {
     _inner.dumpToString(writer);                 // legacy method - don't convert exceptions...
     foreach (Notification notification in JavaConversions.asJavaIterable(_inner.notifications()))
     {
         writer.println(notification.Description);
     }
 }
예제 #13
0
 private void AppendConstraints(PrintWriter @out)
 {
     foreach (string line in ExportConstraints())
     {
         @out.print(line);
         @out.println(";");
     }
 }
예제 #14
0
 public virtual void dumpDot(string path)
 {
     try
     {
         PrintWriter printWriter = new PrintWriter(new FileOutputStream(path));
         printWriter.println(new StringBuilder().append("digraph \"").append(path).append("\" {").toString());
         printWriter.println("rankdir = LR\n");
         this.traverseDot(printWriter, new HashSet());
         printWriter.println("}");
         printWriter.close();
     }
     catch (FileNotFoundException ex)
     {
         [email protected](new StringBuilder().append("Can't write to ").append(path).append(' ').append(ex).toString());
     }
     return;
 }
예제 #15
0
 private void AppendIndexes(PrintWriter @out)
 {
     foreach (string line in ExportIndexes())
     {
         @out.print(line);
         @out.println(";");
     }
 }
예제 #16
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: public long dumpIndexRecursive(java.io.PrintWriter out, String path, String[] files) throws java.io.IOException
        public virtual long dumpIndexRecursive(PrintWriter @out, string path, string[] files)
        {
            long size = 0;

            foreach (string file in files)
            {
                string      filePath = path + "/" + file;
                Iso9660File info;
                int         fileStart  = 0;
                long        fileLength = 0;

                if (path.Length == 0)
                {
                    filePath = file;
                }

                info = getFileEntry(filePath);
                if (info != null)
                {
                    fileStart  = info.LBA;
                    fileLength = info.Size;
                    size      += (fileLength + 0x7FF) & ~0x7FF;
                }

                // "." isn't a directory (throws an exception)
                // "\01" claims to be a directory but ends up in an infinite loop
                // ignore them here as they do not contribute much to the listing
                if (file.Equals(".") || file.Equals("\x0001"))
                {
                    continue;
                }

                if (info == null || isDirectory(info))
                {
                    @out.println(string.Format("D {0:X8} {1,10:D} {2}", fileStart, fileLength, filePath));
                    string[] childFiles = listDirectory(filePath);
                    size += dumpIndexRecursive(@out, filePath, childFiles);
                }
                else
                {
                    @out.println(string.Format("  {0:X8} {1,10:D} {2}", fileStart, fileLength, filePath));
                }
            }
            return(size);
        }
예제 #17
0
        internal virtual void convertMMF(string text)
        {
            IOException ex2;

            try
            {
                BufferedReader bufferedReader = new BufferedReader(new FileReader(text));
                PrintWriter    printWriter    = new PrintWriter(new FileWriter(new StringBuilder().append(text).append(".conv").toString()));
                for (;;)
                {
                    string text2 = bufferedReader.readLine();
                    if (text2 == null)
                    {
                        break;
                    }
                    int num = String.instancehelper_indexOf(text2, "~h");
                    if (num >= 0)
                    {
                        num = String.instancehelper_indexOf(text2, 34);
                        int    num2  = String.instancehelper_lastIndexOf(text2, 34);
                        string text3 = String.instancehelper_substring(text2, num + 1, num2);
                        this.split3ph(text3);
                        string text4 = this.conv3ph();
                        printWriter.println(new StringBuilder().append("~h \"").append(text4).append('"').toString());
                    }
                    else
                    {
                        printWriter.println(text2);
                    }
                }
                printWriter.close();
                bufferedReader.close();
            }
            catch (IOException ex)
            {
                ex2 = ex;
                goto IL_D2;
            }
            return;

IL_D2:
            IOException ex3 = ex2;

            Throwable.instancehelper_printStackTrace(ex3);
        }
예제 #18
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: public void handle(String target, org.eclipse.jetty.server.Request baseRequest, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws java.io.IOException
            public override void Handle(string target, Request baseRequest, HttpServletRequest request, HttpServletResponse response)
            {
                PrintWriter @out = response.Writer;

                response.ContentType = MimeTypes.Type.APPLICATION_JSON.asString();

                string path         = request.PathInfo;
                string expectedPath = string.format(KubernetesResolver.KubernetesClient.PATH, ExpectedNamespace);

                string labelSelector = request.getParameter("labelSelector");
                string auth          = request.getHeader(HttpHeader.AUTHORIZATION.name());
                string expectedAuth  = "Bearer " + ExpectedAuthToken;

                if (!expectedPath.Equals(path))
                {
                    response.Status = HttpServletResponse.SC_BAD_REQUEST;
                    @out.println(Fail("Unexpected path: " + path));
                }
                else if (!ExpectedLabelSelector.Equals(labelSelector))
                {
                    response.Status = HttpServletResponse.SC_BAD_REQUEST;
                    @out.println(Fail("Unexpected labelSelector: " + labelSelector));
                }
                else if (!expectedAuth.Equals(auth))
                {
                    response.Status = HttpServletResponse.SC_BAD_REQUEST;
                    @out.println(Fail("Unexpected auth header value: " + auth));
                }
                else if (!"GET".Equals(request.Method))
                {
                    response.Status = HttpServletResponse.SC_BAD_REQUEST;
                    @out.println(Fail("Unexpected method: " + request.Method));
                }
                else
                {
                    response.Status = HttpServletResponse.SC_OK;
                    if (!string.ReferenceEquals(Body, null))
                    {
                        @out.println(Body);
                    }
                }

                baseRequest.Handled = true;
            }
예제 #19
0
 private void traverseGDL(PrintWriter printWriter, Set set)
 {
     if (!set.contains(this))
     {
         set.add(this);
         printWriter.println(new StringBuilder().append("   node: { title: ").append(this.getGDLID(this)).append(" label: ").append(this.getGDLLabel(this)).append(" shape: ").append(this.getGDLShape(this)).append(" color: ").append(this.getGDLColor(this)).append('}').toString());
         GrammarArc[] successors = this.getSuccessors();
         GrammarArc[] array      = successors;
         int          num        = array.Length;
         for (int i = 0; i < num; i++)
         {
             GrammarArc  grammarArc  = array[i];
             GrammarNode grammarNode = grammarArc.getGrammarNode();
             float       probability = grammarArc.getProbability();
             printWriter.println(new StringBuilder().append("   edge: { source: ").append(this.getGDLID(this)).append(" target: ").append(this.getGDLID(grammarNode)).append(" label: \"").append(probability).append("\"}").toString());
             grammarNode.traverseGDL(printWriter, set);
         }
     }
 }
예제 #20
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Override protected void writeLog(@Nonnull PrintWriter out, @Nonnull String message, @Nonnull Throwable throwable)
        protected internal override void WriteLog(PrintWriter @out, string message, Exception throwable)
        {
            @out.write(_prefix);
            @out.write(": ");
            @out.write(message);
            @out.write(' ');
            @out.write(throwable.Message);
            @out.println();
            throwable.printStackTrace(@out);
        }
예제 #21
0
        private static void dump(PrintWriter writer, Node node, Stack <Node> predecessors)
        {
            if (predecessors.Count > 0)
            {
                Node parent = null;
                foreach (Node predecessor in predecessors)
                {
                    if (isLastSibling(predecessor, parent))
                    {
                        writer.print("   ");
                    }
                    else
                    {
                        writer.print("|  ");
                    }
                    parent = predecessor;
                }
                writer.println("|");
            }
            Node parent = null;

            foreach (Node predecessor in predecessors)
            {
                if (isLastSibling(predecessor, parent))
                {
                    writer.print("   ");
                }
                else
                {
                    writer.print("|  ");
                }
                parent = predecessor;
            }
            writer.print("+- ");
            writer.println(node.ToString());

            predecessors.Push(node);
            for (int i = 0; i < node.Cardinality; i++)
            {
                dump(writer, node.getChild(i), predecessors);
            }
            predecessors.Pop();
        }
예제 #22
0
        private void saveDensityFileAscii(Pool pool, string text, bool append)
        {
            this.logger.info("Saving density file to: ");
            this.logger.info(text);
            OutputStream outputStream = StreamFactory.getOutputStream(this.location, text, append);

            if (outputStream == null)
            {
                string text2 = new StringBuilder().append("Error trying to write file ").append(this.location).append(text).toString();

                throw new IOException(text2);
            }
            PrintWriter printWriter = new PrintWriter(outputStream, true);

            printWriter.print("param ");
            int feature = pool.getFeature(Pool.Feature.__NUM_SENONES, -1);

            printWriter.print(new StringBuilder().append(feature).append(" ").toString());
            int feature2 = pool.getFeature(Pool.Feature.__NUM_STREAMS, -1);

            printWriter.print(new StringBuilder().append(feature2).append(" ").toString());
            int feature3 = pool.getFeature(Pool.Feature.__NUM_GAUSSIANS_PER_STATE, -1);

            printWriter.println(feature3);
            for (int i = 0; i < feature; i++)
            {
                printWriter.println(new StringBuilder().append("mgau ").append(i).toString());
                printWriter.println("feat 0");
                for (int j = 0; j < feature3; j++)
                {
                    printWriter.print(new StringBuilder().append("density \t").append(j).toString());
                    int     id    = i * feature3 + j;
                    float[] array = (float[])pool.get(id);
                    for (int k = 0; k < this.vectorLength; k++)
                    {
                        printWriter.print(new StringBuilder().append(" ").append(array[k]).toString());
                    }
                    printWriter.println();
                }
            }
            outputStream.close();
        }
예제 #23
0
 private void Output(PrintWriter @out, params string[] commands)
 {
     foreach (string command in commands)
     {
         if (string.ReferenceEquals(command, null))
         {
             continue;
         }
         @out.println(command);
     }
 }
예제 #24
0
 private void AppendRelationship(PrintWriter @out, Relationship rel)
 {
     @out.print("create (");
     @out.print(Identifier(rel.StartNode));
     @out.print(")-[:");
     @out.print(Quote(rel.Type.name()));
     FormatProperties(@out, rel);
     @out.print("]->(");
     @out.print(Identifier(rel.EndNode));
     @out.println(")");
 }
예제 #25
0
        protected internal virtual void dump(PrintWriter @out)
        {
            Iterator iterator = this.nodes.values().iterator();

            while (iterator.hasNext())
            {
                Node node = (Node)iterator.next();
                node.dump(@out);
            }
            iterator = this.edges.iterator();
            while (iterator.hasNext())
            {
                Edge edge = (Edge)iterator.next();
                edge.dump(@out);
            }
            @out.println(new StringBuilder().append("initialNode: ").append(this.initialNode.getId()).toString());
            @out.println(new StringBuilder().append("terminalNode: ").append(this.terminalNode.getId()).toString());
            @out.println(new StringBuilder().append("logBase: ").append(this.logMath.getLogBase()).toString());
            @out.flush();
        }
예제 #26
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: public java.net.URL putTmpFile(String prefix, String suffix, String contents) throws java.io.IOException
        public virtual URL PutTmpFile(string prefix, string suffix, string contents)
        {
            File tmpFile = File.createTempFile(prefix, suffix, null);

            tmpFile.deleteOnExit();
            using (PrintWriter @out = new PrintWriter(tmpFile))
            {
                @out.println(contents);
            }
            return(tmpFile.toURI().toURL());
        }
        /// <summary>
        /// Outputs the report as an ASCII table.
        /// </summary>
        /// <param name="report">  the report </param>
        /// <param name="out">  the output stream to write to </param>
        public virtual void writeAsciiTable(R report, Stream @out)
        {
            IList <Type> columnTypes = getColumnTypes(report);
            IList <AsciiTableAlignment> alignments = IntStream.range(0, columnTypes.Count).mapToObj(i => calculateAlignment(columnTypes[i])).collect(toImmutableList());
            IList <string> headers = report.ColumnHeaders;
            ImmutableList <ImmutableList <string> > cells = formatAsciiTable(report);
            string      asciiTable = AsciiTable.generate(headers, alignments, cells);
            PrintWriter pw         = new PrintWriter(new StreamWriter(@out, Encoding.UTF8));

            pw.println(asciiTable);
            pw.flush();
        }
예제 #28
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Override protected void writeLog(@Nonnull PrintWriter out, @Nonnull String message, @Nonnull Throwable throwable)
        protected internal override void WriteLog(PrintWriter @out, string message, Exception throwable)
        {
            LineStart(@out);
            @out.write(message);
            if (throwable.Message != null)
            {
                @out.write(' ');
                @out.write(throwable.Message);
            }
            @out.println();
            throwable.printStackTrace(@out);
        }
예제 #29
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: private DataFactory generateData(Header.Factory factory, org.apache.commons.lang3.mutable.MutableLong start, long count, long nodeCount, String headerString, String fileName, org.neo4j.unsafe.impl.batchimport.input.Groups groups) throws java.io.IOException
        private DataFactory GenerateData(Header.Factory factory, MutableLong start, long count, long nodeCount, string headerString, string fileName, Groups groups)
        {
            File   file   = Directory.file(fileName);
            Header header = factory.Create(charSeeker(wrap(headerString), COMMAS, false), COMMAS, IdType.Integer, groups);
            Distribution <string>    distribution    = new Distribution <string>(new string[] { "Token" });
            Deserialization <string> deserialization = new StringDeserialization(COMMAS);

            using (PrintWriter @out = new PrintWriter(new StreamWriter(file)), RandomEntityDataGenerator generator = new RandomEntityDataGenerator(nodeCount, count, toIntExact(count), Random.seed(), start.longValue(), header, distribution, distribution, 0, 0), InputChunk chunk = generator.NewChunk(), InputEntity entity = new InputEntity())
            {
                @out.println(headerString);
                while (generator.Next(chunk))
                {
                    while (chunk.Next(entity))
                    {
                        @out.println(convert(entity, deserialization, header));
                    }
                }
            }
            start.add(count);
            return(DataFactories.Data(InputEntityDecorators.NO_DECORATOR, Charsets.UTF_8, file));
        }
예제 #30
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: private java.net.URL prepareTestImportFile(int lines) throws java.io.IOException
		 private URL PrepareTestImportFile( int lines )
		 {
			  File tempFile = File.createTempFile( "testImport", ".csv" );
			  using ( PrintWriter writer = FileUtils.newFilePrintWriter( tempFile, StandardCharsets.UTF_8 ) )
			  {
					for ( int i = 0; i < lines; i++ )
					{
						 writer.println( "a,b,c" );
					}
			  }
			  return tempFile.toURI().toURL();
		 }
예제 #31
0
        private void DoTestSearch(Random random, PrintWriter @out, bool useCompoundFile)
        {
            Directory directory = newDirectory();
              Analyzer analyzer = new MockAnalyzer(random);
              IndexWriterConfig conf = newIndexWriterConfig(TEST_VERSION_CURRENT, analyzer);
              MergePolicy mp = conf.MergePolicy;
              mp.NoCFSRatio = useCompoundFile ? 1.0 : 0.0;
              IndexWriter writer = new IndexWriter(directory, conf);

              string[] docs = new string[] {"a b c d e", "a b c d e a b c d e", "a b c d e f g h i j", "a c e", "e c a", "a c e a c e", "a c e a b c"};
              for (int j = 0; j < docs.Length; j++)
              {
            Document d = new Document();
            d.add(newTextField("contents", docs[j], Field.Store.YES));
            d.add(newStringField("id", "" + j, Field.Store.NO));
            writer.addDocument(d);
              }
              writer.close();

              IndexReader reader = DirectoryReader.open(directory);
              IndexSearcher searcher = newSearcher(reader);

              ScoreDoc[] hits = null;

              Sort sort = new Sort(SortField.FIELD_SCORE, new SortField("id", SortField.Type.INT));

              foreach (Query query in BuildQueries())
              {
            @out.println("Query: " + query.ToString("contents"));
            if (VERBOSE)
            {
              Console.WriteLine("TEST: query=" + query);
            }

            hits = searcher.search(query, null, 1000, sort).scoreDocs;

            @out.println(hits.Length + " total results");
            for (int i = 0 ; i < hits.Length && i < 10; i++)
            {
              Document d = searcher.doc(hits[i].doc);
              @out.println(i + " " + hits[i].score + " " + d.get("contents"));
            }
              }
              reader.close();
              directory.close();
        }
예제 #32
0
        private void DoTest(Random random, PrintWriter @out, bool useCompoundFiles, int MAX_DOCS)
        {
            Directory directory = newDirectory();
              Analyzer analyzer = new MockAnalyzer(random);
              IndexWriterConfig conf = newIndexWriterConfig(TEST_VERSION_CURRENT, analyzer);
              MergePolicy mp = conf.MergePolicy;
              mp.NoCFSRatio = useCompoundFiles ? 1.0 : 0.0;
              IndexWriter writer = new IndexWriter(directory, conf);
              if (VERBOSE)
              {
            Console.WriteLine("TEST: now build index MAX_DOCS=" + MAX_DOCS);
              }

              for (int j = 0; j < MAX_DOCS; j++)
              {
            Document d = new Document();
            d.Add(newTextField(PRIORITY_FIELD, HIGH_PRIORITY, Field.Store.YES));
            d.Add(newTextField(ID_FIELD, Convert.ToString(j), Field.Store.YES));
            writer.addDocument(d);
              }
              writer.Dispose();

              // try a search without OR
              IndexReader reader = DirectoryReader.Open(directory);
              IndexSearcher searcher = newSearcher(reader);

              Query query = new TermQuery(new Term(PRIORITY_FIELD, HIGH_PRIORITY));
              @out.println("Query: " + query.ToString(PRIORITY_FIELD));
              if (VERBOSE)
              {
            Console.WriteLine("TEST: search query=" + query);
              }

              Sort sort = new Sort(SortField.FIELD_SCORE, new SortField(ID_FIELD, SortField.Type.INT));

              ScoreDoc[] hits = searcher.Search(query, null, MAX_DOCS, sort).scoreDocs;
              PrintHits(@out, hits, searcher);
              CheckHits(hits, MAX_DOCS, searcher);

              // try a new search with OR
              searcher = newSearcher(reader);
              hits = null;

              BooleanQuery booleanQuery = new BooleanQuery();
              booleanQuery.Add(new TermQuery(new Term(PRIORITY_FIELD, HIGH_PRIORITY)), BooleanClause.Occur_e.SHOULD);
              booleanQuery.Add(new TermQuery(new Term(PRIORITY_FIELD, MED_PRIORITY)), BooleanClause.Occur_e.SHOULD);
              @out.println("Query: " + booleanQuery.ToString(PRIORITY_FIELD));

              hits = searcher.search(booleanQuery, null, MAX_DOCS, sort).scoreDocs;
              PrintHits(@out, hits, searcher);
              CheckHits(hits, MAX_DOCS, searcher);

              reader.Close();
              directory.Close();
        }
예제 #33
0
 private void PrintHits(PrintWriter @out, ScoreDoc[] hits, IndexSearcher searcher)
 {
     @out.println(hits.Length + " total results\n");
     for (int i = 0 ; i < hits.Length; i++)
     {
       if (i < 10 || (i > 94 && i < 105))
       {
     Document d = searcher.Doc(hits[i].Doc);
     @out.println(i + " " + d.Get(ID_FIELD));
       }
     }
 }