id
stringlengths
36
36
text
stringlengths
1
1.25M
4f96201b-9be1-49c3-b8a5-2213fd273f3b
public static void setFirstOfTCharacter(String X) { GrammerAnalysis.tCharacters.get(X).First.add(X); }
5a7d872e-2f73-4177-b902-d04d2ed1a3b4
public static void initFirstOfNCharacter(String X) { for (Production p : GrammerAnalysis.productions) { if (X.equals(p.getLeft())) { String firstCharOfR = p.getRight().get(0); // 如果右部的首符号是终结符 if (isTCharacter(firstCharOfR)) { if (!GrammerAnalysis.nCharacters.get(X).First .contains(firstChar...
9eedc064-cbbc-47f6-926d-da3467aebbbc
public static void setFirstSet(String X) { for (Production p : GrammerAnalysis.productions) { if (X.equals(p.getLeft())) { String firstCharOfR = p.getRight().get(0); if (isNCharacter(firstCharOfR)) { for (String s : GrammerAnalysis.nCharacters .get(firstCharOfR).First) { if (!GrammerAnaly...
66f38fc3-44e6-4b65-b835-4c3cdca36147
public static boolean canLeadNull(String X) { // X是终结符,则X不可能推出空串 if (isTCharacter(X)) { return false; } // X是非终结符 else { // 查找Cache表 if (GrammerAnalysis.canLeadNullList.contains(X)) { return true; } for (Production p : GrammerAnalysis.productions) { if (X.equals(p.getLeft())) { // ...
d7750199-10ad-45dd-9ce2-a26abce6d110
public static boolean isNCharacter(String s) { return GrammerAnalysis.nCharacters.containsKey(s); }
b3d32639-d0d5-4a5c-ae86-15d9762b8226
public static boolean isTCharacter(String s) { return GrammerAnalysis.tCharacters.containsKey(s); }
dae8464d-4eb0-49d7-8d6e-9639f5e0e483
public static ArrayList<String> getFirstSet(String X) { if (isNCharacter(X)) { return (ArrayList<String>) GrammerAnalysis.nCharacters.get(X).First; } else if (isTCharacter(X)) { return (ArrayList<String>) GrammerAnalysis.tCharacters.get(X).First; } else { return null; } }
91f9b82a-d252-4871-b032-1550099f6249
public static ArrayList<String> getFirstSetOfCharSequence( ArrayList<String> alpha) { ArrayList<String> FirstSet = new ArrayList<String>(); // 初始化工作 if (alpha.size() > 0) { String initStr = alpha.get(0); for (String s : getFirstSet(initStr)) { if (!FirstSet.contains(s)) { FirstSet.add(s); }...
2f7a4b96-1526-4cc5-87a5-0b24bccf30c6
public static void initFollow() { ((NonterminalCharacter) GrammerAnalysis.nCharacters .get(GrammerAnalysis.productions.get(0).getLeft())).Follow .add("#"); }
6ff91d15-59ba-472d-9f3e-b680829d84dd
public static void setFollow() { for (Production production : GrammerAnalysis.productions) { String currentLeft = production.getLeft(); ArrayList<String> currentRight = production.getRight(); int len = currentRight.size(); for (int i = 0; i < len; i++) { String currentChar = currentRight.get(i); ...
04831bcb-582d-46fc-b1e7-1cc318de4a15
public static void setSelectForProductions() { for (Production production : GrammerAnalysis.productions) { if ("$".equals(production.getRight().get(0))) { for (String s : ((NonterminalCharacter) GrammerAnalysis.nCharacters .get(production.getLeft())).Follow) { if (!production.Select.contains(s)) { ...
8ef05e7e-035d-4ba7-b644-cd09eeb8b278
public static void setSync() { for (String s : GrammerAnalysis.nCharacters.keySet()) { ((NonterminalCharacter) GrammerAnalysis.nCharacters.get(s)) .setSync(); } }
5ce243f2-3e5d-40ab-821c-872fa173cd97
public static void setForecastTable() { for (Production production : GrammerAnalysis.productions) { if (GrammerAnalysis.ForecastTable.keySet().contains( production.getLeft())) { for (String s : production.Select) { GrammerAnalysis.ForecastTable.get(production.getLeft()) .put(s, production.getR...
810d287b-e5a8-4674-9206-57ad203915a5
public static ArrayList<Production> Analysis(ArrayList<String> sentence, String startChar) { ArrayList<Production> productionSequences = new ArrayList<Production>(); Stack<String> prodChars = new Stack<String>(); prodChars.push("#"); prodChars.push(startChar); // sentence = sentence + "#"; sentence.add("...
1abbdea3-c4e6-46a7-b10b-8f123ec0443c
public static void setCharacters() { // 将非终结符(出现在产生式左部的字符串)放入非终结符的Map中 for (Production p : GrammerAnalysis.productions) { if (!GrammerAnalysis.nCharacters.containsKey(p.getLeft())) { GrammerAnalysis.nCharacters.put(p.getLeft(), new NonterminalCharacter(p.getLeft())); } } // 找出产生式右部的终结符,放入终结符的Map...
25800899-6818-47a6-b5fd-b643f3e42d1b
public static ArrayList<Production> readProductionFromFile(String filePath) throws IOException { ArrayList<Production> productions = new ArrayList<Production>(); File file = new File(filePath); if (!file.exists() || file.isDirectory()) { System.out.println("Error!File not exists or it's a directory!"); ...
fba786c7-b7f7-4d47-b31d-7f2bd6c2f308
public static ArrayList<Token> readTokenFromFile(String tokenPath) throws IOException { ArrayList<Token> tokens = new ArrayList<Token>(); File file = new File(tokenPath); if (!file.exists() || file.isDirectory()) { System.out.println("Error!File not exists or it's a directory!"); throw new FileNotFoundE...
eabe1d62-0ac3-45d4-9075-a5f159018b88
public MyCharacter() { First = new ArrayList<String>(); }
c74407e7-a6b1-4fc7-8b61-6c9f20ad6aba
public NonterminalCharacter(String what) { super(); this.what = what; Follow = new ArrayList<String>(); Sync = new ArrayList<String>(); }
a7aa187c-a1b7-44ab-9d60-380bcf90d5ae
public void setSync() { Sync.addAll(Follow); // 添加Follow集 for (String s : First) { // 添加First集 if (!Sync.contains(s)) { Sync.add(s); } } }
93551106-73ac-4e5d-b9c0-54a5ab62cd64
public Token(String token, String value) { super(); this.token = token; this.value = value; }
b68c84df-8152-4e40-badf-42d36f1f0fc4
public String getToken() { return token; }
e1a1de56-daa2-4e67-a9e8-dfde1cb45a4d
public void setToken(String token) { this.token = token; }
abcbe5a3-dbd1-404b-82ef-4775490d30eb
public String getValue() { return value; }
358b1afc-9c87-42d4-897e-2815b820aaaf
public void setValue(String value) { this.value = value; }
3b2b2cbb-5bb4-45b9-b2b6-39f358c3ce4d
public TerminateCharacter(String what) { super(); this.what = what; }
71009ca3-5b40-4a9e-9253-70d2095a509a
public Production(String left, ArrayList<String> right) { Left = left; this.right = right; this.Select = new ArrayList<String>(); }
2e402515-67c8-4e53-be34-b926a6801208
public String getLeft() { return Left; }
971bfcde-955b-4dca-956c-3e4c8b50eef3
public void setLeft(String left) { Left = left; }
8563f529-95ad-4ac0-a14a-b74cbfaee701
public ArrayList<String> getRight() { return right; }
003afb24-0b51-44d7-9d8f-74239f8dd51b
public void setRight(ArrayList<String> right) { this.right = right; }
061547dd-ac5f-4b67-bf2a-dd08c4f99536
public LogRecord(String id) { super(); this.id = id; }
d8203dd4-2e8c-403c-b59d-9a5a87f95443
@Override public String toString() { StringBuilder stringBuilder = new StringBuilder(); for (String s : this) { stringBuilder.append(s); } return stringBuilder.toString(); }
62a0938d-6002-4b0b-b6fe-8e0e23c7fde7
public String getId() { return id; }
77196c87-6905-43c9-a3d9-43471ba47ee5
String readLine() throws IOException;
51f93510-3750-4e92-97f8-fdecbbf06002
void pushBack(String str);
2b1b9e67-7cf8-4657-9973-a8793a2ee120
private OozieLogReader(PushbackLineReader lineReader) { this.lineReader = lineReader; }
059bd046-e8cd-4d7c-933e-53559be11836
public static LogReader getInstance(PushbackLineReader lineReader) { return new OozieLogReader(lineReader); }
408a6fcb-87c6-4e8e-a428-cfd7cc838b19
@Override public LogRecord readRecord() throws IOException { LogRecord logRecord = null; //read beginnings of first log record in readAhead String line = lineReader.readLine(); if (line == null) { logger.info("processing finished."); return null; } ...
65d67aef-134e-43af-a956-cd48babf7329
private boolean isNewRecord(String line) { final Matcher matcher = recordRegex.matcher(line); return matcher.find(); }
e66a43a2-72ba-4e67-a586-46f8dd83219d
public static String getJobId(String line) { if(StringUtils.isEmpty(line)) { return null; } final Matcher matcher = jobRegex.matcher(line); if(matcher.find()) { return matcher.group(1); } return null; }
f7ad504b-5f28-4d51-9802-1d84d65e6c08
LogRecord readRecord() throws IOException;
7418c50b-1bf6-40b1-bff1-df5a6ed816b6
private App() throws IOException, ConfigurationException { logger.info("***Starting App***"); initConfiguration(); final String[] logLocations = config.getStringArray("log.oozie.location"); if (ArrayUtils.isEmpty(logLocations)) { throw new ConfigurationException("Please set p...
3bca8e5d-fdd4-4441-91bf-7e8cf7527dd9
private void initConfiguration() throws ConfigurationException { CompositeConfiguration compositeConfiguration = new CompositeConfiguration(); compositeConfiguration.addConfiguration(new SystemConfiguration()); compositeConfiguration.addConfiguration(new PropertiesConfiguration("logExtractor.pro...
9e8e01fd-6afb-4c91-97b7-4abc8f1c7bf0
private Writer getWriter(String id) throws IOException { Writer writer = files.get(id); if(writer == null) { final String fileName = writeLocation + id + ".txt"; final File parentFile = new File(fileName).getParentFile(); if (!parentFile.exists()) { lo...
1dd2df43-775c-40c1-af84-53c975c1c7b3
private void closeWriters() { for (String s : files.keySet()) { IOUtils.closeQuietly(files.get(s)); } }
1463149f-84dd-4837-b9ef-4933502d6b13
public void finish() { closeWriters(); logger.info("***App Done***"); }
8e2459e7-1dc5-4ef7-bd05-9d074712c2ce
public static void main(String[] args) throws Exception { App app = new App(); app.segregate(); app.finish(); }
8d574ef6-a38c-40ad-98fa-83a900407630
private void segregate() throws IOException { PushbackLineReader reader = new MultiFileSortedPushbackReader(logFiles); final LogReader logReader = OozieLogReader.getInstance(reader); for (LogRecord record = logReader.readRecord(); record != null; record = logReader.readRecord()) { if...
aacf3855-9d3c-42b4-a5d1-c4ebef386312
private List<File> getLogFiles(String[] logLocations) throws IOException { final String logFileNamePattern = config.getString("log.oozie.filename.pattern"); Set<File> uniqueFiles = new HashSet<File>(); for (String oneLocation : logLocations) { File file = new File(oneLocation); ...
a8d2f0a5-eb12-4bcd-b164-d12252eea8ea
public static AbstractConfiguration getConfig() { return config; }
e6fd3930-1730-416f-93f7-d2008b2cb1be
public MultiFileSortedPushbackReader(List<File> fileList) throws IOException { List<MyReader> readers = new ArrayList<MyReader>(); for (File file : fileList) { final FileReader fileReader = new FileReader(file.getCanonicalPath()); final MyReader reader = new MyReader(fileReader);...
de3c2086-ac0a-41b0-827f-83ff4b3796d2
@Override public int compare(MyReader o1, MyReader o2) { String l1, l2; try { l1 = o1.peekLine(); l2 = o2.peekLine(); } catch (IOException e) { return 0; } return l1.co...
f9dcd7a4-eef6-4fea-9c41-627fe4e437bb
public void pushBack(String str) { pushQueue.add(str); }
aed994fb-6ec9-43bd-a957-bd034453dc0c
@Override public String readLine() throws IOException { //return stuff from push queue if available if(pushQueue.size() != 0) { return pushQueue.remove(0); } //pick up next reader if current reader finished if (readers.size() == 0) { return null; ...
c9e86881-c574-4bb2-b26e-af218368dc68
public MyReader(Reader reader) { br = new BufferedReader(reader); }
71f35c14-030d-4407-a6d0-97b722110bd4
public String peekLine() throws IOException { final String str = readLine(); pushBack(str); return str; }
cc746725-bac4-4072-b20a-0b106ba9c567
public void pushBack(String str) { pushQueue.add(str); }
500de233-7c3a-4988-a87e-4f0bec8b659c
public String readLine() throws IOException { if(pushQueue.size() != 0) { return pushQueue.remove(0); } final String line = br.readLine(); if (line != null) { return line + "\n"; } return null; }
74efa398-af87-46c9-9a80-7ecd9de2e3f5
public void close() { IOUtils.closeQuietly(br); }
4767208d-aeae-4ab5-b25b-7f91eae8a0d2
public InstallmentTermGUI() throws ParseException { calculator = new LoanCalculator(); df = DateFormat.getDateInstance(DateFormat.SHORT); nf = NumberFormat.getNumberInstance(); nf.setMinimumFractionDigits(3); initLoanScheduleTableModel(); initComponents(); ca...
7cdf15db-a001-45cf-afa8-6f18c3b18479
private void initLoanScheduleTableModel() { loanScheduleTableModel = new javax.swing.table.DefaultTableModel( new Object[][]{}, new String[]{ "Payment #", "Payment Amount", "Principal", "Interest", "Payoff Amount"}) { Class[] types = new Class[]{ ...
703e2a24-bc07-4049-b00e-9e6b9912cdc3
public Class getColumnClass(int columnIndex) { return types[columnIndex]; }
2619700b-4696-46bd-a277-c53151ecbe72
public boolean isCellEditable(int rowIndex, int columnIndex) { return canEdit[columnIndex]; }
2f85a77a-a3fb-499c-b2a7-385eb421636f
@SuppressWarnings("unchecked") // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents private void initComponents() { payFreqButtonGroup = new javax.swing.ButtonGroup(); principalLabel = new javax.swing.JLabel(); aprLabel = new javax.swing.JLabel(); ...
4cf24e3f-2065-404f-8ba3-17c6ffce3e1c
public void stateChanged(javax.swing.event.ChangeEvent evt) { termSliderStateChanged(evt); }
00268a6a-c1dd-4f57-95b6-3f81f680dfa3
public void actionPerformed(java.awt.event.ActionEvent evt) { weeklyPayFreqButtonActionPerformed(evt); }
65977923-57b5-4e09-b7d4-39127d68e0c6
public void actionPerformed(java.awt.event.ActionEvent evt) { biweeklyPayFreqButtonActionPerformed(evt); }
1aca26a1-7b99-4e32-a7f1-fbf662e85b8e
public void actionPerformed(java.awt.event.ActionEvent evt) { semimonthlyPayFreqButtonActionPerformed(evt); }
5cbbc9ee-b1ed-44fe-a46a-2c004ab48843
public void actionPerformed(java.awt.event.ActionEvent evt) { monthlyPayFreqButtonActionPerformed(evt); }
6c06c9b6-7ba3-4b12-821a-1919e9eb50b7
public void actionPerformed(java.awt.event.ActionEvent evt) { printButtonActionPerformed(evt); }
45877b2a-962b-4ba2-8362-334cc6608483
public void actionPerformed(java.awt.event.ActionEvent evt) { exportButtonActionPerformed(evt); }
1b1fdb21-cdb7-4b0b-b51e-bc2182190329
public void stateChanged(javax.swing.event.ChangeEvent evt) { principalSliderStateChanged(evt); }
662a7056-9190-4b81-8a1b-93a630629225
public void actionPerformed(java.awt.event.ActionEvent evt) { principalTextFieldActionPerformed(evt); }
44b08e98-4093-4649-a915-198574ad5648
public void actionPerformed(java.awt.event.ActionEvent evt) { aprTextFieldActionPerformed(evt); }
1717a2c3-c84c-4276-ab1c-3d772a078ee0
private void weeklyPayFreqButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_weeklyPayFreqButtonActionPerformed calculator.setPayFreq(PayFrequency.WEEKLY.getLoanPeriod()); calculate(); }//GEN-LAST:event_weeklyPayFreqButtonActionPerformed
f892d17a-5300-4564-ac4d-314297370616
private void biweeklyPayFreqButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_biweeklyPayFreqButtonActionPerformed calculator.setPayFreq(PayFrequency.BI_WEEKLY.getLoanPeriod()); calculate(); }//GEN-LAST:event_biweeklyPayFreqButtonActionPerformed
461e187d-1a88-4a54-9209-b2c33319c2d5
private void semimonthlyPayFreqButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_semimonthlyPayFreqButtonActionPerformed calculator.setPayFreq(PayFrequency.SEMI_MONTHLY.getLoanPeriod()); calculate(); }//GEN-LAST:event_semimonthlyPayFreqButtonActionPerformed
684217fe-52da-4cef-99cb-90137fa5db05
private void monthlyPayFreqButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_monthlyPayFreqButtonActionPerformed calculator.setPayFreq(PayFrequency.MONTHLY.getLoanPeriod()); calculate(); }//GEN-LAST:event_monthlyPayFreqButtonActionPerformed
ccb77676-9b37-4642-8b92-739e53ea7cf1
private void termSliderStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_termSliderStateChanged calculator.setTermLength(termSlider.getValue()); calculate(); }//GEN-LAST:event_termSliderStateChanged
c003a236-fc12-4793-88d9-b17b3e1b5a9d
private void printButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_printButtonActionPerformed try { loanScheduleTable.print(); } catch (PrinterException ex) { printErrorMsg(ex, "unable to print"); } }//GEN-LAST:event_printButtonActionPerformed
d65c7f84-d3fa-4f97-8b24-6b931acde7ff
private void exportButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_exportButtonActionPerformed int colCnt = loanScheduleTable.getColumnCount(); int rowCnt = loanScheduleTable.getRowCount(); File csvFile = null; File renCsvFile = null; String newFileName =...
a5285c13-4423-4d6d-9071-128a2b47302a
private void principalSliderStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_principalSliderStateChanged principalTextField.setText((String.valueOf(principalSlider.getValue()))); calculator.setPrincipal(principalSlider.getValue()); calculate(); }//GEN-LAST:event_principalSl...
6b10a62e-dfb9-4d77-9b7c-9fb2c08e4255
private void principalTextFieldActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_principalTextFieldActionPerformed String prinStr = principalTextField.getText(); try { int principal = Integer.parseInt(prinStr); calculator.setPrincipal(principal); ...
8177d71f-3a08-4fcc-9a2e-f261bf8bc1aa
private void aprTextFieldActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_aprTextFieldActionPerformed calculate(); }//GEN-LAST:event_aprTextFieldActionPerformed
35fac22e-20b9-469e-863d-9bd641ddb946
private void calculate() { int termLength, payFreq; loanScheduleTableModel.setRowCount(0); // set PDL paydown amount try { String aprStr = aprTextField.getText(); calculator.setInstallAPR(Double.parseDouble(aprStr)); } catch (NullPointerException npe) { ...
29f1ff83-bd36-434a-a359-2435fb1eef1b
private void printErrorMsg(Exception e, String msg) { JOptionPane.showMessageDialog(rootPane, msg, "Error", JOptionPane.ERROR_MESSAGE); e.printStackTrace(); }
4e6ef4d3-d49c-4abe-869d-ac91477585db
public static void main(String args[]) { /* Set the Nimbus look and feel */ //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) "> /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel. * For details see http://down...
249fafa9-989d-4a3d-8a98-248de16ba7c5
public void run() { try { new InstallmentTermGUI().setVisible(true); } catch (ParseException ex) { Logger.getLogger(InstallmentTermGUI.class.getName()).log(Level.SEVERE, null, ex); } }
75c4c79d-971b-423b-988b-6280f3e33d7c
PayFrequency(int duration){ this.duration = duration; switch(this.ordinal()){ case 0: loanPeriod = duration; break; case 1: loanPeriod = duration; break; case 2: loanPeriod = duration; ...
a48ae119-f9ce-476c-99e3-1d32f0082b5d
public int getDuration(){return duration;}
eabaad36-a245-4de3-8126-deeda9102363
public int getLoanPeriod(){return loanPeriod;}
39253c5c-de65-4c92-b414-7921a764843e
public InstallmentLoan(int principal, int payFreq, int termLength, double apr, double periodInt, Date origDate) { super (principal, payFreq, apr, periodInt, origDate); this.termLength = termLength; }
25c0663f-208e-4ba8-a6f0-e3f35bf5bf7b
@Override public void setPeriodInterest() { double unit = 0; switch (payFrequency) { case 7: unit = 52; break; case 14: unit = 26; break; case 15: unit = 24; break; ...
342ae8c7-e937-4b21-b196-452bc47a1407
public int getTermLength() {return termLength;}
d6ff2fa7-2cff-4580-8a5e-8ef330e62970
public void setTermLength(int termLength) {this.termLength = termLength;}
480e3b51-1844-4a0b-ad56-976bed67b368
public Loan(int principal, int payFreq, double apr, double periodInt, Date origDate) { this.principal = principal; this.payFrequency = payFreq; this.apr = apr; this.periodInterest = periodInt; this.origDate = origDate; }
4a6979c2-6926-48c9-8ccb-1a76a7c1f8fd
public double getApr() {return apr;}
6d8b0a85-906d-41dc-8c89-49aed20a30d3
public void setApr(double apr) {this.apr = apr;}
fd190d01-8f3e-49c2-974b-ae5ccddbd67e
public int getDaysInYear() {return daysInYear;}