private void appendMessage(String text, String sourceName, int line, int column) { if (location == null) { location = new LocationImpl(null, sourceName, line, column); message = new StringBuffer(); } else { // Append a linefeed message.append("\n"); } message.append(text); }
/** * @see org.apache.cocoon.sitemap.ExecutionContext#getLocation() */ public Location getLocation() { return new LocationImpl("[sitemap]", this.wrappingProcessor.source.getURI()); }
protected String proccessLine(String line, int lineNumber) throws ProcessingException { if (getLogger().isDebugEnabled()) getLogger().debug("Processing line: " + line); Matcher matcher = URIregexp.compiledURIpattern.matcher(line); StringBuffer sb = new StringBuffer(line.length()); while (matcher.find()) { if (getLogger().isDebugEnabled()) getLogger().debug("Processing link: " + matcher.group(0)); String link = matcher.group(1); Object replacement; try { replacement = inputModule.getAttribute(link, null, objectModel); } catch (ConfigurationException e) { throw ProcessingException.throwLocated("Failed to obtain attribute from input module", e, new LocationImpl(null, inputSource.getURI(), lineNumber, matcher.start())); } if (!(replacement instanceof String)) throw new ProcessingException("Attribute named '" + link + "' obtained from 'servlet' input module has to be String object.", new LocationImpl(null, inputSource.getURI(), lineNumber, matcher.start())); matcher.appendReplacement(sb, (String)replacement); } matcher.appendTail(sb); return sb.toString(); }
public Form createForm(String uri) throws Exception { Source source = null; try { try { source = sourceResolver.resolveURI(uri); } catch (Exception e) { throw new FormsException("Could not resolve form definition URI.", e, new LocationImpl("[FormManager]", uri)); } return createForm(source); } finally { if (source != null) { sourceResolver.release(source); } } }
public FormDefinition createFormDefinition(String uri) throws Exception { Source source = null; try { try { source = sourceResolver.resolveURI(uri); } catch (Exception e) { throw new FormsException("Could not resolve form definition.", e, new LocationImpl("[FormManager]", uri)); } return createFormDefinition(source); } finally { if (source != null) { sourceResolver.release(source); } } }
public void onExit(Context cx, boolean byThrow, Object resultOrException) { if (byThrow) { String name = null; if (script.isFunction()) { name = script.getFunctionName(); } else { name = "[script]"; } if (locations == null) { locations = new ArrayList(1); // start small } locations.add(new LocationImpl(name, script.getSourceName(), line, -1)); } else if (locations != null) { // The exception was handled by the script: clear any recorded locations locations = null; } } }
public Location getLocation(Object obj, String description) { if (obj instanceof Configuration) { Configuration config = (Configuration)obj; String locString = config.getLocation(); Location result = LocationUtils.parse(locString); if (LocationUtils.isKnown(result)) { // Add description StringBuffer desc = new StringBuffer().append('<'); // Unfortunately Configuration.getPrefix() is not public try { if (config.getNamespace().startsWith("http://apache.org/cocoon/sitemap/")) { desc.append("map:"); } } catch (ConfigurationException e) { // no namespace: ignore } desc.append(config.getName()).append('>'); return new LocationImpl(desc.toString(), result); } else { return result; } } // Try next finders. return null; } };
} catch (Exception e) { throw new LibraryException("Unable to resolve library.", e, new LocationImpl("[LibraryManager]", sourceURI));
return new LocationImpl(desc.toString(), rawLoc.getURI(), rawLoc.getLineNumber(),
} catch (Exception e) { throw new LibraryException("Unable to resolve library.", e, new LocationImpl("[LibraryManager]", sourceURI));
} catch (Exception e) { throw new LibraryException("Unable to resolve library.", e, new LocationImpl("[LibraryManager]", sourceURI)); } catch (Exception e) { throw new LibraryException("Unable to load library.", e, new LocationImpl("[LibraryManager]", source.getURI()));
public FormDefinition createFormDefinition(Source source) throws Exception { FormDefinition formDefinition = (FormDefinition) this.cacheManager.get(source, PREFIX); if (formDefinition != null && formDefinition.getLocalLibrary().dependenciesHaveChanged()) { formDefinition = null; // invalidate } if (formDefinition == null) { if (LOG.isDebugEnabled()) { LOG.debug("Building Form: " + source.getURI()); } Document formDocument; try { InputSource inputSource = new InputSource(source.getInputStream()); inputSource.setSystemId(source.getURI()); formDocument = DomHelper.parse(inputSource, parser); } catch (Exception e) { throw new FormsException("Could not parse form definition.", e, new LocationImpl("[FormManager]", source.getURI())); } Element formElement = formDocument.getDocumentElement(); formDefinition = createFormDefinition(formElement); this.cacheManager.set(formDefinition, source, PREFIX); } return formDefinition; }
} catch (Exception e) { throw new LibraryException("Unable to resolve library.", e, new LocationImpl("[LibraryManager]", sourceURI)); } catch (Exception e) { throw new LibraryException("Unable to load library.", e, new LocationImpl("[LibraryManager]", source.getURI()));
public Location getLocation(Object obj, String description) { if (obj instanceof EcmaError) { EcmaError ex = (EcmaError)obj; if (ex.sourceName() != null) { return new LocationImpl(ex.getName(), ex.sourceName(), ex.lineNumber(), ex.columnNumber()); } else { return Location.UNKNOWN; } } else if (obj instanceof JavaScriptException) { JavaScriptException ex = (JavaScriptException)obj; if (ex.sourceName() != null) { return new LocationImpl(description, ex.sourceName(), ex.lineNumber(), -1); } else { return Location.UNKNOWN; } } return null; } };