List of usage examples for org.xml.sax Locator getSystemId
public abstract String getSystemId();
From source file:net.ontopia.topicmaps.webed.impl.utils.TagUtils.java
public static Map getSchemaRegistry(ServletContext servletContext) { Map schemas = (Map) servletContext.getAttribute(Constants.AA_SCHEMAS); if (schemas != null) return schemas; // Read in schemas for the topicmaps and provide them to the app context String schemasRootDir = servletContext.getInitParameter(Constants.SCTXT_SCHEMAS_ROOTDIR); if (schemasRootDir != null) schemasRootDir = servletContext.getRealPath(schemasRootDir); schemas = new HashMap(); if (schemasRootDir == null) { servletContext.setAttribute(Constants.AA_SCHEMAS, schemas); log.debug("No schema directory configured; registry empty"); return schemas; }// w ww . j a va 2s . c o m log.debug("Reading schemas from " + schemasRootDir); TopicMapRepositoryIF repository = NavigatorUtils.getTopicMapRepository(servletContext); Collection refkeys = repository.getReferenceKeys(); Iterator iter = refkeys.iterator(); while (iter.hasNext()) { String refkey = (String) iter.next(); TopicMapReferenceIF reference = repository.getReferenceByKey(refkey); String tmid = reference.getId(); try { OSLSchemaReader reader = new OSLSchemaReader(new File(schemasRootDir, tmid + ".osl")); OSLSchema schema = (OSLSchema) reader.read(); schemas.put(tmid, schema); log.info("Loaded schema for " + tmid); } catch (java.io.IOException e) { log.info("Warning: " + e.getMessage()); } catch (SchemaSyntaxException e) { log.error("Schema syntax error: " + e.getMessage()); Locator loc = e.getErrorLocation(); log.error("Location: " + loc.getSystemId() + ":" + loc.getLineNumber() + ":" + loc.getColumnNumber() + "."); } } servletContext.setAttribute(Constants.AA_SCHEMAS, schemas); return schemas; }
From source file:com.netspective.axiom.schema.transport.DataException.java
public DataException(Locator locator, Throwable cause) { super(locator.getSystemId() + " at " + locator.getLineNumber(), cause); }
From source file:MyContentHandler.java
public void setDocumentLocator(Locator locator) { this.locator = locator; System.out.println("-" + locator.getLineNumber() + "---Document ID: " + locator.getSystemId()); }
From source file:Main.java
/** * The name and of the SAX document and the current location within the * document./*from ww w .j a va2 s . c o m*/ */ public void setDocumentLocator(Locator locator) { this.locator = locator; System.out.println("-" + locator.getLineNumber() + "---Document ID: " + locator.getSystemId()); }
From source file:com.sun.faces.config.rules.ManagedBeanRule.java
/** * <p>Provides simple sanity checks.</p> * * @param bean the <code>ManagedBeanBean</code> instance to validate */// w ww . j a va 2s . c om private void validate(ManagedBeanBean bean) { String val = bean.getManagedBeanName(); if (val == null || val.length() == 0) { Locator locator = digester.getDocumentLocator(); String documentName = "UNKNOWN"; String lineNumber = "UNKNWOWN"; if (locator != null) { documentName = locator.getSystemId(); lineNumber = Integer.toString(locator.getLineNumber()); } throw new IllegalStateException(ToolsUtil.getMessage(ToolsUtil.MANAGED_BEAN_NO_MANAGED_BEAN_NAME_ID, new Object[] { documentName, lineNumber })); } val = bean.getManagedBeanClass(); if (val == null || val.length() == 0) { throw new IllegalStateException(ToolsUtil.getMessage(ToolsUtil.MANAGED_BEAN_NO_MANAGED_BEAN_CLASS_ID, new Object[] { bean.getManagedBeanName() })); } val = bean.getManagedBeanScope(); if (val == null || val.length() == 0) { throw new IllegalStateException(ToolsUtil.getMessage(ToolsUtil.MANAGED_BEAN_NO_MANAGED_BEAN_SCOPE_ID, new Object[] { bean.getManagedBeanName() })); } if (Arrays.binarySearch(SCOPES, val) < 0) { throw new IllegalStateException(ToolsUtil.getMessage(ToolsUtil.MANAGED_BEAN_INVALID_SCOPE_ID, new Object[] { val, bean.getManagedBeanName() })); } // - if the managed bean is itself a List, make sure it has no // map entries or managed properties // - if the managed bean is itself a Map, make sure it has no // managed properties if (bean.getListEntries() != null) { if (bean.getMapEntries() != null || bean.getManagedProperties().length != 0) { throw new IllegalStateException(ToolsUtil.getMessage(ToolsUtil.MANAGED_BEAN_AS_LIST_CONFIG_ERROR_ID, new Object[] { bean.getManagedBeanName() })); } } else if (bean.getMapEntries() != null) { if (bean.getManagedProperties().length != 0) { throw new IllegalStateException(ToolsUtil.getMessage(ToolsUtil.MANAGED_BEAN_AS_MAP_CONFIG_ERROR_ID, new Object[] { bean.getManagedBeanName() })); } } }
From source file:TypeInfoWriter.java
/** Set document locator. */ public void setDocumentLocator(Locator locator) { fIndent = 0;//from w w w . jav a 2s. c o m printIndent(); fOut.print("setDocumentLocator("); fOut.print("systemId="); printQuotedString(locator.getSystemId()); fOut.print(", publicId="); printQuotedString(locator.getPublicId()); fOut.println(')'); fOut.flush(); }
From source file:org.apache.cocoon.transformation.LDAPTransformer.java
/** BEGIN SAX ContentHandler handlers */ public void setDocumentLocator(Locator locator) { if (getLogger().isDebugEnabled()) { getLogger().debug("PUBLIC ID: " + locator.getPublicId()); getLogger().debug("SYSTEM ID: " + locator.getSystemId()); }//from w ww .ja v a 2 s .co m if (super.contentHandler != null) super.contentHandler.setDocumentLocator(locator); }
From source file:org.apache.openjpa.persistence.XMLPersistenceMetaDataParser.java
@Override protected boolean startClass(String elem, Attributes attrs) throws SAXException { boolean metaDataComplete = false; super.startClass(elem, attrs); if (isMetaDataComplete(attrs)) { metaDataComplete = true;/*from w w w.ja v a 2s . c o m*/ setAnnotationParser(null); } else if (!_isXMLMappingMetaDataComplete) { resetAnnotationParser(); } // query mode only? _cls = classForName(currentClassName()); // Prevent a reentrant parse for the same class if (parseListContains(_cls)) { return false; } if (_mode == MODE_QUERY) { if (_conf.getCompatibilityInstance().getParseAnnotationsForQueryMode()) { if (_parser != null) { _parser.parse(_cls); } } return true; } Log log = getLog(); if (log.isTraceEnabled()) log.trace(_loc.get("parse-class", _cls.getName())); MetaDataRepository repos = getRepository(); ClassMetaData meta = repos.getCachedMetaData(_cls); if (meta != null && ((isMetaDataMode() && (meta.getSourceMode() & MODE_META) != 0) || (isMappingMode() && (meta.getSourceMode() & MODE_MAPPING) != 0))) { if (isDuplicateClass(meta)) { if (log.isWarnEnabled()) { log.warn(_loc.get("dup-metadata", _cls, getSourceName())); } if (log.isTraceEnabled()) { log.trace(String.format( "MetaData originally obtained from source: %s under mode: %d with scope: %s, and type: %d", meta.getSourceName(), meta.getSourceMode(), meta.getSourceScope(), meta.getSourceType())); } } _cls = null; return false; } int access = AccessCode.UNKNOWN; if (meta == null) { int accessCode = toAccessType(attrs.getValue("access")); // if access not specified and access was specified at // the system level, use the system default (which may // be UNKNOWN) if (accessCode == AccessCode.UNKNOWN) accessCode = _access; meta = repos.addMetaData(_cls, accessCode, metaDataComplete); FieldMetaData[] fmds = meta.getFields(); if (metaDataComplete) { for (int i = 0; i < fmds.length; i++) { fmds[i].setExplicit(true); } } meta.setEnvClassLoader(_envLoader); meta.setSourceMode(MODE_NONE); // parse annotations first so XML overrides them if (_parser != null) { _parser.parse(_cls); } } access = meta.getAccessType(); boolean mappedSuper = "mapped-superclass".equals(elem); boolean embeddable = "embeddable".equals(elem); if (isMetaDataMode()) { Locator locator = getLocation().getLocator(); meta.setSource(getSourceFile(), SourceTracker.SRC_XML, locator != null ? locator.getSystemId() : ""); meta.setSourceMode(MODE_META, true); if (locator != null) { meta.setLineNumber(locator.getLineNumber()); meta.setColNumber(locator.getColumnNumber()); } meta.setListingIndex(_clsPos); String name = attrs.getValue("name"); if (!StringUtils.isEmpty(name)) meta.setTypeAlias(name); meta.setAbstract(mappedSuper); meta.setEmbeddedOnly(mappedSuper || embeddable); if (embeddable) { meta.setEmbeddable(); setDeferredEmbeddableAccessType(_cls, access); } } if (attrs.getValue("cacheable") != null) { meta.setCacheEnabled(Boolean.valueOf(attrs.getValue("cacheable"))); } if (isMappingMode()) meta.setSourceMode(MODE_MAPPING, true); if (isMappingOverrideMode()) startClassMapping(meta, mappedSuper, attrs); if (isQueryMode()) meta.setSourceMode(MODE_QUERY, true); _clsPos++; _fieldPos = 0; addComments(meta); pushElement(meta); return true; }
From source file:org.apache.openjpa.persistence.XMLPersistenceMetaDataParser.java
/** * Parse named-query.//from ww w.j av a 2s . c o m */ protected boolean startNamedQuery(Attributes attrs) throws SAXException { if (!isQueryMode()) return false; String name = attrs.getValue("name"); Log log = getLog(); if (log.isTraceEnabled()) log.trace(_loc.get("parse-query", name)); QueryMetaData meta = new QueryMetaData(_cls, name, JPQLParser.LANG_JPQL); meta.setQueryString(attrs.getValue("query")); String lockModeStr = attrs.getValue("lock-mode"); LockModeType lmt = processNamedQueryLockModeType(log, lockModeStr, name); if (lmt != null && lmt != LockModeType.NONE) { meta.addHint("openjpa.FetchPlan.ReadLockMode", lmt); } Locator locator = getLocation().getLocator(); if (locator != null) { meta.setLineNumber(locator.getLineNumber()); meta.setColNumber(locator.getColumnNumber()); } Object cur = currentElement(); Object scope = (cur instanceof ClassMetaData) ? ((ClassMetaData) cur).getDescribedType() : null; meta.setSource(getSourceFile(), scope, SourceTracker.SRC_XML, locator == null ? "" : locator.getSystemId()); if (isMetaDataMode()) meta.setSourceMode(MODE_META); else if (isMappingMode()) meta.setSourceMode(MODE_MAPPING); else meta.setSourceMode(MODE_QUERY); addQueryMetaData(cur, meta); pushElement(meta); return true; }
From source file:org.apache.openjpa.persistence.XMLPersistenceMetaDataParser.java
/** * Parse native-named-query.//from w w w . j ava 2s .c om */ protected boolean startNamedNativeQuery(Attributes attrs) throws SAXException { if (!isQueryMode()) return false; String name = attrs.getValue("name"); Log log = getLog(); if (log.isTraceEnabled()) log.trace(_loc.get("parse-native-query", name)); QueryMetaData meta = getRepository().getCachedQueryMetaData(name); if (meta != null && isDuplicateQuery(meta)) { log.warn(_loc.get("override-query", name, currentLocation())); } meta = new QueryMetaData(_cls, name, QueryLanguages.LANG_SQL); getRepository().addQueryMetaData(meta); meta.setQueryString(attrs.getValue("query")); String val = attrs.getValue("result-class"); if (val != null) { Class<?> type = classForName(val); if (ImplHelper.isManagedType(getConfiguration(), type)) meta.setCandidateType(type); else meta.setResultType(type); } val = attrs.getValue("result-set-mapping"); if (val != null) meta.setResultSetMappingName(val); Object cur = currentElement(); Object scope = (cur instanceof ClassMetaData) ? ((ClassMetaData) cur).getDescribedType() : null; Locator locator = getLocation().getLocator(); meta.setSource(getSourceFile(), scope, SourceTracker.SRC_XML, locator == null ? "" : locator.getSystemId()); if (locator != null) { meta.setLineNumber(locator.getLineNumber()); meta.setColNumber(locator.getColumnNumber()); } if (isMetaDataMode()) meta.setSourceMode(MODE_META); else if (isMappingMode()) meta.setSourceMode(MODE_MAPPING); else meta.setSourceMode(MODE_QUERY); pushElement(meta); return true; }