it.tidalwave.util.Key类的使用及代码示例

x33g5p2x  于2022-01-23 转载在 其他  
字(12.6k)|赞(0)|评价(0)|浏览(149)

本文整理了Java中it.tidalwave.util.Key类的一些代码示例,展示了Key类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Key类的具体详情如下:
包路径:it.tidalwave.util.Key
类名称:Key

Key介绍

暂无

代码示例

代码示例来源:origin: it.tidalwave.northernwind/it-tidalwave-northernwind-core-default

@Override @Nonnull
 protected String filter (final @Nonnull Matcher matcher)
  {
   try
    {
     final String propertyName = matcher.group(1);
     return context.get().getNodeProperties().getProperty(new Key<String>(propertyName), "");
    }
   catch (IOException e)
    {
     return "ERR";
    }
  }
}

代码示例来源:origin: it.tidalwave.northernwind/it-tidalwave-northernwind-core-default

final String s = entry.getKey().stringValue();
final Object value = entry.getValue();
  propertyMap.put(new Key<>(s), value);
  otherMap.put(new Key<>(x[1]), value);

代码示例来源:origin: it.tidalwave.bluebill/it-tidalwave-bluebill-observation-simple-rdf

@Override @Nonnull
 public void marshal (final @Nonnull As entity, final @Nonnull Context context)
  {
   try
    {
     super.marshal(entity, context);
     final Media media = (Media)entity;
     final Set<Key<?>> keys = new HashSet<Key<?>>(media.getKeys());
     keys.remove(Media.ID);
     context.addStatement(media, Vocabulary.RDF_TYPE, Media.FOAF_DOCUMENT);
     for (final Key<?> key : keys)
      {
       if (!key.equals(Media.MIME_TYPE) && !key.equals(Media.DURATION))
        {
         context.addStatement(media, new Id(key.stringValue()), media.get(key));
        }
      }
    }
   catch (NotFoundException e)
    {
     throw new RuntimeException(e);
    }
  }
}

代码示例来源:origin: it.tidalwave.northernwind/it-tidalwave-northernwind-frontend-core

/*******************************************************************************************************************
 *
 * {@inheritDoc}
 *
 ******************************************************************************************************************/
@Override @Nonnull
public <Type> Type getProperty (@Nonnull Key<Type> key)
 throws NotFoundException, IOException
 {
  try
   { 
    return properties.get(key);
   }
  catch (NotFoundException e)
   {
    return (Type)getFileBasedProperty(key.stringValue());
   }
 }

代码示例来源:origin: it.tidalwave.bluebill/it-tidalwave-bluebill-mobile-commons

if (key.equals(Media.RIGHTS))

代码示例来源:origin: it.tidalwave.northernwind.rca/it-tidalwave-northernwind-rca-model

/*******************************************************************************************************************
   *
   * {@inheritDoc}
   *
   ******************************************************************************************************************/
  @Override @SuppressWarnings("unchecked")
  public <Type> Type resolveProperty (final @Nonnull Id propertyGroupId, final @Nonnull Key<Type> propertyName)
   throws NotFoundException, IOException
   {
    log.trace("resolveProperty({})", propertyName);

    final ResourceFile propertyFile = findLocalizedFile(propertyName.stringValue());
    log.trace(">>>> reading from {}", propertyFile.getPath());
    final String mimeType = propertyFile.getMimeType();
    final String charset = mimeType.equals("application/xhtml+xml") ? "UTF-8" : Charset.defaultCharset().name();

    try
     {
//            return (Type)filterSetExpander.get().filter(propertyFile.asText(charset), mimeType);
      return (Type)propertyFile.asText(charset);
     }
    catch (RuntimeException e) // FIXME: introduce a FilterException
     {
      throw new IOException(e);
     }
   }

代码示例来源:origin: it.tidalwave.bluebill.android/it-tidalwave-mobile-utilities

public <T> Media with (final @Nonnull Key<T> key, final @Nonnull T value)
  if (key.equals(FORMAT))
      if (k.equals(MIME_TYPE))

代码示例来源:origin: it.tidalwave.northernwind/it-tidalwave-northernwind-core-default

@Override @Nonnull
 protected String filter (final @Nonnull Matcher matcher)
  {
   try
    {
     final String propertyName = matcher.group(1);
     return requestContext.get().getContentProperties().getProperty(new Key<String>(propertyName), "");
    }
   catch (IOException e)
    {
     return "ERR";
    }
  }
}

代码示例来源:origin: it.tidalwave.northernwind/it-tidalwave-northernwind-core-default

final Key<String> propertyKey = new Key<>(propertyName);
log.trace(">>>>>>>> setting property {} = {}", propertyKey.stringValue(), e.getValue());
when(properties.getProperty(eq(propertyKey))).thenReturn(e.getValue());
when(properties.getProperty(eq(propertyKey), anyString())).thenReturn(e.getValue());

代码示例来源:origin: it.tidalwave.northernwind/it-tidalwave-northernwind-core-default

/*******************************************************************************************************************
 *
 * {@inheritDoc}
 *
 ******************************************************************************************************************/
@Override @SuppressWarnings("unchecked")
public <Type> Type resolveProperty (final @Nonnull Id propertyGroupId, final @Nonnull Key<Type> propertyName)
 throws NotFoundException, IOException
 {
  log.trace("resolveProperty({})", propertyName);
  final ResourceFile propertyFile = findLocalizedFile(propertyName.stringValue());
  log.trace(">>>> reading from {}", propertyFile.getPath());
  final String mimeType = propertyFile.getMimeType();
  final String charset = mimeType.equals("application/xhtml+xml") ? "UTF-8" : Charset.defaultCharset().name();
  try
   {
    return (Type)filterSetExpander.get().filter(propertyFile.asText(charset), mimeType);
   }
  catch (RuntimeException e) // FIXME: introduce a FilterException
   {
    throw new IOException(e);
   }
 }

代码示例来源:origin: it.tidalwave.northernwind/it-tidalwave-northernwind-frontend-core

/*******************************************************************************************************************
  *
  *
  ******************************************************************************************************************/
 @PostConstruct
 private void loadProperties()
  throws IOException
  {
   log.trace("loadProperties() for /{}", file.getPath());
       
   final Map<Key<?>, Object> map = new HashMap<Key<?>, Object>();
   for (final FileObject propertyFile : Utilities.getInheritedPropertyFiles(file, "Resource_en.properties"))
    {
     log.trace(">>>> reading properties from /{}...", propertyFile.getPath());
     @Cleanup final Reader r = new InputStreamReader(propertyFile.getInputStream());
     final Properties tempProperties = new Properties();
     tempProperties.load(r);
     log.trace(">>>> local properties: {}", tempProperties);
     r.close();        
     
     for (final Entry<Object, Object> entry : tempProperties.entrySet())
      {
       map.put(new Key<Object>(entry.getKey().toString()), entry.getValue());
      }
    }
   properties = new TypeSafeHashMap(map);
   log.debug(">>>> properties for /{}: {}", file.getPath(), properties);
  }
}

代码示例来源:origin: it.tidalwave.bluebill/it-tidalwave-bluebill-factsheet-bbc

final Key<Object> key = new Key<Object>(predicate);
factSheet = factSheet.with(key, context.find(object));
final Key<Object> key = new Key<Object>(predicate);
factSheet = factSheet.with(key, context.find(object));
 || predicate.startsWith(NS_DC_TERMS))
final Key<Object> key = new Key<Object>(predicate);
factSheet = factSheet.with(key, deserialize(object));
   && !predicate.equals(RDFS_LABEL.stringValue()))

代码示例来源:origin: it.tidalwave.bluebill/it-tidalwave-bluebill-observation-simple-rdf

@Override @Nonnull
 public As unmarshal (final @Nonnull List<Statement> statements, final @Nonnull Context context)
  {
   Media media = new Media().with(Media.ID, Converter.valueToId(statements.get(0).getSubject()));
   final String format = (String)getLiteral(statements, new Id(Media.FORMAT.stringValue()));
   if (format != null)
    {
     media = media.with(Media.FORMAT, format);
    }
   
   final String rights = (String)getLiteral(statements, new Id(Media.RIGHTS.stringValue()));
   if (rights != null)
    {
     media = media.with(Media.RIGHTS, rights);
    }
   return media;
  }
}

代码示例来源:origin: it.tidalwave.northernwind/it-tidalwave-northernwind-core-default

@Override @Nonnull
 protected String filter (final @Nonnull Matcher matcher)
  {
   try
    {
     // FIXME: should be pushed into @PostConstruct, but can't - see NW-224
     final Site site = siteProvider.get().getSite();
     final SiteNode rootSiteNode = site.find(SiteNode).withRelativeUri("/").result(); // See NW-223
     // END FIXME
     final String propertyName = matcher.group(1);
     return rootSiteNode.getProperties().getProperty(new Key<String>(propertyName), "");
    }
   catch (NotFoundException | IOException e)
    {
     return "ERR";
    }
  }
}

代码示例来源:origin: it.tidalwave.northernwind/it-tidalwave-northernwind-core-default

@Override
public void setUp (final @Nonnull ResourceFileSystem fileSystem,
          final @Nonnull Map<String, String> resourceProperties)
 {
  super.setUp(fileSystem, resourceProperties);
  // FIXME: this is flat, create some hierarchy
  createMockFolder(fileSystem, documentFolder, "document1");
  createMockFolder(fileSystem, documentFolder, "document2");
  createMockFolder(fileSystem, documentFolder, "document3");
  createMockFolder(fileSystem, nodeFolder, "node1");
  createMockFolder(fileSystem, nodeFolder, "node2");
  createMockFolder(fileSystem, nodeFolder, "node3");
  resourceProperties.put("/structure/node3." + SiteNode.PROPERTY_MANAGES_PATH_PARAMS.stringValue(), "true");
  createMockFolder(fileSystem, nodeFolder, "node4");
  createMockFile(fileSystem, mediaFolder, "media1");
  createMockFile(fileSystem, mediaFolder, "media2");
  createMockFile(fileSystem, mediaFolder, "media3");
  createMockFile(fileSystem, mediaFolder, "ignored1");
  createMockFile(fileSystem, libraryFolder, "library1");
  createMockFile(fileSystem, libraryFolder, "library2");
  createMockFile(fileSystem, libraryFolder, "ignored2");
 }

代码示例来源:origin: it.tidalwave.bluebill/it-tidalwave-bluebill-factsheet-bbc

@Nonnull
 public As unmarshal (final @Nonnull List<Statement> statements, final @Nonnull Context context)
  {
   final Id id = findId(statements, context);
   Biblio biblio = new Biblio(id);
   for (final Statement statement : statements)
    {
     final String predicate = statement.getPredicate().stringValue();
     if (predicate.startsWith(NS_DC_TERMS))
      {
       final Key<Object> key = new Key<Object>(predicate);
       biblio = biblio.with(key, deserialize(statement.getObject()));
      }
     else if (!predicate.equals(TYPE_RDF_TYPE.stringValue())
          && !predicate.equals(ID_FOAF_PRIMARY_TOPIC.stringValue()))
      {
       System.err.println("BIBLIO Unused statement: " + statement);
      }
    }
   return biblio;
  }
}

代码示例来源:origin: it.tidalwave.bluebill/it-tidalwave-bluebill-taxonomy-mobile

document = document.with(new Key<Object>(predicate), object.stringValue());

代码示例来源:origin: it.tidalwave.bluebill/it-tidalwave-bluebill-factsheet-bbc

@Nonnull
 public As unmarshal (final @Nonnull List<Statement> statements, final @Nonnull Context context)
  {
   final Id id = findId(statements, context);
   Media movie = new Media().with(Media.ID, id).with(DC_RIGHTS, BBC_SYNDICATION_GUIDELINES);
   for (final Statement statement : statements)
    {
     final String predicate = statement.getPredicate().stringValue();
     if (predicate.startsWith(NS_DC_TERMS))
      {
       final Key<Object> key = new Key<Object>(predicate);
       movie = movie.with(key, deserialize(statement.getObject()));
      }
     else if (!predicate.equals(TYPE_RDF_TYPE.stringValue())
          && !predicate.equals(BbcVocabulary.ID_PO_SUBJECT.stringValue()))
      {
       System.err.println("MOVIE Unused statement: " + statement);
      }
    }
   return movie;
  }
}

代码示例来源:origin: it.tidalwave.bluebill/it-tidalwave-bluebill-factsheet

@Override @Nonnull
 public As unmarshal (final @Nonnull List<Statement> statements, final @Nonnull Context context)
  {
   final Id id = new Id(statements.get(0).getSubject().stringValue());
   Media media = new Media().with(Media.ID, id);
   for (final Statement statement : statements)
    {
     final Value object = statement.getObject();
     final Id predicate = new Id(statement.getPredicate().stringValue());
     final Key<Object> key = new Key<Object>(predicate);
     if (PREDICATES_REFERRING_ENTITIES.contains(predicate))
      {
       media = media.with(key, context.find(object));
      }
     else if (PREDICATES_REFERRING_IDS.contains(predicate))
      {
       media = media.with(key, new Id(object.stringValue()));
      }
     else if (object instanceof Literal)
      {
       media = media.with(key, object.stringValue());
      }
    }
   return media;
  }
}

代码示例来源:origin: it.tidalwave.northernwind/it-tidalwave-northernwind-frontend-components

/*******************************************************************************************************************
 *
 * {@inheritDoc}
 *
 ******************************************************************************************************************/
@Nonnull
protected String loadTemplate (final @Nonnull GalleryAdapterContext context, final @Nonnull String templateName)
 throws IOException
 {
  try
   {
    final SiteNode siteNode = context.getSiteNode();
    final GalleryView view = context.getView();
    final Site site = context.getSite();
    final ResourceProperties viewProperties = siteNode.getPropertyGroup(view.getId());
    final String templateRelativePath = viewProperties.getProperty(new Key<String>(templateName + "Path"));
    final Content template = site.find(Content).withRelativePath(templateRelativePath).result();
    return template.getProperties().getProperty(PROPERTY_TEMPLATE);
   }
  catch (NotFoundException e)
   {
    return loadDefaultTemplate(templateName + ".txt");
   }
 }

相关文章

微信公众号

最新文章

更多