Skip to content

Instantly share code, notes, and snippets.

@pitometsyurii
Last active August 16, 2019 16:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pitometsyurii/be3f257555e32a057b9e76dde270ba07 to your computer and use it in GitHub Desktop.
Save pitometsyurii/be3f257555e32a057b9e76dde270ba07 to your computer and use it in GitHub Desktop.
Object to XML
public class ReportDefintionBase {
public static final String T = "t";
public static final String F = "f";
public final String toXMLString() {
StringWriter stringWriter = new StringWriter();
Marshaller marshaller = null;
try {
marshaller = JAXBContext.newInstance(this.getClass()).createMarshaller();
marshaller.setProperty(Marshaller.JAXB_FRAGMENT, Boolean.TRUE);
marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE);
marshaller.marshal(this, stringWriter);
return stringWriter.toString();
} catch (JAXBException e) {
e.printStackTrace();
}
return "";
}
}
@XmlRootElement(name = "forward_cash")
@XmlAccessorType(XmlAccessType.NONE)
@SuppressFBWarnings
public class ForwardCashReportDefinition extends ReportDefintionBase {
@XmlElement
public JustOrNothing from_date = JustOrNothing.nothing();
@XmlElement
public JustOrNothing to_date = JustOrNothing.nothing();
@XmlElement
public JustOrNothing storage_scheduling_refdate = JustOrNothing.nothing();
@XmlElement
public String filter_expr = "";
@XmlElement
public String cash_settle_futures = T;
@XmlElement
public String include_contingent_flows = T;
@XmlElement
public String include_location_info = T;
@XmlElement
public String include_zero_amounts = T;
@XmlElement
public String net_bond_positions = T;
@XmlElement
public String cash_settle_options = T;
@XmlElement
public String options_settle_at_maturity = T;
@XmlElement
public String include_repo_eom_fees = T;
@XmlElement
public String cash_settle_options_at_strike = T;
@XmlElement
public String cash_settle_options_in_the_money = T;
@XmlElement
public String apply_rounding = T;
}
public class Main {
public static void main(String[] args) {
Random random = new Random();
for (int i = 0 ; i < 9000 ; i++) {
int i1 = random.nextInt(10);
int i2 = random.nextInt(10);
int i3 = random.nextInt(10);
int i4 = random.nextInt(10);
int i5 = random.nextInt(10);
int i6 = random.nextInt(10);
int i7 = random.nextInt(10);
int i8 = random.nextInt(10);
int i9 = random.nextInt(10);
int i10 = random.nextInt(10);
int i11 = random.nextInt(10);
int i12 = random.nextInt(10);
String low = "" + i1 + i2 + i3 + i4 + i5 + i6 + i7 + i8 + i9 + i10 + i11 + i12 + "0000";
String high = "" + i1 + i2 + i3 + i4 + i5 + i6 + i7 + i8 + i9 + i10 + i11 + i12 + "9999";
System.out.println(String.format("<record> <LO_RANGE>%s</LO_RANGE> <HI_RANGE>%s</HI_RANGE> </record>", low, high));
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment