diff --git a/pom.xml b/pom.xml index 8275858..f9b2e7b 100644 --- a/pom.xml +++ b/pom.xml @@ -3,11 +3,11 @@ org.fross quoter - 5.0.20 + 5.0.21 jar quoter - Simple console based program to display stock quotes and index data + A simple console based program to display stock quotes, US core index data, and historical trending https://fross.org diff --git a/snap/snapcraft.yaml b/snap/snapcraft.yaml index d41f242..ac3f1c4 100644 --- a/snap/snapcraft.yaml +++ b/snap/snapcraft.yaml @@ -1,5 +1,5 @@ name: quoter -version: '5.0.20' +version: '5.0.21' summary: Command line utility to pull stock and index quotes description: | Quoter fetches online stock quotes and index data for easy display on diff --git a/src/main/java/org/fross/quoter/FileExporter.java b/src/main/java/org/fross/quoter/FileExporter.java index 1c963d6..c0ae5c6 100644 --- a/src/main/java/org/fross/quoter/FileExporter.java +++ b/src/main/java/org/fross/quoter/FileExporter.java @@ -58,7 +58,7 @@ public FileExporter(String fileName) { // Create the FileWriter object for writing to the export file try { - exportFileFW = new FileWriter(this.exportFile); + this.exportFileFW = new FileWriter(this.exportFile); } catch (IOException ex) { Output.printColorln(Ansi.Color.RED, "Error writing to export file '" + fileName + "'\n" + ex.getMessage()); } @@ -71,7 +71,7 @@ public FileExporter(String fileName) { */ public boolean canWrite() { try { - return exportFile.canWrite(); + return this.exportFile.canWrite(); } catch (Exception ex) { return false; } @@ -90,9 +90,9 @@ public boolean exportSecurities(Symbol symbolObj) { if (this.exportSymbolHeaderWritten == false) { for (String i : fields) { if (!i.matches("[Ss]tatus")) - exportFileFW.append(i + ","); + this.exportFileFW.append(i + ","); } - exportFileFW.append("\n"); + this.exportFileFW.append("\n"); this.exportSymbolHeaderWritten = true; } @@ -101,9 +101,9 @@ public boolean exportSecurities(Symbol symbolObj) { // If the data has a ',' in it remove it String item = symbolObj.get(i).replaceAll(",", ""); if (!symbolObj.get(i).matches("[Oo][Kk]")) - exportFileFW.append(item + ","); + this.exportFileFW.append(item + ","); } - exportFileFW.append("\n"); + this.exportFileFW.append("\n"); } catch (IOException ex) { Output.printColorln(Ansi.Color.RED, "Error writing data to the export file: " + ex.getMessage()); @@ -117,22 +117,22 @@ public boolean exportSecurities(Symbol symbolObj) { */ public void exportIndexes(Index indexObj) { try { - exportFileFW.append("\n"); + this.exportFileFW.append("\n"); // Dump the header information to the export file List fields = indexObj.getAllFieldNames(); if (this.exportIndexHeaderWritten == false) { for (String i : fields) { if (!i.matches("[Ss]tatus")) - exportFileFW.append(i + ","); + this.exportFileFW.append(i + ","); } - exportFileFW.append("\n"); + this.exportFileFW.append("\n"); this.exportIndexHeaderWritten = true; } // Dump the index data for (String key : indexObj.getAllFieldNames()) { if (!indexObj.get(key).matches("[Oo][Kk]")) - exportFileFW.append("\"" + indexObj.get(key) + "\"" + ","); + this.exportFileFW.append("\"" + indexObj.get(key) + "\"" + ","); } } catch (IOException ex) { diff --git a/src/main/java/org/fross/quoter/Help.java b/src/main/java/org/fross/quoter/Help.java index 1e276bb..818dc61 100644 --- a/src/main/java/org/fross/quoter/Help.java +++ b/src/main/java/org/fross/quoter/Help.java @@ -41,14 +41,14 @@ public class Help { static final int HEADERWIDTH = 72; /** - * Display(): Prints help in color using the JCDP library in the output module. + * Display(): Prints help in color using the JCDP library in the output module */ public static void Display() { Output.printColorln(Ansi.Color.CYAN, "\n+" + "-".repeat(HEADERWIDTH - 2) + "+"); Output.printColorln(Ansi.Color.CYAN, "+" + Format.CenterText(HEADERWIDTH - 2, "Quoter v" + Main.VERSION) + "+"); Output.printColorln(Ansi.Color.CYAN, "+" + Format.CenterText(HEADERWIDTH - 2, Main.COPYRIGHT) + "+"); Output.printColorln(Ansi.Color.CYAN, "+" + "-".repeat(HEADERWIDTH - 2) + "+"); - Output.printColorln(Ansi.Color.CYAN, Format.CenterText(HEADERWIDTH - 2, "Quoter displays stock quotes & US index data, and more")); + Output.printColorln(Ansi.Color.CYAN, Format.CenterText(HEADERWIDTH - 2, "Quoter displays stock quotes, US index data, and trends")); Output.printColorln(Ansi.Color.CYAN, Format.CenterText(HEADERWIDTH - 2, "Hompage: https://github.com/frossm/quoter") + "\n"); Output.printColorln(Ansi.Color.YELLOW, "Command Line Options"); @@ -72,7 +72,7 @@ public static void Display() { Output.printColorln(Ansi.Color.YELLOW, "\nMisc:"); Output.printColorln(Ansi.Color.WHITE, " -D Start in debug mode and display details for developers"); - Output.printColorln(Ansi.Color.WHITE, " -v Display program version and lastest GitHub release and exit"); + Output.printColorln(Ansi.Color.WHITE, " -v Display program version and the lastest release on GitHub"); Output.printColorln(Ansi.Color.WHITE, " -? | -h Display this help information"); Output.printColorln(Ansi.Color.YELLOW, "\nNotes:"); diff --git a/src/main/java/org/fross/quoter/HistoricalQuotes.java b/src/main/java/org/fross/quoter/HistoricalQuotes.java index 2c79dcd..2a82caa 100644 --- a/src/main/java/org/fross/quoter/HistoricalQuotes.java +++ b/src/main/java/org/fross/quoter/HistoricalQuotes.java @@ -246,8 +246,7 @@ public void displayTrend(String symb) { Output.debugPrintln("Slots per Cost Unit: " + slotsPerCostUnit); // Display the symbol informational header - Output.printColorln(Ansi.Color.WHITE, "\n\n+--" + String.format("%02d", NUM_DAYS_IN_TREND) + " Day Trend" - + "-".repeat(graphWidth - 2) + "+"); + Output.printColorln(Ansi.Color.WHITE, "\n\n+--" + String.format("%02d", NUM_DAYS_IN_TREND) + " Day Trend" + "-".repeat(graphWidth - 2) + "+"); Output.printColorln(Ansi.Color.YELLOW, symb.toUpperCase() + " : " + symbolData.get("fullname")); Output.printColorln(Ansi.Color.YELLOW, "Current Price: " + symbolData.get("latestPrice")); Output.printColorln(Ansi.Color.YELLOW, NUM_DAYS_IN_TREND + " Day Low: " + String.format("%,.2f", sv)); diff --git a/src/main/java/org/fross/quoter/Index.java b/src/main/java/org/fross/quoter/Index.java index 27357c5..4a2de18 100644 --- a/src/main/java/org/fross/quoter/Index.java +++ b/src/main/java/org/fross/quoter/Index.java @@ -63,7 +63,7 @@ public Index(String idx) { public boolean queryMarketOpen() { return marketOpen; } - + /** * queryPageItem():Find the specific value in the provided doc with the xPath given * @@ -169,7 +169,7 @@ private void getIndex(String idx) { this.indexData.put("status", "ok"); // Determine if the market is open or closed - if (Symbol.queryPageItem(htmlPage, xPathLookup.lookupIndexOpen("marketStatus")).toLowerCase().contains("closed") == true) { + if (Symbol.queryPageItem(htmlPage, this.xPathLookup.lookupIndexOpen("marketStatus")).toLowerCase().contains("closed") == true) { marketOpen = false; } else { marketOpen = true; @@ -182,22 +182,22 @@ private void getIndex(String idx) { // Current Price String key = "latestPrice"; - String result = queryPageItem(htmlPage, xPathLookup.lookupIndexClosed(key)); + String result = queryPageItem(htmlPage, this.xPathLookup.lookupIndexClosed(key)); indexData.put(key, result.replaceAll("[,%]", "").trim()); // Change key = "change"; - result = queryPageItem(htmlPage, xPathLookup.lookupIndexClosed(key)); + result = queryPageItem(htmlPage, this.xPathLookup.lookupIndexClosed(key)); indexData.put(key, result.replaceAll("[,%]", "").trim()); // Change Percent key = "changePercent"; - result = queryPageItem(htmlPage, xPathLookup.lookupIndexClosed(key)); + result = queryPageItem(htmlPage, this.xPathLookup.lookupIndexClosed(key)); indexData.put(key, result.replaceAll("[,%]", "").trim()); // 52 Week Range key = "52weekRange"; - result = queryPageItem(htmlPage, xPathLookup.lookupIndexClosed(key)); + result = queryPageItem(htmlPage, this.xPathLookup.lookupIndexClosed(key)); String w52Low = result.split(" - ")[0]; String w52High = result.split(" - ")[1]; @@ -207,17 +207,17 @@ private void getIndex(String idx) { // Year to Date Change Percent key = "ytdChangePercent"; - result = queryPageItem(htmlPage, xPathLookup.lookupIndexClosed(key)); + result = queryPageItem(htmlPage, this.xPathLookup.lookupIndexClosed(key)); indexData.put(key, result.replaceAll("[,%]", "").trim()); // One Year Change Percent key = "oneYearChangePercent"; - result = queryPageItem(htmlPage, xPathLookup.lookupIndexClosed(key)); + result = queryPageItem(htmlPage, this.xPathLookup.lookupIndexClosed(key)); indexData.put(key, result.replaceAll("[,%]", "").trim()); // TimeStamp key = "timeStamp"; - result = queryPageItem(htmlPage, xPathLookup.lookupIndexClosed(key)); + result = queryPageItem(htmlPage, this.xPathLookup.lookupIndexClosed(key)); indexData.put(key, result.replaceAll("[,%]", "").trim()); } else { @@ -226,22 +226,22 @@ private void getIndex(String idx) { // Current Price String key = "latestPrice"; - String result = queryPageItem(htmlPage, xPathLookup.lookupIndexOpen(key)); + String result = queryPageItem(htmlPage, this.xPathLookup.lookupIndexOpen(key)); indexData.put(key, result.replaceAll("[,%]", "").trim()); // Change key = "change"; - result = queryPageItem(htmlPage, xPathLookup.lookupIndexOpen(key)); + result = queryPageItem(htmlPage, this.xPathLookup.lookupIndexOpen(key)); indexData.put("change", result.replaceAll("[,%]", "").trim()); // Change Percent key = "changePercent"; - result = queryPageItem(htmlPage, xPathLookup.lookupIndexOpen(key)); + result = queryPageItem(htmlPage, this.xPathLookup.lookupIndexOpen(key)); indexData.put(key, result.replaceAll("[,%]", "").trim()); // 52 Week Range key = "52weekRange"; - result = queryPageItem(htmlPage, xPathLookup.lookupIndexOpen(key)); + result = queryPageItem(htmlPage, this.xPathLookup.lookupIndexOpen(key)); String w52Low = result.split(" - ")[0]; String w52High = result.split(" - ")[1]; @@ -251,17 +251,17 @@ private void getIndex(String idx) { // Year to Date key = "ytdChangePercent"; - result = queryPageItem(htmlPage, xPathLookup.lookupIndexOpen(key)); + result = queryPageItem(htmlPage, this.xPathLookup.lookupIndexOpen(key)); indexData.put(key, result.replaceAll("[,%]", "").trim()); // One Year Change Percent key = "oneYearChangePercent"; - result = queryPageItem(htmlPage, xPathLookup.lookupIndexOpen(key)); + result = queryPageItem(htmlPage, this.xPathLookup.lookupIndexOpen(key)); indexData.put(key, result.replaceAll("[,%]", "").trim()); // TimeStamp key = "timeStamp"; - result = queryPageItem(htmlPage, xPathLookup.lookupIndexOpen(key)); + result = queryPageItem(htmlPage, this.xPathLookup.lookupIndexOpen(key)); indexData.put(key, result.replaceAll("[,%]", "").trim()); } diff --git a/src/main/java/org/fross/quoter/Main.java b/src/main/java/org/fross/quoter/Main.java index f3c6578..c1db75d 100644 --- a/src/main/java/org/fross/quoter/Main.java +++ b/src/main/java/org/fross/quoter/Main.java @@ -24,7 +24,6 @@ * SOFTWARE. * ***************************************************************************************************************/ - package org.fross.quoter; import static org.fusesource.jansi.Ansi.ansi; diff --git a/src/main/java/org/fross/quoter/QuoteConsoleOutput.java b/src/main/java/org/fross/quoter/QuoteConsoleOutput.java index 09d6d78..44da66b 100644 --- a/src/main/java/org/fross/quoter/QuoteConsoleOutput.java +++ b/src/main/java/org/fross/quoter/QuoteConsoleOutput.java @@ -1,3 +1,29 @@ +/************************************************************************************************************** + * Quoter.jar + * + * Quoter is a command line program that display stock quotes and index data. + * + * Copyright (c) 2019-2022 Michael Fross + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + ***************************************************************************************************************/ package org.fross.quoter; import java.time.LocalDateTime; @@ -238,11 +264,11 @@ public void displayOutput(FileExporter exporter) { } // Display the open/closed status of the market - Output.printColor(Ansi.Color.CYAN, "\nThe US markets are currently: "); + Output.printColor(Ansi.Color.WHITE, "\nThe US markets are currently: "); if (new Index("DOW").queryMarketOpen() == true) { - Output.printColorln(Ansi.Color.YELLOW, "~ OPEN ~"); + Output.printColorln(Ansi.Color.YELLOW, "-= OPEN =-"); } else { - Output.printColorln(Ansi.Color.YELLOW, "~ CLOSED ~"); + Output.printColorln(Ansi.Color.YELLOW, "-= CLOSED =-"); } // Convert to local time & time zone @@ -281,7 +307,7 @@ public void displayOutput(FileExporter exporter) { timeStamp = timeStamp.replaceAll("AM", "am"); // Display the time stamp - Output.printColorln(Ansi.Color.CYAN, "Data as of " + timeStamp + ". Quotes are delayed."); + Output.printColorln(Ansi.Color.WHITE, "Data as of " + timeStamp + ". Quotes are delayed."); // Display trending data if -t was provided and there is at least one valid symbol if (cli.clTrend == true) { diff --git a/src/main/java/org/fross/quoter/Symbol.java b/src/main/java/org/fross/quoter/Symbol.java index fc79685..5375e8b 100644 --- a/src/main/java/org/fross/quoter/Symbol.java +++ b/src/main/java/org/fross/quoter/Symbol.java @@ -89,7 +89,7 @@ protected String get(String field) { */ protected boolean put(String field, String value) { try { - symbolData.put(field, value); + this.symbolData.put(field, value); } catch (Exception ex) { return false; } @@ -134,7 +134,7 @@ private void getSymbolData(String symb) { this.symbolData.put("status", "ok"); // Determine if the market is open or closed - if (Symbol.queryPageItem(htmlPage, xPathLookup.lookupIndexOpen("marketStatus")).toLowerCase().contains("open") == true) { + if (Symbol.queryPageItem(htmlPage, this.xPathLookup.lookupIndexOpen("marketStatus")).toLowerCase().contains("open") == true) { marketOpen = true; } else { marketOpen = false; @@ -147,22 +147,22 @@ private void getSymbolData(String symb) { // Current Price String key = "latestPrice"; - String result = queryPageItem(htmlPage, xPathLookup.lookupSymbolClosed(key)); - symbolData.put(key, result.replaceAll("[$,%]", "").trim()); + String result = queryPageItem(htmlPage, this.xPathLookup.lookupSymbolClosed(key)); + this.symbolData.put(key, result.replaceAll("[$,%]", "").trim()); // Change key = "change"; - result = queryPageItem(htmlPage, xPathLookup.lookupSymbolClosed(key)); - symbolData.put(key, result.replaceAll("[$,%]", "").trim()); + result = queryPageItem(htmlPage, this.xPathLookup.lookupSymbolClosed(key)); + this.symbolData.put(key, result.replaceAll("[$,%]", "").trim()); // Change Percent key = "changePercent"; - result = queryPageItem(htmlPage, xPathLookup.lookupSymbolClosed(key)); - symbolData.put(key, result.replaceAll("[,%]", "").trim()); + result = queryPageItem(htmlPage, this.xPathLookup.lookupSymbolClosed(key)); + this.symbolData.put(key, result.replaceAll("[,%]", "").trim()); // 52 Week High / Low - Get range and split into high/low key = "52weekRange"; - result = queryPageItem(htmlPage, xPathLookup.lookupSymbolClosed(key)); + result = queryPageItem(htmlPage, this.xPathLookup.lookupSymbolClosed(key)); String low52 = ""; String high52 = ""; @@ -173,12 +173,12 @@ private void getSymbolData(String symb) { low52 = high52 = "-"; } - symbolData.put("week52High", high52.replaceAll("[,%]", "").trim()); - symbolData.put("week52Low", low52.replaceAll("[,%]", "").trim()); + this.symbolData.put("week52High", high52.replaceAll("[,%]", "").trim()); + this.symbolData.put("week52Low", low52.replaceAll("[,%]", "").trim()); // Day Range - Get range and split into high/low key = "dayRange"; - result = queryPageItem(htmlPage, xPathLookup.lookupSymbolClosed(key)); + result = queryPageItem(htmlPage, this.xPathLookup.lookupSymbolClosed(key)); String lowD = ""; String highD = ""; @@ -189,8 +189,8 @@ private void getSymbolData(String symb) { lowD = highD = "-"; } - symbolData.put("dayHigh", highD.replaceAll("[,%]", "").trim()); - symbolData.put("dayLow", lowD.replaceAll("[,%]", "").trim()); + this.symbolData.put("dayHigh", highD.replaceAll("[,%]", "").trim()); + this.symbolData.put("dayLow", lowD.replaceAll("[,%]", "").trim()); // Year to Date Change key = "ytdChangePercent"; @@ -202,13 +202,13 @@ private void getSymbolData(String symb) { // TimeStamp key = "timeStamp"; - result = queryPageItem(htmlPage, xPathLookup.lookupSymbolClosed(key)); - symbolData.put(key, result.replaceAll("[,%]", "").trim()); + result = queryPageItem(htmlPage, this.xPathLookup.lookupSymbolClosed(key)); + this.symbolData.put(key, result.replaceAll("[,%]", "").trim()); // Full Name of Company key = "fullname"; - result = queryPageItem(htmlPage, xPathLookup.lookupSymbolClosed(key)); - symbolData.put(key, result.trim()); + result = queryPageItem(htmlPage, this.xPathLookup.lookupSymbolClosed(key)); + this.symbolData.put(key, result.trim()); } else { // Market is OPEN @@ -216,22 +216,22 @@ private void getSymbolData(String symb) { // Current Price String key = "latestPrice"; - String result = queryPageItem(htmlPage, xPathLookup.lookupSymbolOpen(key)); - symbolData.put(key, result.replaceAll("[,%]", "").trim()); + String result = queryPageItem(htmlPage, this.xPathLookup.lookupSymbolOpen(key)); + this.symbolData.put(key, result.replaceAll("[,%]", "").trim()); // Change key = "change"; - result = queryPageItem(htmlPage, xPathLookup.lookupSymbolOpen(key)); - symbolData.put(key, result.replaceAll("[,%]", "").trim()); + result = queryPageItem(htmlPage, this.xPathLookup.lookupSymbolOpen(key)); + this.symbolData.put(key, result.replaceAll("[,%]", "").trim()); // Change Percent key = "changePercent"; - result = queryPageItem(htmlPage, xPathLookup.lookupSymbolOpen(key)); - symbolData.put(key, result.replaceAll("[,%]", "").trim()); + result = queryPageItem(htmlPage, this.xPathLookup.lookupSymbolOpen(key)); + this.symbolData.put(key, result.replaceAll("[,%]", "").trim()); // 52 Week High / Low - Get range and split into high/low key = "52weekRange"; - result = queryPageItem(htmlPage, xPathLookup.lookupSymbolOpen(key)); + result = queryPageItem(htmlPage, this.xPathLookup.lookupSymbolOpen(key)); String low52 = ""; String high52 = ""; @@ -242,12 +242,12 @@ private void getSymbolData(String symb) { low52 = high52 = "-"; } - symbolData.put("week52High", high52.replaceAll("[,%]", "").trim()); - symbolData.put("week52Low", low52.replaceAll("[,%]", "").trim()); + this.symbolData.put("week52High", high52.replaceAll("[,%]", "").trim()); + this.symbolData.put("week52Low", low52.replaceAll("[,%]", "").trim()); // Day Range - Get range and split into high/low key = "dayRange"; - result = queryPageItem(htmlPage, xPathLookup.lookupSymbolOpen(key)); + result = queryPageItem(htmlPage, this.xPathLookup.lookupSymbolOpen(key)); String lowD = ""; String highD = ""; @@ -258,8 +258,8 @@ private void getSymbolData(String symb) { lowD = highD = "-"; } - symbolData.put("dayHigh", highD.replaceAll("[,%]", "").trim()); - symbolData.put("dayLow", lowD.replaceAll("[,%]", "").trim()); + this.symbolData.put("dayHigh", highD.replaceAll("[,%]", "").trim()); + this.symbolData.put("dayLow", lowD.replaceAll("[,%]", "").trim()); // Year to Date Change key = "ytdChangePercent"; @@ -271,19 +271,19 @@ private void getSymbolData(String symb) { // TimeStamp key = "timeStamp"; - result = queryPageItem(htmlPage, xPathLookup.lookupSymbolOpen(key)); - symbolData.put(key, result.replaceAll("[,%]", "").trim()); + result = queryPageItem(htmlPage, this.xPathLookup.lookupSymbolOpen(key)); + this.symbolData.put(key, result.replaceAll("[,%]", "").trim()); // Full Name of Company key = "fullname"; - result = queryPageItem(htmlPage, xPathLookup.lookupSymbolOpen(key)); - symbolData.put(key, result.trim()); + result = queryPageItem(htmlPage, this.xPathLookup.lookupSymbolOpen(key)); + this.symbolData.put(key, result.trim()); } // If we are in debug mode, display the values of the symbol if (Debug.query() == true) { Output.debugPrintln("Symbol Data Results:"); - for (String i : symbolData.keySet()) { + for (String i : this.symbolData.keySet()) { Output.debugPrintln(" - " + i + ": " + this.get(i)); } } @@ -305,7 +305,7 @@ private void getSymbolData(String symb) { private void setOptionalField(final Document htmlPage, final String key, final MarketStatus marketStatus) { try { final String result = queryPageItem(htmlPage, - marketStatus == MarketStatus.Closed ? xPathLookup.lookupSymbolClosed(key) : xPathLookup.lookupSymbolOpen(key)); + marketStatus == MarketStatus.Closed ? this.xPathLookup.lookupSymbolClosed(key) : this.xPathLookup.lookupSymbolOpen(key)); symbolData.put(key, result.replaceAll("[,%]", "").trim()); } catch (Exception e) { diff --git a/src/main/java/org/fross/quoter/XPathLookup.java b/src/main/java/org/fross/quoter/XPathLookup.java index 731d146..d0bbd71 100644 --- a/src/main/java/org/fross/quoter/XPathLookup.java +++ b/src/main/java/org/fross/quoter/XPathLookup.java @@ -41,52 +41,52 @@ public XPathLookup() { // --------------------------------------------------------------------------------- // xPaths: Symbols with market CLOSED // --------------------------------------------------------------------------------- - symbolClosed.put("latestPrice", "/html/body/div[3]/div[2]/div[3]/div/div[4]/table/tbody/tr/td[1]"); - symbolClosed.put("change", "/html/body/div[3]/div[2]/div[3]/div/div[4]/table/tbody/tr/td[2]"); - symbolClosed.put("changePercent", "/html/body/div[3]/div[2]/div[3]/div/div[4]/table/tbody/tr/td[3]"); - symbolClosed.put("52weekRange", "/html/body/div[3]/div[6]/div[1]/div[1]/div/ul/li[3]/span[1]"); - symbolClosed.put("dayRange", "/html/body/div[3]/div[6]/div[1]/div[1]/div/ul/li[2]/span[1]"); - symbolClosed.put("ytdChangePercent", "/html/body/div[3]/div[6]/div[1]/div[2]/div[1]/table/tbody/tr[4]/td[2]/ul/li[1]"); - symbolClosed.put("oneYearChangePercent", "/html/body/div[3]/div[6]/div[1]/div[2]/div[1]/table/tbody/tr[5]/td[2]/ul/li[1]"); - symbolClosed.put("timeStamp", "/html/body/div[3]/div[2]/div[3]/div/div[1]/span/bg-quote"); - symbolClosed.put("fullname", "/html/body/div[3]/div[2]/div[2]/div/div[2]/h1"); + this.symbolClosed.put("latestPrice", "/html/body/div[3]/div[2]/div[3]/div/div[4]/table/tbody/tr/td[1]"); + this.symbolClosed.put("change", "/html/body/div[3]/div[2]/div[3]/div/div[4]/table/tbody/tr/td[2]"); + this.symbolClosed.put("changePercent", "/html/body/div[3]/div[2]/div[3]/div/div[4]/table/tbody/tr/td[3]"); + this.symbolClosed.put("52weekRange", "/html/body/div[3]/div[6]/div[1]/div[1]/div/ul/li[3]/span[1]"); + this.symbolClosed.put("dayRange", "/html/body/div[3]/div[6]/div[1]/div[1]/div/ul/li[2]/span[1]"); + this.symbolClosed.put("ytdChangePercent", "/html/body/div[3]/div[6]/div[1]/div[2]/div[1]/table/tbody/tr[4]/td[2]/ul/li[1]"); + this.symbolClosed.put("oneYearChangePercent", "/html/body/div[3]/div[6]/div[1]/div[2]/div[1]/table/tbody/tr[5]/td[2]/ul/li[1]"); + this.symbolClosed.put("timeStamp", "/html/body/div[3]/div[2]/div[3]/div/div[1]/span/bg-quote"); + this.symbolClosed.put("fullname", "/html/body/div[3]/div[2]/div[2]/div/div[2]/h1"); // --------------------------------------------------------------------------------- // xPaths: Symbols with market OPEN // --------------------------------------------------------------------------------- - symbolOpen.put("latestPrice", "/html/body/div[3]/div[2]/div[3]/div/div[2]/h2/bg-quote"); - symbolOpen.put("change", "/html/body/div[3]/div[2]/div[3]/div/div[2]/bg-quote/span[1]/bg-quote"); - symbolOpen.put("changePercent", "/html/body/div[3]/div[2]/div[3]/div/div[2]/bg-quote/span[2]/bg-quote"); - symbolOpen.put("52weekRange", "/html/body/div[3]/div[6]/div[1]/div[1]/div/ul/li[3]/span[1]"); - symbolOpen.put("dayRange", "/html/body/div[3]/div[6]/div[1]/div[1]/div/ul/li[2]/span[1]"); - symbolOpen.put("ytdChangePercent", "/html/body/div[3]/div[6]/div[1]/div[2]/div[1]/table/tbody/tr[4]/td[2]/ul/li[1]"); - symbolOpen.put("oneYearChangePercent", "/html/body/div[3]/div[6]/div[1]/div[2]/div[1]/table/tbody/tr[5]/td[2]/ul/li[1]"); - symbolOpen.put("timeStamp", "/html/body/div[3]/div[2]/div[3]/div/div[1]/span/bg-quote"); - symbolOpen.put("fullname", "/html/body/div[3]/div[2]/div[2]/div/div[2]/h1"); + this.symbolOpen.put("latestPrice", "/html/body/div[3]/div[2]/div[3]/div/div[2]/h2/bg-quote"); + this.symbolOpen.put("change", "/html/body/div[3]/div[2]/div[3]/div/div[2]/bg-quote/span[1]/bg-quote"); + this.symbolOpen.put("changePercent", "/html/body/div[3]/div[2]/div[3]/div/div[2]/bg-quote/span[2]/bg-quote"); + this.symbolOpen.put("52weekRange", "/html/body/div[3]/div[6]/div[1]/div[1]/div/ul/li[3]/span[1]"); + this.symbolOpen.put("dayRange", "/html/body/div[3]/div[6]/div[1]/div[1]/div/ul/li[2]/span[1]"); + this.symbolOpen.put("ytdChangePercent", "/html/body/div[3]/div[6]/div[1]/div[2]/div[1]/table/tbody/tr[4]/td[2]/ul/li[1]"); + this.symbolOpen.put("oneYearChangePercent", "/html/body/div[3]/div[6]/div[1]/div[2]/div[1]/table/tbody/tr[5]/td[2]/ul/li[1]"); + this.symbolOpen.put("timeStamp", "/html/body/div[3]/div[2]/div[3]/div/div[1]/span/bg-quote"); + this.symbolOpen.put("fullname", "/html/body/div[3]/div[2]/div[2]/div/div[2]/h1"); // --------------------------------------------------------------------------------- // xPaths: Indexes with market CLOSED // --------------------------------------------------------------------------------- - indexClosed.put("latestPrice", "/html/body/div[3]/div[2]/div[3]/div/div[2]/h2/span"); - indexClosed.put("change", "/html/body/div[3]/div[2]/div[3]/div/div[2]/bg-quote/span[1]"); - indexClosed.put("changePercent", "/html/body/div[3]/div[2]/div[3]/div/div[2]/bg-quote/span[2]"); - indexClosed.put("52weekRange", "/html/body/div[3]/div[6]/div[1]/div[1]/div/ul/li[3]/span[1]"); - indexClosed.put("ytdChangePercent", "/html/body/div[3]/div[6]/div[1]/div[2]/div[1]/table/tbody/tr[5]/td[2]/ul/li[1]"); - indexClosed.put("oneYearChangePercent", "/html/body/div[3]/div[6]/div[1]/div[2]/div[1]/table/tbody/tr[5]/td[2]/ul/li[1]"); - indexClosed.put("timeStamp", "/html/body/div[3]/div[2]/div[3]/div/div[1]/span/bg-quote"); + this.indexClosed.put("latestPrice", "/html/body/div[3]/div[2]/div[3]/div/div[2]/h2/span"); + this.indexClosed.put("change", "/html/body/div[3]/div[2]/div[3]/div/div[2]/bg-quote/span[1]"); + this.indexClosed.put("changePercent", "/html/body/div[3]/div[2]/div[3]/div/div[2]/bg-quote/span[2]"); + this.indexClosed.put("52weekRange", "/html/body/div[3]/div[6]/div[1]/div[1]/div/ul/li[3]/span[1]"); + this.indexClosed.put("ytdChangePercent", "/html/body/div[3]/div[6]/div[1]/div[2]/div[1]/table/tbody/tr[5]/td[2]/ul/li[1]"); + this.indexClosed.put("oneYearChangePercent", "/html/body/div[3]/div[6]/div[1]/div[2]/div[1]/table/tbody/tr[5]/td[2]/ul/li[1]"); + this.indexClosed.put("timeStamp", "/html/body/div[3]/div[2]/div[3]/div/div[1]/span/bg-quote"); // --------------------------------------------------------------------------------- // xPaths: Indexes with market OPEN // --------------------------------------------------------------------------------- - indexOpen.put("latestPrice", "/html/body/div[3]/div[2]/div[3]/div/div[2]/h2/bg-quote"); - indexOpen.put("change", "/html/body/div[3]/div[2]/div[3]/div/div[2]/bg-quote/span[1]/bg-quote"); - indexOpen.put("changePercent", "/html/body/div[3]/div[2]/div[3]/div/div[2]/bg-quote/span[2]/bg-quote"); - indexOpen.put("52weekRange", "/html/body/div[3]/div[6]/div[1]/div[1]/div/ul/li[3]/span[1]"); - indexOpen.put("ytdChangePercent", "/html/body/div[3]/div[6]/div[1]/div[2]/div/table/tbody/tr[4]/td[2]/ul/li[1]"); - indexOpen.put("oneYearChangePercent", "/html/body/div[3]/div[6]/div[1]/div[2]/div[1]/table/tbody/tr[5]/td[2]/ul/li[1]"); - indexOpen.put("timeStamp", "/html/body/div[3]/div[2]/div[3]/div/div[1]/span/bg-quote"); - - indexOpen.put("marketStatus", "/html/body/div[3]/div[2]/div[3]/div/small/div"); + this.indexOpen.put("latestPrice", "/html/body/div[3]/div[2]/div[3]/div/div[2]/h2/bg-quote"); + this.indexOpen.put("change", "/html/body/div[3]/div[2]/div[3]/div/div[2]/bg-quote/span[1]/bg-quote"); + this.indexOpen.put("changePercent", "/html/body/div[3]/div[2]/div[3]/div/div[2]/bg-quote/span[2]/bg-quote"); + this.indexOpen.put("52weekRange", "/html/body/div[3]/div[6]/div[1]/div[1]/div/ul/li[3]/span[1]"); + this.indexOpen.put("ytdChangePercent", "/html/body/div[3]/div[6]/div[1]/div[2]/div/table/tbody/tr[4]/td[2]/ul/li[1]"); + this.indexOpen.put("oneYearChangePercent", "/html/body/div[3]/div[6]/div[1]/div[2]/div[1]/table/tbody/tr[5]/td[2]/ul/li[1]"); + this.indexOpen.put("timeStamp", "/html/body/div[3]/div[2]/div[3]/div/div[1]/span/bg-quote"); + + this.indexOpen.put("marketStatus", "/html/body/div[3]/div[2]/div[3]/div/small/div"); } @@ -97,7 +97,7 @@ public XPathLookup() { * @return */ public String lookupSymbolOpen(String key) { - return symbolOpen.get(key); + return this.symbolOpen.get(key); } /** @@ -107,7 +107,7 @@ public String lookupSymbolOpen(String key) { * @return */ public String lookupSymbolClosed(String key) { - return symbolClosed.get(key); + return this.symbolClosed.get(key); } /** @@ -117,7 +117,7 @@ public String lookupSymbolClosed(String key) { * @return */ public String lookupIndexOpen(String key) { - return indexOpen.get(key); + return this.indexOpen.get(key); } /** @@ -127,6 +127,6 @@ public String lookupIndexOpen(String key) { * @return */ public String lookupIndexClosed(String key) { - return indexClosed.get(key); + return this.indexClosed.get(key); } }