Package io.jenetics.xml
Class Writers.PermutationChromosome
- java.lang.Object
-
- io.jenetics.xml.Writers.PermutationChromosome
-
- Enclosing class:
- Writers
public static final class Writers.PermutationChromosome extends Object
This class contains static writer methods forPermutationChromosome
objects.Writer code
XML outputfinal PermutationChromosome<Integer> value = PermutationChromosome.ofInteger(5) final Writer<PermutationChromosome<Integer> writer = Writers.PermutationChromosome.writer(); try (AutoCloseableXMLStreamWriter xml = XML.writer(System.out, " ")) { Writers.PermutationChromosome.writer().write(value, xml); }
<permutation-chromosome length="5"> <valid-alleles type="java.lang.Integer"> <allele>0</allele> <allele>1</allele> <allele>2</allele> <allele>3</allele> <allele>4</allele> </valid-alleles> <order>2 1 3 5 4</order> </permutation-chromosome>
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static <A> void
write(OutputStream out, PermutationChromosome<A> data)
Write the givenPermutationChromosome
to the given output stream.static <A> void
write(OutputStream out, PermutationChromosome<A> data, Writer<? super A> alleleWriter)
Write the givenPermutationChromosome
to the given output stream.static <A> void
write(OutputStream out, PermutationChromosome<A> data, String indent)
Write the givenPermutationChromosome
to the given output stream.static <A> void
write(OutputStream out, PermutationChromosome<A> data, String indent, Writer<? super A> alleleWriter)
Write the givenPermutationChromosome
to the given output stream.static <A> Writer<PermutationChromosome<A>>
writer()
Create a writer for permutation-chromosomes.static <A> Writer<PermutationChromosome<A>>
writer(Writer<? super A> alleleWriter)
Create a writer for permutation-chromosomes.
-
-
-
Method Detail
-
writer
public static <A> Writer<PermutationChromosome<A>> writer(Writer<? super A> alleleWriter)
Create a writer for permutation-chromosomes. How to write the valid alleles is defined by the givenWriter
.- Type Parameters:
A
- the allele type- Parameters:
alleleWriter
- the allele writer- Returns:
- a new permutation chromosome writer
- Throws:
NullPointerException
- if the given allelewriter
isnull
-
writer
public static <A> Writer<PermutationChromosome<A>> writer()
Create a writer for permutation-chromosomes. The valid alleles are serialized by calling theObject.toString()
method. Calling this method is equivalent with:Example output:final Writer<PermutationChromosome<Double> writer = PermutationChromosome.write(text().map(Objects::toString));
<permutation-chromosome length="15"> <valid-alleles type="java.lang.Double"> <allele>0.27251556008507416</allele> <allele>0.003140816229067145</allele> <allele>0.43947528327497376</allele> <allele>0.10654807463069327</allele> <allele>0.19696530915810317</allele> <allele>0.7450003838065538</allele> <allele>0.5594416969271359</allele> <allele>0.02823782430152355</allele> <allele>0.5741102315010789</allele> <allele>0.4533651041367144</allele> <allele>0.811148141800367</allele> <allele>0.5710456351848858</allele> <allele>0.30166768355230955</allele> <allele>0.5455492865240272</allele> <allele>0.21068427527733102</allele> </valid-alleles> <order>13 12 4 6 8 14 7 2 11 5 3 0 9 10 1</order> </permutation-chromosome>
- Type Parameters:
A
- the allele type- Returns:
- a new permutation chromosome writer
-
write
public static <A> void write(OutputStream out, PermutationChromosome<A> data, String indent) throws XMLStreamException
Write the givenPermutationChromosome
to the given output stream.- Type Parameters:
A
- the allele type- Parameters:
out
- the target output streamdata
- the chromosome to writeindent
- the XML level indentation- Throws:
XMLStreamException
- if an error occurs while writing the chromosomeNullPointerException
- if thechromosome
or output stream isnull
-
write
public static <A> void write(OutputStream out, PermutationChromosome<A> data, String indent, Writer<? super A> alleleWriter) throws XMLStreamException
Write the givenPermutationChromosome
to the given output stream.- Type Parameters:
A
- the allele type- Parameters:
out
- the target output streamdata
- the chromosome to writeindent
- the XML level indentationalleleWriter
- the allele writer of the permutation chromosome- Throws:
XMLStreamException
- if an error occurs while writing the chromosomeNullPointerException
- if thechromosome
or output stream isnull
-
write
public static <A> void write(OutputStream out, PermutationChromosome<A> data) throws XMLStreamException
Write the givenPermutationChromosome
to the given output stream.- Type Parameters:
A
- the allele type- Parameters:
out
- the target output streamdata
- the chromosome to write- Throws:
XMLStreamException
- if an error occurs while writing the chromosomeNullPointerException
- if thechromosome
or output stream isnull
-
write
public static <A> void write(OutputStream out, PermutationChromosome<A> data, Writer<? super A> alleleWriter) throws XMLStreamException
Write the givenPermutationChromosome
to the given output stream.- Type Parameters:
A
- the allele type- Parameters:
out
- the target output streamdata
- the chromosome to writealleleWriter
- the allele writer used to write the chromosome alleles- Throws:
XMLStreamException
- if an error occurs while writing the chromosomeNullPointerException
- if thechromosome
or output stream isnull
-
-