@Override public int hashCode() { // This is a work-around because JSONObject doesn't override hashCode(). // it will be quite expensive, but should suffice. return getRawJSON().toString().hashCode(); } }
@Override public boolean equals(final Object obj) { if (this == obj) { return true; } if (obj == null) { return false; } if (!(obj instanceof MetaDataResult)) { return false; } final MetaDataResult other = (MetaDataResult) obj; // This is a work-around because JSONObject doesn't override equals(). // it will be quite expensive, but should suffice. return getRawJSON().toString().equals(other.getRawJSON().toString()); }
/** * Pretty print a MetaDataResult as an indented piece of JSON code. Throws a QuandlRuntimeException if it can't render the nested * JSONObject to a String. * * @param metaDataResult the metaDataResult, not null * @return a String representation of the object, probably multi-line. */ public static String toPrettyPrintedString(final MetaDataResult metaDataResult) { return toPrettyPrintedString(metaDataResult.getRawJSON()); }
/** * Load file using internal counter to generate file name and compare contents to the result provided. * @param metaDataResult the result to check file contents against */ public final void processResult(final MetaDataResult metaDataResult) { processResult(metaDataResult.getRawJSON()); }
/** * Load file using internal counter to generate file name and compare contents to the result provided. * @param metaDataResult the result to check file contents against */ public final void processResult(final MetaDataResult metaDataResult) { processResult(metaDataResult.getRawJSON()); }
/** * Save a MetaDataResult into a file in pretty printed format. * @param metaDataResult the metaDataResult object to save */ public final void processResult(final MetaDataResult metaDataResult) { ArgumentChecker.notNull(metaDataResult, "metaDataResult"); processResult(metaDataResult.getRawJSON()); }
/** * Save a MetaDataResult into a file in pretty printed format. * @param metaDataResult the metaDataResult object to save */ public final void processResult(final MetaDataResult metaDataResult) { ArgumentChecker.notNull(metaDataResult, "metaDataResult"); processResult(metaDataResult.getRawJSON()); }
/** * The main body of the code. */ private void run() { ClassicQuandlSession quandl = ClassicQuandlSession.create(); SearchResult searchResult = quandl.search(SearchRequest.Builder.ofQuery("Apple").withMaxPerPage(2).build()); System.out.println(searchResult.toPrettyPrintedString()); for (MetaDataResult metaData : searchResult.getMetaDataResultList()) { System.out.println(PrettyPrinter.toPrettyPrintedString(metaData.getRawJSON())); } TabularResult tabularResult = null; tabularResult = quandl.getDataSet(DataSetRequest.Builder.of("WIKI/AAPL").withFrequency(Frequency.QUARTERLY) .withColumn(CLOSE_COLUMN).withTransform(Transform.NORMALIZE).build()); System.out.println(PrettyPrinter.toPrettyPrintedString(tabularResult)); MetaDataResult metaData = quandl.getMetaData(MetaDataRequest.of("WIKI/AAPL")); System.out.println(PrettyPrinter.toPrettyPrintedString(metaData.getRawJSON())); }
/** * The main body of the code. */ private void run() { QuandlSession quandl = QuandlSession.create(); SearchResult searchResult = quandl.search(SearchRequest.Builder.ofQuery("Apple").withMaxPerPage(2).build()); System.out.println(searchResult.toPrettyPrintedString()); for (MetaDataResult metaData : searchResult.getMetaDataResultList()) { System.out.println(PrettyPrinter.toPrettyPrintedString(metaData.getRawJSON())); } TabularResult tabularResult = null; tabularResult = quandl.getDataSet(DataSetRequest.Builder.of("WIKI/AAPL").withFrequency(Frequency.QUARTERLY) .withColumn(CLOSE_COLUMN).withTransform(Transform.NORMALIZE).build()); System.out.println(PrettyPrinter.toPrettyPrintedString(tabularResult)); TabularResult tabularResultMulti = quandl.getDataSets( MultiDataSetRequest.Builder.of( QuandlCodeRequest.allColumns("WIKI/AAPL"), QuandlCodeRequest.allColumns("DOE/RWTC") ).withStartDate(RECENTISH_DATE) .build()); System.out.println(PrettyPrinter.toPrettyPrintedString(tabularResultMulti)); MetaDataResult metaData = quandl.getMetaData(MetaDataRequest.of("WIKI/AAPL")); System.out.println(PrettyPrinter.toPrettyPrintedString(metaData.getRawJSON())); MetaDataResult metaData2 = quandl.getMetaData(MultiMetaDataRequest.of("WIKI/AAPL", "DOE/RWTC", "WIKI/MSFT")); System.out.println(PrettyPrinter.toPrettyPrintedString(metaData2.getRawJSON())); }