/* (non-Javadoc) * @see org.xml.sax.helpers.DefaultHandler#endDocument() */ @Override public void endDocument() throws SAXException { super.endDocument(); for (DefaultHandler delegate : delegates) { delegate.endDocument(); } }
@Override public void endDocument() throws SAXException { /*Log.i("end_document",_yahooWeatherForecast.getCityName()); Log.i("end_document", _yahooWeatherForecast.getCountryName()); Log.i("end_document",_yahooWeatherForecast.getRegionName());*/ super.endDocument(); }
@Override public void endDocument() throws SAXException { if (this.mErrors == null || this.mErrors.size() == 0) { // Maybe do some finalization or similar... } super.endDocument(); }
@Override public void endDocument() throws SAXException { super.endDocument(); L.d("endDocument: " + entries.size() + " entries parsed"); for (EntryInfo entry : entries) { L.d(" " + entry.title + " : " + entry.link.toString()); } }
@Override public void endDocument() throws SAXException { // TODO Auto-generated method stub super.endDocument(); }
@Override public void endDocument() throws SAXException { super.endDocument(); }
@Override public void endDocument() throws SAXException { super.endDocument(); HashMap<String, String> mapFullName = new HashMap<>(mAccountList.size()); HashMap<String, Account> mapImbalanceAccount = new HashMap<>(); // The XML has no ROOT, create one if (mRootAccount == null) { mRootAccount = new Account("ROOT"); mRootAccount.setAccountType(AccountType.ROOT); mAccountList.add(mRootAccount); mAccountMap.put(mRootAccount.getUID(), mRootAccount); } String imbalancePrefix = AccountsDbAdapter.getImbalanceAccountPrefix(); // Add all account without a parent to ROOT, and collect top level imbalance accounts for (Account account : mAccountList) { mapFullName.put(account.getUID(), null); boolean topLevel = false; if (account.getParentUID() == null && account.getAccountType() != AccountType.ROOT) { account.setParentUID(mRootAccount.getUID()); topLevel = true; } if (topLevel || (mRootAccount.getUID().equals(account.getParentUID()))) { if (account.getName().startsWith(imbalancePrefix)) { mapImbalanceAccount.put(account.getName().substring(imbalancePrefix.length()), account); } } } // Set the account for created balancing splits to correct imbalance accounts for (Split split : mAutoBalanceSplits) { String currencyCode = split.getAccountUID(); Account imbAccount = mapImbalanceAccount.get(currencyCode); if (imbAccount == null) { imbAccount = new Account(imbalancePrefix + currencyCode, Currency.getInstance(currencyCode)); imbAccount.setParentUID(mRootAccount.getUID()); imbAccount.setAccountType(AccountType.BANK); mapImbalanceAccount.put(currencyCode, imbAccount); mAccountList.add(imbAccount); } split.setAccountUID(imbAccount.getUID()); } java.util.Stack<Account> stack = new Stack<>(); for (Account account : mAccountList) { if (mapFullName.get(account.getUID()) != null) { continue; } stack.push(account); String parentAccountFullName; while (!stack.isEmpty()) { Account acc = stack.peek(); if (acc.getAccountType() == AccountType.ROOT) { // ROOT_ACCOUNT_FULL_NAME should ensure ROOT always sorts first mapFullName.put(acc.getUID(), AccountsDbAdapter.ROOT_ACCOUNT_FULL_NAME); stack.pop(); continue; } String parentUID = acc.getParentUID(); Account parentAccount = mAccountMap.get(parentUID); // ROOT account will be added if not exist, so now anly ROOT // has an empty parent if (parentAccount.getAccountType() == AccountType.ROOT) { // top level account, full name is the same as its name mapFullName.put(acc.getUID(), acc.getName()); stack.pop(); continue; } parentAccountFullName = mapFullName.get(parentUID); if (parentAccountFullName == null) { // non-top-level account, parent full name still unknown stack.push(parentAccount); continue; } mapFullName.put( acc.getUID(), parentAccountFullName + AccountsDbAdapter.ACCOUNT_NAME_SEPARATOR + acc.getName()); stack.pop(); } } for (Account account : mAccountList) { account.setFullName(mapFullName.get(account.getUID())); } long startTime = System.nanoTime(); mAccountsDbAdapter.beginTransaction(); Log.d(getClass().getSimpleName(), "bulk insert starts"); try { Log.d(getClass().getSimpleName(), "before clean up db"); mAccountsDbAdapter.deleteAllRecords(); Log.d( getClass().getSimpleName(), String.format("deb clean up done %d ns", System.nanoTime() - startTime)); long nAccounts = mAccountsDbAdapter.bulkAddRecords(mAccountList); Log.d("Handler:", String.format("%d accounts inserted", nAccounts)); // We need to add scheduled actions first because there is a foreign key constraint on // transactions // which are generated from scheduled actions (we do auto-create some transactions during // import) long nSchedActions = mScheduledActionsDbAdapter.bulkAddRecords(mScheduledActionsList); Log.d("Handler:", String.format("%d scheduled actions inserted", nSchedActions)); long nTempTransactions = mTransactionsDbAdapter.bulkAddRecords(mTemplateTransactions); Log.d("Handler:", String.format("%d template transactions inserted", nTempTransactions)); long nTransactions = mTransactionsDbAdapter.bulkAddRecords(mTransactionList); Log.d("Handler:", String.format("%d transactions inserted", nTransactions)); long nPrices = mPricesDbAdapter.bulkAddRecords(mPriceList); Log.d(getClass().getSimpleName(), String.format("%d prices inserted", nPrices)); long endTime = System.nanoTime(); Log.d(getClass().getSimpleName(), String.format("bulk insert time: %d", endTime - startTime)); mAccountsDbAdapter.setTransactionSuccessful(); } finally { mAccountsDbAdapter.endTransaction(); } }
@Override public void endDocument() throws SAXException { super.endDocument(); // we're done, make sure any remaining text is moved flushAccumulator(); }
/* * Actual implementation of the rendering process. When a function in this * module is called, this method is executed with the given inputs. @param * Sequence[] args (XSL-FO, mime-type, parameters) @param Sequence * contextSequence (default sequence) * * @see org.exist.xquery.BasicFunction#eval(org.exist.xquery.value.Sequence[], * org.exist.xquery.value.Sequence) */ public Sequence eval(Sequence[] args, Sequence contextSequence) throws XPathException { // gather input XSL-FO document // if no input document (empty), return empty result as we need data to // process if (args[0].isEmpty()) return Sequence.EMPTY_SEQUENCE; Item inputNode = args[0].itemAt(0); // get mime-type String mimeType = args[1].getStringValue(); // get parameters Properties parameters = new Properties(); if (!args[2].isEmpty()) { parameters = ModuleUtils.parseParameters(((NodeValue) args[2].itemAt(0)).getNode()); } try { // setup a transformer handler TransformerHandler handler = TransformerFactoryAllocator.getTransformerFactory(context.getBroker()) .newTransformerHandler(); Transformer transformer = handler.getTransformer(); // set the parameters if any if (parameters.size() > 0) { Enumeration keys = parameters.keys(); while (keys.hasMoreElements()) { String name = (String) keys.nextElement(); String value = parameters.getProperty(name); transformer.setParameter(name, value); } } // setup the FopFactory FopFactory fopFactory = FopFactory.newInstance(); if (args.length == 4 && args[3] != null && !args[3].isEmpty()) { FopConfigurationBuilder cfgBuilder = new FopConfigurationBuilder(context.getBroker()); Configuration cfg = cfgBuilder.buildFromItem(args[3].itemAt(0)); fopFactory.setUserConfig(cfg); } // setup the foUserAgent, using given parameters held in the // transformer handler FOUserAgent foUserAgent = setupFOUserAgent(fopFactory.newFOUserAgent(), parameters, transformer); // create new instance of FOP using the mimetype, the created user // agent, and the output stream ByteArrayOutputStream baos = new ByteArrayOutputStream(); Fop fop = fopFactory.newFop(mimeType, foUserAgent, baos); // Obtain FOP's DefaultHandler DefaultHandler dh = fop.getDefaultHandler(); // process the XSL-FO dh.startDocument(); inputNode.toSAX(context.getBroker(), dh, new Properties()); dh.endDocument(); // return the result return new Base64Binary(baos.toByteArray()); } catch (TransformerException te) { throw new XPathException(te); } catch (SAXException se) { throw new XPathException(se); } }
/** 用来标识解析结束 */ @Override public void endDocument() throws SAXException { super.endDocument(); System.out.println("SAX解析结束"); }
@Override public void endDocument() throws SAXException { super.endDocument(); Logger.w(TAG, "endDocument()"); // Do Nothing; }