//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: private static void formatAppendix(Appendable builder) throws java.io.IOException private static void FormatAppendix(Appendable builder) { Formatln(builder, " }"); Formatln(builder, "}"); Formatln(builder); Formatln(builder, "/* END OF GENERATED CONTENT */"); }
public static int RepeatTests(int repeats) { return(Appendable .Repeat(new IntAppendable(0), repeats) .Invoke(new IntAppendable(5)) .Value); }
/// <summary> /// Writes the curve nodes in a CSV format to an appendable. /// </summary> /// <param name="underlying"> the underlying appendable destination </param> /// <param name="valuationDate"> the valuation date </param> /// <param name="group"> the curve group </param> public static void writeCurveNodes(Appendable underlying, LocalDate valuationDate, RatesCurveGroup group) { CsvOutput csv = CsvOutput.standard(underlying); // header csv.writeLine(HEADERS_NODES); // rows string valuationDateStr = valuationDate.ToString(); IDictionary <Currency, Curve> discountingCurves = group.DiscountCurves; ISet <CurveName> names = new HashSet <CurveName>(); foreach (KeyValuePair <Currency, Curve> entry in discountingCurves.SetOfKeyValuePairs()) { Curve curve = entry.Value; nodeLines(valuationDateStr, curve, csv); names.Add(curve.Name); } IDictionary <Index, Curve> forwardCurves = group.ForwardCurves; foreach (KeyValuePair <Index, Curve> entry in forwardCurves.SetOfKeyValuePairs()) { Curve curve = entry.Value; if (!names.Contains(curve.Name)) { nodeLines(valuationDateStr, curve, csv); names.Add(curve.Name); } } }
//------------------------------------------------------------------------- /// <summary> /// Write sensitivities to an appendable in the standard sensitivities format. /// <para> /// The output is written in standard format, with no identifier columns. /// The parameter metadata must contain tenors. /// /// </para> /// </summary> /// <param name="curveSens"> the curve sensitivities to write </param> /// <param name="output"> the appendable to write to </param> /// <exception cref="IllegalArgumentException"> if the metadata does not contain tenors </exception> /// <exception cref="UncheckedIOException"> if an IO error occurs </exception> public void write(CurveSensitivities curveSens, Appendable output) { CsvOutput csv = CsvOutput.standard(output, "\n"); IList <string> additionalHeaders = supplier.headers(curveSens); // check for dates if (curveSens.TypedSensitivities.values().stream().flatMap(allParamSens => allParamSens.Sensitivities.stream()).flatMap(paramSens => paramSens.ParameterMetadata.stream()).anyMatch(pmd => !(pmd is TenoredParameterMetadata))) { throw new System.ArgumentException("Parameter metadata must contain tenors"); } bool containsDates = curveSens.TypedSensitivities.values().stream().flatMap(allParamSens => allParamSens.Sensitivities.stream()).flatMap(paramSens => paramSens.ParameterMetadata.stream()).anyMatch(pmd => pmd is DatedParameterMetadata); // headers csv.writeCell(SensitivityCsvLoader.REFERENCE_HEADER); csv.writeCell(SensitivityCsvLoader.TYPE_HEADER); csv.writeCell(SensitivityCsvLoader.TENOR_HEADER); if (containsDates) { csv.writeCell(SensitivityCsvLoader.DATE_HEADER); } csv.writeCell(SensitivityCsvLoader.CURRENCY_HEADER); csv.writeCell(SensitivityCsvLoader.VALUE_HEADER); csv.writeLine(additionalHeaders); // content, grouped by reference, then type MapStream.of(curveSens.TypedSensitivities).flatMapValues(sens => sens.Sensitivities.stream()).mapKeys((type, sens) => Pair.of(sens.MarketDataName.Name, type)).sortedKeys().forEach((pair, paramSens) => write(pair.First, pair.Second, curveSens, paramSens, additionalHeaders, containsDates, csv)); }
public override void AppendString(Appendable appendable, string start, string separator, string end) { try { appendable.append(start); appendable.append("offheap,size=").append(Size().ToString()).append("; "); //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final org.eclipse.collections.api.iterator.LongIterator iterator = longIterator(); LongIterator iterator = LongIterator(); for (int i = 0; i < 100 && iterator.hasNext(); i++) { appendable.append(Convert.ToString(iterator.next())); if (iterator.hasNext()) { appendable.append(", "); } } if (iterator.hasNext()) { appendable.append("..."); } appendable.append(end); } catch (IOException e) { throw new Exception(e); } }
//------------------------------------------------------------------------- // creates an instance private CsvOutput(Appendable underlying, string newLine, string separator, bool safeExpressions) { this.underlying = ArgChecker.notNull(underlying, "underlying"); this.newLine = newLine; this.separator = separator; this.safeExpressions = safeExpressions; }
/// <summary> /// Writes the curve settings in a CSV format to an appendable. /// </summary> /// <param name="underlying"> the underlying appendable destination </param> /// <param name="group"> the curve group </param> public static void writeCurveSettings(Appendable underlying, RatesCurveGroup group) { CsvOutput csv = CsvOutput.standard(underlying); // header csv.writeLine(HEADERS_SETTINGS); // rows IDictionary <Currency, Curve> discountingCurves = group.DiscountCurves; ISet <CurveName> names = new HashSet <CurveName>(); foreach (KeyValuePair <Currency, Curve> entry in discountingCurves.SetOfKeyValuePairs()) { Curve curve = entry.Value; csv.writeLine(curveSettings(curve)); names.Add(curve.Name); } IDictionary <Index, Curve> forwardCurves = group.ForwardCurves; foreach (KeyValuePair <Index, Curve> entry in forwardCurves.SetOfKeyValuePairs()) { Curve curve = entry.Value; if (!names.Contains(curve.Name)) { csv.writeLine(curveSettings(curve)); names.Add(curve.Name); } } }
public static int ConcatTests(int[] values) { return(Appendable .Concat( new IntAppendable(0), values.Select(x => new IntAppendable(x)).ToArray()) .Value); }
public void ctor_sets_empty_State_if_arg_is_null() { var initialItems = null as IEnumerable <string>; var appendable = new Appendable <string>(initialItems); Assert.Empty(appendable); }
/// <summary> /// Writes the curve group in a CSV format to an appendable. /// </summary> /// <param name="underlying"> the underlying appendable destination </param> /// <param name="groups"> the curve groups </param> public static void writeCurveGroup(Appendable underlying, params RatesCurveGroup[] groups) { CsvOutput csv = CsvOutput.standard(underlying); csv.writeLine(HEADERS); foreach (RatesCurveGroup group in groups) { writeCurveGroup(csv, group); } }
public void Add_adds_an_item_to_the_collection() { const string ITEM = "Hello world!"; var appendable = new Appendable <string>(); appendable.Add(ITEM); Assert.Contains(ITEM, appendable); }
public static void InvalidArgumentsTest() { // ReSharper disable AssignNullToNotNullAttribute Assert.Throws <ArgumentNullException>(() => Appendable.Concat(null, new IntAppendable(0))); Assert.Throws <ArgumentNullException>(() => Appendable.Concat(new IntAppendable(0), default(IntAppendable[]))); Assert.Throws <ArgumentNullException>(() => Appendable.Concat(new IntAppendable(0), default(IEnumerable <IntAppendable>))); Assert.Throws <ArgumentNullException>(() => default(IntAppendable).Repeat(new IntAppendable(0), 0)); Assert.Throws <ArgumentNullException>(() => new IntAppendable(0).Repeat(null, 0)); Assert.Throws <ArgumentOutOfRangeException>(() => new IntAppendable(0).Repeat(new IntAppendable(0), -1)); // ReSharper restore AssignNullToNotNullAttribute }
public void ctor_sets_initial_state() { var initialItems = new[] { "a", "b", "c" }; var appendable = new Appendable <string>(initialItems); Assert.Equal(initialItems.Length, appendable.Count()); foreach (var item in initialItems) { Assert.Contains(item, appendable); } }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: private void formatPreamble(Appendable builder) throws java.io.IOException private void FormatPreamble(Appendable builder) { string interfaceSimpleName = _interfaceClass.Name; //JAVA TO C# CONVERTER WARNING: The .NET Type.FullName property will not always yield results identical to the Java Class.getCanonicalName method: string interfaceClassName = interfaceSimpleName.Length == 0 ? _interfaceClass.FullName : interfaceSimpleName; if (_generatedClassPackage.Length > 0) { Formatln(builder, "package %s;", _generatedClassPackage); Formatln(builder); } //JAVA TO C# CONVERTER WARNING: The .NET Type.FullName property will not always yield results identical to the Java Class.getCanonicalName method: Formatln(builder, "import %s;", typeof(Visitable).FullName); //JAVA TO C# CONVERTER WARNING: The .NET Type.FullName property will not always yield results identical to the Java Class.getCanonicalName method: Formatln(builder, "import %s;", _interfaceClass.FullName); Formatln(builder); foreach (string importExpr in _argumentFormatter.imports()) { Formatln(builder, "import %s;", importExpr); } Formatln(builder); Formatln(builder, "//"); Formatln(builder, "// GENERATED FILE. DO NOT EDIT."); Formatln(builder, "//"); Formatln(builder, "// This has been generated by:"); Formatln(builder, "//"); if (_generatorInfo.Length > 0) { Formatln(builder, "// %s", _generatorInfo); Formatln(builder, "//"); //JAVA TO C# CONVERTER WARNING: The .NET Type.FullName property will not always yield results identical to the Java Class.getCanonicalName method: Formatln(builder, "// (using %s)", this.GetType().FullName); Formatln(builder, "//"); } else { //JAVA TO C# CONVERTER WARNING: The .NET Type.FullName property will not always yield results identical to the Java Class.getCanonicalName method: Formatln(builder, "// %s", this.GetType().FullName); Formatln(builder, "//"); } Formatln(builder); Formatln(builder, "public enum %s", _generatedClassName); Formatln(builder, "implements %s<%s>", typeof(Visitable).Name, interfaceClassName); Formatln(builder, "{"); Formatln(builder, " INSTANCE;"); Formatln(builder); Formatln(builder, " public void accept( %s visitor )", interfaceClassName); Formatln(builder, " {"); }
public static void Escape(Appendable output, string arg) { int len = arg.Length; for (int i = 0; i < len; i++) { char ch = arg[i]; switch (ch) { case '"': output.append("\\\""); break; case '\'': output.append("\\\'"); break; case '\\': output.append("\\\\"); break; case '\n': output.append("\\n"); break; case '\t': output.append("\\t"); break; case '\r': output.append("\\r"); break; case '\b': output.append("\\b"); break; case '\f': output.append("\\f"); break; default: output.append(ch); break; } } }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: public InvocationTracer(String generatorInfo, String generatedClassPackage, String generatedClassName, Class<C> interfaceClass, ArgumentFormatter argumentFormatter, Appendable output) throws java.io.IOException public InvocationTracer(string generatorInfo, string generatedClassPackage, string generatedClassName, Type interfaceClass, ArgumentFormatter argumentFormatter, Appendable output) { interfaceClass = typeof(C); this._generatorInfo = generatorInfo; if (generatedClassName.Contains(".") || generatedClassName.Contains("%")) { throw new System.ArgumentException("Invalid class name: " + generatedClassName); } if (generatedClassPackage.Contains("%")) { throw new System.ArgumentException("Invalid class package: " + generatedClassPackage); } this._generatedClassPackage = generatedClassPackage; this._generatedClassName = generatedClassName; this._interfaceClass = interfaceClass; this._argumentFormatter = argumentFormatter; this._output = output; FormatPreamble(output); }
public override void AppendString(Appendable appendable, string start, string separator, string end) { throw new System.NotSupportedException("not implemented"); }
//------------------------------------------------------------------------- /// <summary> /// Creates an instance, using the system default line separator and using a comma separator. /// <para> /// See the standard quoting rules in the class-level documentation. /// /// </para> /// </summary> /// <param name="underlying"> the destination to write to </param> /// <returns> the CSV outputter </returns> public static CsvOutput standard(Appendable underlying) { return(new CsvOutput(underlying, NEW_LINE, COMMA, false)); }
public StringDescription(Appendable @out) { StringDescription stringDescription = this; this.@out = @out; }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: private static void formatln(Appendable output) throws java.io.IOException private static void Formatln(Appendable output) { output.append(Environment.NewLine); }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: private static void format(Appendable output, String format, Object... args) throws java.io.IOException private static void Format(Appendable output, string format, params object[] args) { output.append(string.format(format, args)); }
/// <summary> /// Creates an instance, allowing the new line character to be controlled, specifying the separator. /// <para> /// This applies the standard quoting rules from the class-level documentation, plus an additional rule. /// If an entry starts with an expression character, '=', '@', '+' or '-', the entry /// will be quoted and the quote section will be preceeded by equals. /// Thus, the string '=Foo' will be written as '="=Foo"'. /// This avoids the string being treated as an expression by tools like Excel. /// Simple numbers are not quoted. /// Thus, the number '-1234' will still be written as '-1234'. /// /// </para> /// </summary> /// <param name="underlying"> the destination to write to </param> /// <param name="newLine"> the new line string </param> /// <param name="separator"> the separator used to separate each field, typically a comma, but a tab is sometimes used </param> /// <returns> the CSV outputter </returns> public static CsvOutput safe(Appendable underlying, string newLine, string separator) { return(new CsvOutput(underlying, newLine, separator, true)); }
/// <summary> /// Creates an instance, allowing the new line character to be controlled and using a comma separator. /// <para> /// See the standard quoting rules in the class-level documentation. /// /// </para> /// </summary> /// <param name="underlying"> the destination to write to </param> /// <param name="newLine"> the new line string </param> /// <returns> the CSV outputter </returns> public static CsvOutput standard(Appendable underlying, string newLine) { return(new CsvOutput(underlying, newLine, COMMA, false)); }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: private void traceDb(String generator, String generatedClazzPackage, String generatedClazzName, org.neo4j.graphdb.GraphDatabaseService graph, Appendable output) throws java.io.IOException private void TraceDb(string generator, string generatedClazzPackage, string generatedClazzName, GraphDatabaseService graph, Appendable output) { InvocationTracer <DbStructureVisitor> tracer = new InvocationTracer <DbStructureVisitor>(generator, generatedClazzPackage, generatedClazzName, typeof(DbStructureVisitor), DbStructureArgumentFormatter.INSTANCE, output); DbStructureVisitor visitor = tracer.NewProxy(); GraphDbStructureGuide guide = new GraphDbStructureGuide(graph); guide.Accept(visitor); tracer.Close(); }
//------------------------------------------------------------------------- /// <summary> /// Creates an instance, using the system default line separator and using a comma separator. /// <para> /// This applies the standard quoting rules from the class-level documentation, plus an additional rule. /// If an entry starts with an expression character, '=', '@', '+' or '-', the entry /// will be quoted and the quote section will be preceeded by equals. /// Thus, the string '=Foo' will be written as '="=Foo"'. /// This avoids the string being treated as an expression by tools like Excel. /// Simple numbers are not quoted. /// Thus, the number '-1234' will still be written as '-1234'. /// /// </para> /// </summary> /// <param name="underlying"> the destination to write to </param> /// <returns> the CSV outputter </returns> public static CsvOutput safe(Appendable underlying) { return(new CsvOutput(underlying, NEW_LINE, COMMA, true)); }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: private static void formatln(Appendable output, String format, Object... args) throws java.io.IOException private static void Formatln(Appendable output, string format, params object[] args) { format(output, format, args); Formatln(output); }
/// <summary> /// Creates an instance, allowing the new line character to be controlled, specifying the separator. /// <para> /// See the standard quoting rules in the class-level documentation. /// /// </para> /// </summary> /// <param name="underlying"> the destination to write to </param> /// <param name="newLine"> the new line string </param> /// <param name="separator"> the separator used to separate each field, typically a comma, but a tab is sometimes used </param> /// <returns> the CSV outputter </returns> public static CsvOutput standard(Appendable underlying, string newLine, string separator) { return(new CsvOutput(underlying, newLine, separator, false)); }
/// <summary> /// Creates an instance, allowing the new line character to be controlled and using a comma separator. /// <para> /// This applies the standard quoting rules from the class-level documentation, plus an additional rule. /// If an entry starts with an expression character, '=', '@', '+' or '-', the entry /// will be quoted and the quote section will be preceeded by equals. /// Thus, the string '=Foo' will be written as '="=Foo"'. /// This avoids the string being treated as an expression by tools like Excel. /// Simple numbers are not quoted. /// Thus, the number '-1234' will still be written as '-1234'. /// /// </para> /// </summary> /// <param name="underlying"> the destination to write to </param> /// <param name="newLine"> the new line string </param> /// <returns> the CSV outputter </returns> public static CsvOutput safe(Appendable underlying, string newLine) { return(new CsvOutput(underlying, newLine, COMMA, true)); }