コード例 #1
0
 protected internal void Print(PrintStream @out, Exception exception, string linePrefix)
 {
     if (exception != null)
     {
         @out.println(", exception:");
         MemoryStream buf  = new MemoryStream();
         PrintStream  sbuf = new PrintStream(buf);
         exception.printStackTrace(sbuf);
         sbuf.flush();
         StreamReader reader = new StreamReader(new StringReader(buf.ToString()));
         try
         {
             string line = reader.ReadLine();
             while (!string.ReferenceEquals(line, null))
             {
                 @out.print(linePrefix);
                 @out.print('\t');
                 @out.println(line);
                 line = reader.ReadLine();
             }
             @out.print(linePrefix);
         }
         catch (IOException e)
         {
             throw new Exception(e);
         }
     }
 }
コード例 #2
0
        /// <summary>
        /// Implements print. </summary>
        private static int print(Lua L)
        {
            int    n        = L.Top;
            object tostring = L.getGlobal("tostring");

            for (int i = 1; i <= n; ++i)
            {
                L.push(tostring);
                L.pushValue(i);
                L.call(1, 1);
                string s = L.toString(L.value(-1));
                if (s == null)
                {
                    return(L.error("'tostring' must return a string to 'print'"));
                }
                if (i > 1)
                {
                    OUT.print('\t');
                }
                OUT.print(s);
                L.pop(1);
            }
            OUT.println();
            return(0);
        }
コード例 #3
0
    public override void Print(PrintStream p)
    {
        int max = 0;

        foreach (var t in a)
        {
            for (int k = 0; k < a[0].Length; k++)
            {
                int l = StringFmt.Compact(t[k].ToString()).Length;

                if (l > max)
                {
                    max = l;
                }
            }
        }

        max += 2;

        for (int i = 0; i < a.Length; i++)
        {
            p.print("\n  ");
            for (int k = 0; k < a[0].Length; k++)
            {
                string r = StringFmt.Compact(a[i][k].ToString());
                p.print(r);
                for (int m = 0; m < max - r.Length; m++)
                {
                    p.print(" ");
                }
            }
        }
    }
コード例 #4
0
ファイル: Basic.cs プロジェクト: gywerd/WinJNI
 internal static void show(int level, BufferN b)
 {
     for (int i = 0; i < level; i++)
     {
         outt.print("  ");
     }
     outt.println(toString(b) + " " + Integer.toHexString(b.GetHashCode()));
 }
コード例 #5
0
 internal override void PrintBody(PrintStream @out, string exceptionLinePrefix)
 {
     @out.print(", filePageId:");
     @out.print(FilePageIdConflict);
     @out.print(", cachePageId:");
     @out.print(CachePageIdConflict);
     Print(@out, File);
     Print(@out, Exception, exceptionLinePrefix);
 }
コード例 #6
0
 public override void print(PrintStream p)
 {
     p.print("[ ");
     for (int i = 0; i < a.Length; i++)
     {
         string r = StringFmt.compact(a[i].ToString());
         if (i < a.Length - 1)
         {
             r += "  ";
         }
         p.print(r);
     }
     p.print(" ]");
 }
コード例 #7
0
        //FIXME:
        private static int g_write(Lua L, PrintStream stream, int arg)
        {
            //FIXME:
            int nargs  = L.Top;    //FIXME:notice here, original code is 'lua_gettop(L) - 1' (something pushed before?)
            int status = 1;

            for (; nargs != 0; arg++)
            {
                nargs--;
                if (L.type(arg) == Lua.TNUMBER)
                {
                    if (status != 0)
                    {
                        try
                        {
                            //stream.print(String.format("%s", L.toNumber(L.value(arg))));
                            //@see http://stackoverflow.com/questions/703396/how-to-nicely-format-floating-numbers-to-string-without-unnecessary-decimal-0
                            //stream.print(new DecimalFormat("#.##########").format(L.value(arg)));
                            //@see Lua#vmToString
                            FormatItem    f = new FormatItem(null, NUMBER_FMT);
                            StringBuilder b = new StringBuilder();
                            double?       d = (double?)L.toNumber(L.value(arg));
                            f.formatFloat(b, (double)d);
                            stream.print(b.ToString());
                        }
                        catch (Exception)
                        {
                            status = 0;
                        }
                    }
                }
                else
                {
                    string s = L.checkString(arg);
                    if (status != 0)
                    {
                        try
                        {
                            stream.print(s);
                        }
                        catch (Exception)
                        {
                            status = 0;
                        }
                    }
                }
            }
            return(pushresult(L, status, null));
        }
コード例 #8
0
 public override void BeginNode(long pageId, bool isLeaf, long generation, int keyCount)
 {
     if (_printHeader)
     {
         string treeNodeType = isLeaf ? "leaf" : "internal";
         @out.print(format("{%d,%s,generation=%d,keyCount=%d} ", pageId, treeNodeType, generation, keyCount));
     }
     else
     {
         @out.print("{" + pageId + "} ");
     }
 }
コード例 #9
0
 private static void outputLicenseHeader(PrintStream ps)
 {
     String[] lines =
     {
         "Licensed to the Apache Software Foundation (ASF) under one or more",
         "contributor license agreements.  See the NOTICE file distributed with",
         "this work for Additional information regarding copyright ownership.",
         "The ASF licenses this file to You under the Apache License, Version 2.0",
         "(the \"License\"); you may not use this file except in compliance with",
         "the License.  You may obtain a copy of the License at",
         "",
         "    http://www.apache.org/licenses/LICENSE-2.0",
         "",
         "Unless required by applicable law or agreed to in writing, software",
         "distributed under the License is distributed on an \"AS IS\" BASIS,",
         "WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.",
         "See the License for the specific language governing permissions and",
         "limitations under the License.",
     };
     for (int i = 0; i < lines.Length; i++)
     {
         ps.print("# ");
         ps.println(lines[i]);
     }
     ps.println();
 }
コード例 #10
0
 internal virtual void Putcs(PrintStream @out, char c, int count)
 {
     for (int i = 0; i < count; i++)
     {
         @out.print(c);
     }
 }
コード例 #11
0
 public virtual void dumpSummary()
 {
     if (this.enabled)
     {
         float num = 0f;
         if (this.utteranceStateCount > 0)
         {
             num = (float)this.utteranceSumStates / (float)this.utteranceStateCount;
         }
         [email protected]("# Utterance stats ");
         PrintStream   @out          = java.lang.System.@out;
         StringBuilder stringBuilder = new StringBuilder().append(" States: ");
         int           num2          = this.utteranceStateCount;
         int           num3          = this.frame;
         @out.print(stringBuilder.append((num3 != -1) ? (num2 / num3) : (-num2)).toString());
         if (this.utteranceStateCount > 0)
         {
             PrintStream   out2           = java.lang.System.@out;
             StringBuilder stringBuilder2 = new StringBuilder().append(" Paths: ");
             int           num4           = this.utteranceSumStates;
             int           num5           = this.frame;
             out2.print(stringBuilder2.append((num5 != -1) ? (num4 / num5) : (-num4)).toString());
             [email protected](new StringBuilder().append(" Max: ").append(this.utteranceMaxStates).toString());
             [email protected](new StringBuilder().append(" Avg: ").append(num).toString());
         }
         [email protected]();
     }
 }
コード例 #12
0
    public override List compile(Stream instream, PrintStream ps)
    {
        string s, sp = null;

        reset();
        while ((s = ReadLine(instream)) != null)
        {
            sp = s;
            translate(s);
            if (ready())
            {
                break;
            }
            else
            {
                if (ps != null)
                {
                    ps.print("> ");
                }
            }
        }
        if (sp == null)
        {
            return(null);
        }
        if (s == null && State.InList == IN_BLOCK)
        {
            List v = State.Tokens;
            State = (ParserState)State.Sub;
            State.Tokens.Add(v);
        }
        return(get());
    }
コード例 #13
0
    public virtual void printStack()
    {
        while (stack.Count > 0)
        {
            var x = stack.Pop();

            if (x is Algebraic)
            {
                var vname = "ans";

                env.putValue(vname, x);

                if ((( Algebraic )x).Name != null)
                {
                    vname = (( Algebraic )x).Name;
                }

                if (ps != null)
                {
                    var s = vname + " = ";

                    ps.print(s);

                    (( Algebraic )x).Print(ps);

                    ps.println("");
                }
            }
            else if (x is string)
            {
                ps.println(( string )x);
            }
        }
    }
コード例 #14
0
 public virtual void Print(PrintStream @out, string exceptionLinePrefix)
 {
     @out.print(this.GetType().Name);
     @out.print('#');
     @out.print(System.identityHashCode(this));
     @out.print('[');
     @out.print("time:");
     @out.print((Time - end.time) / 1000);
     @out.print(", threadId:");
     @out.print(ThreadId);
     PrintBody(@out, exceptionLinePrefix);
     @out.print(']');
 }
コード例 #15
0
 public override void Println(string line)
 {
     for (int i = 0; i < _indentation; i++)
     {
         @out.print("    ");
     }
     @out.println(line);
 }
コード例 #16
0
        public virtual void saveJSGF(URL url)
        {
            PrintStream printStream = new PrintStream(new File(url.toURI()));

            printStream.print(this.toString());
            printStream.flush();
            printStream.close();
        }
コード例 #17
0
 internal virtual void PrintProgress()
 {
     if (_output != null)
     {
         char lineSep = _interactive ? '\r' : '\n';
         if (_done)
         {
             _output.println(lineSep + "Done: " + _currentFiles + " files, " + ByteUnit.bytesToString(_currentBytes) + " processed.");
         }
         else if (MaxFiles > 0 && MaxBytes > 0)
         {
             double progress = (_currentBytes / ( double )MaxBytes) * 100;
             _output.print(lineSep + "Files: " + _currentFiles + '/' + MaxFiles + ", data: " + string.Format("{0,4:F1}%", progress));
         }
         else
         {
             _output.print(lineSep + "Files: " + _currentFiles + "/?" + ", data: ??.?%");
         }
     }
 }
コード例 #18
0
 internal override void PrintBody(PrintStream @out, string exceptionLinePrefix)
 {
     @out.print(", filePageId:");
     @out.print(FilePageId);
     @out.print(", cachePageId:");
     @out.print(CachePageId);
     @out.print(", pageCount:");
     @out.print(PageCount);
     Print(@out, File);
     @out.print(", bytesWritten:");
     @out.print(BytesWritten);
     Print(@out, Exception, exceptionLinePrefix);
 }
コード例 #19
0
        public virtual void dumpAscii(string outputFile)
        {
            PrintStream printStream = new PrintStream(new FileOutputStream(outputFile), true);

            printStream.print(this.getNumberDataPoints());
            printStream.print(' ');
            Iterator iterator = this.allFeatures.iterator();

            while (iterator.hasNext())
            {
                float[] array  = (float[])iterator.next();
                float[] array2 = array;
                int     num    = array2.Length;
                for (int i = 0; i < num; i++)
                {
                    float num2 = array2[i];
                    printStream.print(num2);
                    printStream.print(' ');
                }
            }
            printStream.close();
        }
コード例 #20
0
        public static void dumpComponentAsHTML(PrintStream @out, string name, PropertySheet properties)
        {
            @out.println("<table border=1>");
            @out.print("    <tr><th bgcolor=\"#CCCCFF\" colspan=2>");
            @out.print(name);
            @out.print("</a>");
            @out.println("</td></tr>");
            @out.println("    <tr><th bgcolor=\"#CCCCFF\">Property</th><th bgcolor=\"#CCCCFF\"> Value</th></tr>");
            Collection registeredProperties = properties.getRegisteredProperties();
            Iterator   iterator             = registeredProperties.iterator();

            while (iterator.hasNext())
            {
                string text = (string)iterator.next();
                @out.print(new StringBuilder().append("    <tr><th align=\"leftt\">").append(text).append("</th>").toString());
                object raw = properties.getRaw(text);
                if (raw is string)
                {
                    @out.println(new StringBuilder().append("<td>").append(raw).append("</td></tr>").toString());
                }
                else if (raw is List)
                {
                    List list = (List)raw;
                    @out.println("    <td><ul>");
                    Iterator iterator2 = list.iterator();
                    while (iterator2.hasNext())
                    {
                        object obj = iterator2.next();
                        @out.println(new StringBuilder().append("        <li>").append(obj).append("</li>").toString());
                    }
                    @out.println("    </ul></td>");
                }
                else
                {
                    @out.println("<td>DEFAULT</td></tr>");
                }
            }
            @out.println("</table><br>");
        }
コード例 #21
0
 public override void PercentChanged(int percent)
 {
     for (int i = _lastPercentage + 1; i <= percent; i++)
     {
         @out.print('.');
         if (i % 20 == 0)
         {
             @out.printf(" %3d%%%n", i);
         }
     }
     _lastPercentage = percent;
     @out.flush();
 }
コード例 #22
0
 internal override void PrintBody(PrintStream @out, string exceptionLinePrefix)
 {
     @out.print(", filePageId:");
     @out.print(FilePageId);
     @out.print(", cachePageId:");
     @out.print(CachePageIdConflict);
     @out.print(", hit:");
     @out.print(HitConflict);
     Print(@out, File);
     @out.append(", exclusiveLock:");
     @out.print(ExclusiveLock);
 }
コード例 #23
0
        private void PrintSampleTree(PrintStream @out, double total, PriorityQueue <Sample> children, int indent)
        {
            Sample child;

            while ((child = children.poll()) != null)
            {
                for (int i = 0; i < indent; i++)
                {
                    @out.print(' ');
                }
                @out.printf("%.2f%%: %s%n", child.get() / total * 100.0, child.StackTraceElement);
                PrintSampleTree(@out, total, child.OrderedChildren, indent + 2);
            }
        }
コード例 #24
0
ファイル: TestDirectory.cs プロジェクト: Neo4Net/Neo4Net
 private void Register(string test, string dir)
 {
     try
     {
         using (PrintStream printStream = new PrintStream(_fileSystem.openAsOutputStream(new File(EnsureBase(), ".register"), true)))
         {
             printStream.print(format("%s = %s%n", dir, test));
         }
     }
     catch (IOException e)
     {
         throw new Exception(e);
     }
 }
コード例 #25
0
 internal override void PrintBody(PrintStream @out, string exceptionLinePrefix)
 {
     @out.print(", cachePageId:");
     @out.print(CachePageIdConflict);
     @out.print(", bytesRead:");
     @out.print(BytesRead);
     @out.print(", pageEvictedByFaulter:");
     @out.print(PageEvictedByFaulter);
     Print(@out, Exception, exceptionLinePrefix);
 }
コード例 #26
0
            internal override void PrintBody(PrintStream @out, string exceptionLinePrefix)
            {
                @out.print(", elapsedMicros:");
                @out.print((Time - Event.time) / 1000);
                @out.print(", endOf:");
                Type   eventClass = Event.GetType();
                string className  = ClassSimpleNameCache.computeIfAbsent(eventClass, k => eventClass.Name);

                @out.print(className);
                @out.print('#');
                @out.print(System.identityHashCode(Event));
            }
コード例 #27
0
        public override void Check(StageExecution execution)
        {
            StringBuilder builder = new StringBuilder();

            PrintSpectrum(builder, execution, _width, DetailLevel.IMPORTANT);

            // add delta
            long progress     = last(execution.Steps()).stats().stat(Keys.done_batches).asLong() * execution.Config.batchSize();
            long currentDelta = progress - _lastProgress;

            builder.Append(" ∆").Append(FitInProgress(currentDelta));

            // and remember progress to compare with next check
            _lastProgress = progress;

            // print it (overwriting the previous contents on this console line)
            @out.print("\r" + builder);
        }
コード例 #28
0
    public static void Run()
    {
        while (true)
        {
            ps.print(Pars.prompt());

            try
            {
                Proc.set_interrupt(false);

                var istream = new MemoryStream(Encoding.UTF8.GetBytes(Console.ReadLine()));

                istream.Seek(0, SeekOrigin.Begin);

                var code = Pars.compile(istream, ps);

                if (code == null)
                {
                    ps.println("");

                    continue;
                }

                if (Proc.process_list(code, false) == Processor.EXIT)
                {
                    Console.WriteLine("\nGoodbye.");

                    Console.ResetColor();

                    return;
                }

                Proc.printStack();
            }
            catch (Exception ex)
            {
                Console.WriteLine("\n" + ex.Message);

                Proc.clearStack();
            }
        }
    }
コード例 #29
0
    public override List compile(Stream istream, PrintStream ps)
    {
        string s, sp = null;

        reset();

        while ((s = readLine(istream)) != null)
        {
            sp = s;

            translate(s);

            if (ready())
            {
                break;
            }

            if (ps != null)
            {
                ps.print("> ");
            }
        }

        if (sp == null)
        {
            return(null);
        }

        if (s == null && pst.inList == IN_BLOCK)
        {
            var v = pst.tokens;

            pst = ( ParserState )pst.sub;

            pst.tokens.Add(v);
        }

        return(get());
    }
コード例 #30
0
ファイル: Tester.cs プロジェクト: yyl-20020115/Sphinx4CSharp
        public static void printIntervals(ArrayList speakers)
        {
            [email protected](new StringBuilder().append("Detected ").append(speakers.size()).append(" Speakers :").toString());
            int      num      = 0;
            Iterator iterator = speakers.iterator();

            while (iterator.hasNext())
            {
                SpeakerCluster speakerCluster = (SpeakerCluster)iterator.next();
                PrintStream    @out           = java.lang.System.@out;
                StringBuilder  stringBuilder  = new StringBuilder().append("Speaker ");
                num++;
                @out.print(stringBuilder.append(num).append(": ").toString());
                ArrayList speakerIntervals = speakerCluster.getSpeakerIntervals();
                Iterator  iterator2        = speakerIntervals.iterator();
                while (iterator2.hasNext())
                {
                    Segment segment = (Segment)iterator2.next();
                    [email protected](new StringBuilder().append("[").append(Tester.time(segment.getStartTime())).append(" ").append(Tester.time(segment.getLength())).append("]").toString());
                }
                [email protected]();
            }
        }
コード例 #31
0
        private static void ProcessFile(File effDocFile, File outFile)
        {
            if (!effDocFile.exists())
            {
                throw new RuntimeException("file '" + effDocFile.GetAbsolutePath() + "' does not exist");
            }
            OutputStream os;
            try
            {
                os = new FileOutputStream(outFile);
            }
            catch (FileNotFoundException e)
            {
                throw new RuntimeException(e);
            }
            os = new SimpleAsciiOutputStream(os);
            PrintStream ps;
            try
            {
                ps = new PrintStream(os, true, "UTF-8");
            }
            catch (UnsupportedEncodingException e)
            {
                throw new RuntimeException(e);
            }

            outputLicenseHeader(ps);
            Type genClass = typeof(ExcelFileFormatDocFunctionExtractor);
            ps.println("# Created by (" + genClass.Name + ")");
            // identify the source file
            ps.print("# from source file '" + SOURCE_DOC_FILE_NAME + "'");
            ps.println(" (size=" + effDocFile.Length + ", md5=" + GetFileMD5(effDocFile) + ")");
            ps.println("#");
            ps.println("#Columns: (index, name, minParams, maxParams, returnClass, paramClasses, isVolatile, hasFootnote )");
            ps.println("");
            try
            {
                ZipFile zf = new ZipFile(effDocFile);
                InputStream is1 = zf.GetInputStream(zf.GetEntry("content.xml"));
                extractFunctionData(new FunctionDataCollector(ps), is1);
                zf.Close();
            }
            catch (ZipException e)
            {
                throw new RuntimeException(e);
            }
            catch (IOException e)
            {
                throw new RuntimeException(e);
            }
            ps.Close();

            String canonicalOutputFileName;
            try
            {
                canonicalOutputFileName = outFile.GetCanonicalPath();
            }
            catch (IOException e)
            {
                throw new RuntimeException(e);
            }
            Console.WriteLine("Successfully output to '" + canonicalOutputFileName + "'");
        }
コード例 #32
0
 private static void outputLicenseHeader(PrintStream ps)
 {
     String[] lines = {
     "Licensed to the Apache Software Foundation (ASF) under one or more",
     "contributor license agreements.  See the NOTICE file distributed with",
     "this work for Additional information regarding copyright ownership.",
     "The ASF licenses this file to You under the Apache License, Version 2.0",
     "(the \"License\"); you may not use this file except in compliance with",
     "the License.  You may obtain a copy of the License at",
     "",
     "    http://www.apache.org/licenses/LICENSE-2.0",
     "",
     "Unless required by applicable law or agreed to in writing, software",
     "distributed under the License is distributed on an \"AS IS\" BASIS,",
     "WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.",
     "See the License for the specific language governing permissions and",
     "limitations under the License.",
     };
     for (int i = 0; i < lines.Length; i++)
     {
         ps.print("# ");
         ps.println(lines[i]);
     }
     ps.println();
 }