QValueFactoryImpl(NamePathResolver resolver, ValueLoader loader) { this.loader = loader; vf = new ValueFactoryQImpl(this, resolver); }
/** * {@inheritDoc} */ public Value createValue(Node value) throws RepositoryException { return createValue(value, false); }
/** * Returns the string value of the identified property default value. * * @param def property definition * @param index default value index * @return default value */ private String getDefaultValue(QPropertyDefinition def, int index) { try { QValue[] values = def.getDefaultValues(); NamespaceResolver nsResolver = new AdditionalNamespaceResolver(registry); NamePathResolver resolver = new DefaultNamePathResolver(nsResolver); ValueFactoryQImpl factory = new ValueFactoryQImpl(InternalValueFactory.getInstance(), resolver); return factory.createValue(values[index]).getString(); } catch (RepositoryException e) { throw new AssertionFailedError(e.getMessage()); } }
QValue p = valueFactory.getQValueFactory().create(hmgr.getPath(sn[idx].getNodeId())); return valueFactory.createValue(p); } else if (n.hasProperty(col.getPropertyName())) { Property p = n.getProperty(col.getPropertyName()); } else { if (p.getDefinition().getRequiredType() == PropertyType.UNDEFINED) { return valueFactory.createValue(p.getString()); } else { return p.getValue(); return valueFactory.createValue(Math.round(score * 1000f)); } else if (isExcerptFunction(prop)) { return getExcerpt();
/** * Creates a new repository service based on the given * <code>repository</code>. * * @param repository a JCR repository instance. * @param batchReadConfig * {@link #getNodeInfo(SessionInfo, NodeId)}. */ public RepositoryServiceImpl(Repository repository, BatchReadConfig batchReadConfig, int itemInfoCacheSize) { this.repository = repository; this.batchReadConfig = batchReadConfig; this.supportsObservation = "true".equals(repository.getDescriptor(Repository.OPTION_OBSERVATION_SUPPORTED)); this.itemInfoCacheSize = itemInfoCacheSize; try { Session s = repository.login(new GuestCredentials()); ValueFactory vf = s.getValueFactory(); if (vf instanceof ValueFactoryQImpl) { qValueFactory = ((ValueFactoryQImpl) vf).getQValueFactory(); } } catch (RepositoryException e) { // ignore } }
if (requiredType == PropertyType.BINARY) { Value v = new ValueFactoryQImpl(qValueFactory, resolver).createValue(jcrVal, requiredType); qValue = ValueFormat.getQValue(v, resolver, qValueFactory); } else {
QValue p = valueFactory.getQValueFactory().create(hmgr.getPath(sn[idx].getNodeId())); return valueFactory.createValue(p); } else if (n.hasProperty(col.getPropertyName())) { Property p = n.getProperty(col.getPropertyName()); } else { if (p.getDefinition().getRequiredType() == PropertyType.UNDEFINED) { return valueFactory.createValue(p.getString()); } else { return p.getValue(); return valueFactory.createValue(Math.round(score * 1000f)); } else if (isExcerptFunction(prop)) { return getExcerpt();
/** * Creates a new repository service based on the given * <code>repository</code>. * * @param repository a JCR repository instance. * @param batchReadConfig * {@link #getNodeInfo(SessionInfo, NodeId)}. */ public RepositoryServiceImpl(Repository repository, BatchReadConfig batchReadConfig, int itemInfoCacheSize) { this.repository = repository; this.batchReadConfig = batchReadConfig; this.supportsObservation = "true".equals(repository.getDescriptor(Repository.OPTION_OBSERVATION_SUPPORTED)); this.itemInfoCacheSize = itemInfoCacheSize; try { Session s = repository.login(new GuestCredentials()); ValueFactory vf = s.getValueFactory(); if (vf instanceof ValueFactoryQImpl) { qValueFactory = ((ValueFactoryQImpl) vf).getQValueFactory(); } } catch (RepositoryException e) { // ignore } }
/** * {@inheritDoc} */ public Value createValue(Node value) throws RepositoryException { return createValue(value, false); }
QValueFactoryImpl(NamePathResolver resolver, ValueLoader loader) { this.loader = loader; vf = new ValueFactoryQImpl(this, resolver); }
if (requiredType == PropertyType.BINARY) { Value v = new ValueFactoryQImpl(qValueFactory, resolver).createValue(jcrVal, requiredType); qValue = ValueFormat.getQValue(v, resolver, qValueFactory); } else {
public Value createValue(Binary value) { // TODO review/optimize/refactor try { return createValue(value.getStream()); } catch (RepositoryException ex) { throw new RuntimeException(ex); } }
/** * Write one QNodeTypeDefinition to this writer * * @param ntd node type definition * @throws IOException if an I/O error occurs */ public void write(QNodeTypeDefinition ntd) throws IOException { NodeTypeDefinition def = new NodeTypeDefinitionImpl(ntd, npResolver, new ValueFactoryQImpl(QValueFactoryImpl.getInstance(), npResolver)); super.write(def); }
public Value createValue(Binary value) { // TODO review/optimize/refactor try { return createValue(value.getStream()); } catch (RepositoryException ex) { throw new RuntimeException(ex); } }
/** * Write one QNodeTypeDefinition to this writer * * @param ntd node type definition * @throws IOException if an I/O error occurs */ public void write(QNodeTypeDefinition ntd) throws IOException { NodeTypeDefinition def = new NodeTypeDefinitionImpl(ntd, npResolver, new ValueFactoryQImpl(QValueFactoryImpl.getInstance(), npResolver)); super.write(def); }
/** * Highlights the matching terms in the passed <code>text</code>. * * @param text the text where to apply highlighting. * @return a StringValue or <code>null</code> if highlighting fails. */ private Value highlight(String text) { if (!(excerptProvider instanceof HighlightingExcerptProvider)) { return null; } HighlightingExcerptProvider hep = (HighlightingExcerptProvider) excerptProvider; try { long time = System.currentTimeMillis(); text = hep.highlight(text); time = System.currentTimeMillis() - time; log.debug("Highlighted text in {} ms.", time); return valueFactory.createValue(text); } catch (IOException e) { return null; } }
/** * Creates a jcr Value from the given qvalue using the specified * factory. * @return the jcr value representing the qvalue. */ private Value createJcrValue(QValue qValue) throws RepositoryException { // build ValueFactory ValueFactoryQImpl valueFactory = new ValueFactoryQImpl(qvf, resolver); // build jcr value QValueValue jcrValue = new QValueValue(qValue, resolver); return ValueHelper.copy(jcrValue, valueFactory); } }
/** * Returns the spell checked string of the first relation query node * with a spellcheck operation. * * @return a StringValue or <code>null</code> if the spell checker * thinks the words are spelled correctly. This method also * returns <code>null</code> if no spell checker is configured. */ private Value getSpellCheckedStatement() { String v = null; if (spellSuggestion != null) { try { v = spellSuggestion.getSuggestion(); } catch (IOException e) { log.warn("Spell checking failed", e); } } if (v != null) { return valueFactory.createValue(v); } else { return null; } } }
/** * Creates a jcr Value from the given qvalue using the specified * factory. * @return the jcr value representing the qvalue. */ private Value createJcrValue(QValue qValue) throws RepositoryException { // build ValueFactory ValueFactoryQImpl valueFactory = new ValueFactoryQImpl(qvf, resolver); // build jcr value QValueValue jcrValue = new QValueValue(qValue, resolver); return ValueHelper.copy(jcrValue, valueFactory); } }
/** * Highlights the matching terms in the passed <code>text</code>. * * @param text the text where to apply highlighting. * @return a StringValue or <code>null</code> if highlighting fails. */ private Value highlight(String text) { if (!(excerptProvider instanceof HighlightingExcerptProvider)) { return null; } HighlightingExcerptProvider hep = (HighlightingExcerptProvider) excerptProvider; try { long time = System.currentTimeMillis(); text = hep.highlight(text); time = System.currentTimeMillis() - time; log.debug("Highlighted text in {} ms.", time); return valueFactory.createValue(text); } catch (IOException e) { return null; } }