本文整理汇总了Java中org.datacleaner.api.Renderer类的典型用法代码示例。如果您正苦于以下问题:Java Renderer类的具体用法?Java Renderer怎么用?Java Renderer使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Renderer类属于org.datacleaner.api包,在下文中一共展示了Renderer类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testGetRendererByHierarchyDistance
import org.datacleaner.api.Renderer; //导入依赖的package包/类
public void testGetRendererByHierarchyDistance() throws Exception {
final ClasspathScanDescriptorProvider descriptorProvider =
new ClasspathScanDescriptorProvider().scanPackage("org.datacleaner.result.renderer", true);
final RendererFactory rendererFactory = new RendererFactory(new DataCleanerConfigurationImpl()
.withEnvironment(new DataCleanerEnvironmentImpl().withDescriptorProvider(descriptorProvider)));
Renderer<?, ? extends CharSequence> renderer;
renderer = rendererFactory.getRenderer(new NumberResult(1), TextRenderingFormat.class);
assertEquals(ToStringTextRenderer.class, renderer.getClass());
renderer = rendererFactory.getRenderer(new CrosstabResult(null), TextRenderingFormat.class);
assertEquals(CrosstabTextRenderer.class, renderer.getClass());
renderer = rendererFactory.getRenderer(new DataSetResult(new LinkedList<>()), TextRenderingFormat.class);
assertEquals(MetricBasedResultTextRenderer.class, renderer.getClass());
}
示例2: showConfigurationDialog
import org.datacleaner.api.Renderer; //导入依赖的package包/类
public void showConfigurationDialog(final ComponentBuilder componentBuilder) {
final ComponentConfigurationDialog existingDialog = _componentConfigurationDialogs.get(componentBuilder);
if (existingDialog != null) {
existingDialog.toFront();
return;
}
@SuppressWarnings("unchecked") final Renderer<ComponentBuilder, ? extends ComponentBuilderPresenter> renderer =
(Renderer<ComponentBuilder, ? extends ComponentBuilderPresenter>) _presenterRendererFactory
.getRenderer(componentBuilder, ComponentBuilderPresenterRenderingFormat.class);
if (renderer != null) {
final ComponentConfigurationDialog dialog =
new ComponentConfigurationDialog(_windowContext, componentBuilder, renderer);
dialog.addWindowListener(new WindowAdapter() {
@Override
public void windowClosed(final WindowEvent e) {
_componentConfigurationDialogs.remove(componentBuilder);
_graphContext.getJobGraph().refresh();
}
});
_componentConfigurationDialogs.put(componentBuilder, dialog);
dialog.open();
}
}
示例3: testClasspathDiscovery
import org.datacleaner.api.Renderer; //导入依赖的package包/类
@Test
public void testClasspathDiscovery() {
final DescriptorProvider descriptorProvider =
new ClasspathScanDescriptorProvider().scanPackage("org.datacleaner.beans", true);
final Collection<RendererBeanDescriptor<?>> htmlRenderers =
descriptorProvider.getRendererBeanDescriptorsForRenderingFormat(HtmlRenderingFormat.class);
final TreeSet<RendererBeanDescriptor<?>> sorted = new TreeSet<>(htmlRenderers);
Assert.assertEquals(
"[AnnotationBasedRendererBeanDescriptor[org.datacleaner.beans.DefaultAnalyzerResultHtmlRenderer], "
+ "AnnotationBasedRendererBeanDescriptor[org.datacleaner.beans.writers.WriteDataResultHtmlRenderer]]",
sorted.toString());
final DataCleanerConfiguration conf = new DataCleanerConfigurationImpl()
.withEnvironment(new DataCleanerEnvironmentImpl().withDescriptorProvider(descriptorProvider));
final RendererFactory rendererFactory = new RendererFactory(conf);
final Renderer<? super WriteDataResultImpl, ? extends HtmlFragment> renderer = rendererFactory
.getRenderer(new WriteDataResultImpl(2, 3, "datastore", "schema", "table"), HtmlRenderingFormat.class);
Assert.assertEquals(WriteDataResultHtmlRenderer.class, renderer.getClass());
}
示例4: isRenderer
import org.datacleaner.api.Renderer; //导入依赖的package包/类
public boolean isRenderer() {
if (_beanClazz != null) {
return ReflectionUtils.isAnnotationPresent(_beanClazz, RendererBean.class)
&& ReflectionUtils.is(_beanClazz, Renderer.class);
}
return false;
}
示例5: setRendererClassNames
import org.datacleaner.api.Renderer; //导入依赖的package包/类
public void setRendererClassNames(final Collection<String> classNames) throws ClassNotFoundException {
for (final String className : classNames) {
@SuppressWarnings("unchecked") final Class<? extends Renderer<?, ?>> c =
(Class<? extends Renderer<?, ?>>) Class.forName(className);
final RendererBeanDescriptor<?> descriptor = getRendererBeanDescriptorForClass(c);
if (descriptor == null || !_rendererBeanDescriptors.contains(descriptor)) {
addRendererBeanDescriptor(Descriptors.ofRenderer(c));
}
}
}
示例6: getRendererBeanDescriptorForClass
import org.datacleaner.api.Renderer; //导入依赖的package包/类
@Override
public final <R extends Renderer<?, ?>> RendererBeanDescriptor<R> getRendererBeanDescriptorForClass(
final Class<R> rendererBeanClass) {
for (final RendererBeanDescriptor<?> descriptor : getRendererBeanDescriptors()) {
if (descriptor.getComponentClass() == rendererBeanClass) {
@SuppressWarnings("unchecked") final RendererBeanDescriptor<R> result =
(RendererBeanDescriptor<R>) descriptor;
return result;
}
}
return notFoundRenderer(rendererBeanClass);
}
示例7: AnnotationBasedRendererBeanDescriptor
import org.datacleaner.api.Renderer; //导入依赖的package包/类
protected AnnotationBasedRendererBeanDescriptor(final Class<R> rendererClass) throws DescriptorException {
super(rendererClass, true);
final RendererBean rendererBeanAnnotation = ReflectionUtils.getAnnotation(rendererClass, RendererBean.class);
if (rendererBeanAnnotation == null) {
throw new DescriptorException(rendererClass + " doesn't implement the RendererBean annotation");
}
_renderingFormat = rendererBeanAnnotation.value();
if (_renderingFormat == null || _renderingFormat.isInterface() || Modifier
.isAbstract(_renderingFormat.getModifiers())) {
throw new DescriptorException("Rendering format (" + _renderingFormat + ") is not a non-abstract class");
}
_formatOutputType = ReflectionUtils.getTypeParameter(_renderingFormat, RenderingFormat.class, 0);
logger.debug("Found format output type: {}", _formatOutputType);
if (_formatOutputType == null) {
throw new DescriptorException("Could not determine output type of rendering format: " + _renderingFormat);
}
@SuppressWarnings("unchecked") final Class<? extends Renderable> rendererInputType =
(Class<? extends Renderable>) ReflectionUtils.getTypeParameter(rendererClass, Renderer.class, 0);
_rendererInputType = rendererInputType;
logger.debug("Found renderer input type: {}", _rendererInputType);
_rendererOutputType = ReflectionUtils.getTypeParameter(rendererClass, Renderer.class, 1);
logger.debug("Found renderer output type: {}", _rendererOutputType);
if (_rendererOutputType == null) {
throw new DescriptorException("Could not determine output type of renderer: " + rendererClass);
}
if (!ReflectionUtils.is(_rendererOutputType, _formatOutputType)) {
throw new DescriptorException("The renderer output type (" + _rendererOutputType
+ ") is not a valid instance or sub-class of format output type (" + _formatOutputType + ")");
}
}
示例8: addRendererClass
import org.datacleaner.api.Renderer; //导入依赖的package包/类
public ClasspathScanDescriptorProvider addRendererClass(final Class<? extends Renderer<?, ?>> clazz) {
RendererBeanDescriptor<?> descriptor = _rendererBeanDescriptors.get(clazz.getName());
if (descriptor == null) {
try {
descriptor = Descriptors.ofRenderer(clazz);
_rendererBeanDescriptors.put(clazz.getName(), descriptor);
} catch (Exception | NoClassDefFoundError e) {
logger.error("Unexpected error occurred while creating descriptor for: " + clazz, e);
}
}
return this;
}
示例9: getRendererBeanDescriptorForClass
import org.datacleaner.api.Renderer; //导入依赖的package包/类
@Override
public <R extends Renderer<?, ?>> RendererBeanDescriptor<R> getRendererBeanDescriptorForClass(
final Class<R> rendererBeanClass) {
for (final DescriptorProvider provider : delegates) {
final RendererBeanDescriptor<R> descriptor = provider.getRendererBeanDescriptorForClass(rendererBeanClass);
if (descriptor != null) {
return descriptor;
}
}
return null;
}
示例10: initialize
import org.datacleaner.api.Renderer; //导入依赖的package包/类
@Override
public void initialize(final RendererBeanDescriptor<?> descriptor, final Renderer<?, ?> renderer) {
final Set<ProvidedPropertyDescriptor> providedProperties = descriptor.getProvidedProperties();
for (final ProvidedPropertyDescriptor providedPropertyDescriptor : providedProperties) {
final InjectionPoint<?> injectionPoint = new PropertyInjectionPoint(providedPropertyDescriptor, renderer);
final Object value = _injectionManager.getInstance(injectionPoint);
providedPropertyDescriptor.setValue(renderer, value);
}
}
示例11: getRenderer
import org.datacleaner.api.Renderer; //导入依赖的package包/类
/**
* Gets the best suited {@link Renderer} for the given {@link Renderable} to
* the given {@link RenderingFormat}.
*
* @param <I>
* @param <O>
* @param renderable
* @param renderingFormat
* @return
*/
public <I extends Renderable, O> Renderer<? super I, ? extends O> getRenderer(final I renderable,
final Class<? extends RenderingFormat<? extends O>> renderingFormat) {
RendererSelection bestMatch = null;
final Collection<RendererBeanDescriptor<?>> descriptors =
_descriptorProvider.getRendererBeanDescriptorsForRenderingFormat(renderingFormat);
for (final RendererBeanDescriptor<?> descriptor : descriptors) {
final RendererSelection rendererMatch = isRendererMatch(descriptor, renderable, bestMatch);
if (rendererMatch != null) {
bestMatch = rendererMatch;
}
}
if (bestMatch == null) {
logger.warn("Didn't find any matches for renderable {} (format={})", renderable, renderingFormat);
return null;
}
@SuppressWarnings("unchecked") final Renderer<? super I, ? extends O> renderer =
(Renderer<? super I, ? extends O>) bestMatch.getRenderer();
if (logger.isInfoEnabled()) {
logger.info("Returning renderer '{}' for renderable '{}' in format '{}'",
new Object[] { renderer, renderable.getClass().getName(), renderingFormat.getName() });
}
return renderer;
}
示例12: isRendererCapable
import org.datacleaner.api.Renderer; //导入依赖的package包/类
private RendererSelection isRendererCapable(final RendererBeanDescriptor<?> rendererDescriptor,
final Renderable renderable, final RendererSelection bestMatch) {
final Renderer<Renderable, ?> renderer = instantiate(rendererDescriptor);
if (_rendererInitializer != null) {
_rendererInitializer.initialize(rendererDescriptor, renderer);
}
RendererPrecedence precedence;
try {
precedence = renderer.getPrecedence(renderable);
if (precedence == null) {
logger.debug("Renderer precedence was null for {}, using MEDIUM", renderer);
precedence = RendererPrecedence.MEDIUM;
}
if (precedence == RendererPrecedence.NOT_CAPABLE) {
logger.debug("Renderer is not capable of rendering this renderable!");
return null;
}
if (bestMatch != null) {
final RendererPrecedence bestPrecedence = bestMatch.getPrecedence();
if (precedence.ordinal() < bestPrecedence.ordinal()) {
logger.info("Precedence {} did not match or supersede best matching precedence ({}).", precedence,
bestPrecedence);
return null;
}
}
} catch (final Exception e) {
logger.error("Could not get precedence of renderer, returning null", e);
return null;
}
final Class<? extends Renderable> renderableType = rendererDescriptor.getRenderableType();
final int hierarchyDistance = ReflectionUtils.getHierarchyDistance(renderable.getClass(), renderableType);
return new RendererSelection(renderer, precedence, hierarchyDistance);
}
示例13: getWindowContent
import org.datacleaner.api.Renderer; //导入依赖的package包/类
@Override
protected JComponent getWindowContent() {
if (!_results.isEmpty()) {
for (final AnalyzerResult analyzerResult : _results) {
final Renderer<? super AnalyzerResult, ? extends JComponent> renderer =
_rendererFactory.getRenderer(analyzerResult, SwingRenderingFormat.class);
final JComponent component;
if (renderer == null) {
component = new JTextArea(analyzerResult.toString());
} else {
component = renderer.render(analyzerResult);
}
addRenderedResult(component);
}
}
final DCPanel panel = new DCPanel(WidgetUtils.COLOR_ALTERNATIVE_BACKGROUND);
panel.setLayout(new BorderLayout());
panel.add(WidgetUtils.scrolleable(_taskPaneContainer), BorderLayout.CENTER);
final Dimension preferredSize = panel.getPreferredSize();
final int height = preferredSize.height < 400 ? preferredSize.height + 100 : preferredSize.height;
final int width = preferredSize.width < 500 ? 500 : preferredSize.width;
panel.setPreferredSize(width, height);
return panel;
}
示例14: ComponentConfigurationDialog
import org.datacleaner.api.Renderer; //导入依赖的package包/类
public ComponentConfigurationDialog(final WindowContext windowContext, final ComponentBuilder componentBuilder,
final Renderer<ComponentBuilder, ? extends ComponentBuilderPresenter> renderer) {
super(windowContext, getBannerImage(componentBuilder));
_componentBuilder = componentBuilder;
_componentBuilder.addRemovalListener(this);
_renderer = renderer;
final ComponentScopeMenuBuilder menuBuilder = new ComponentScopeMenuBuilder(_componentBuilder) {
@Override
protected void onScopeChangeStart() {
_changingScope = true;
}
@Override
protected void onScopeChangeComplete(final AnalysisJobBuilder osJobBuilder,
final ComponentBuilder osComponentBuilder) {
_changingScope = false;
_componentScopeButton.updateText(osJobBuilder, osComponentBuilder);
_changeRequirementButton.updateText();
_changeRequirementButton.setVisible(ChangeRequirementMenu.isRelevant(_componentBuilder));
initialize();
}
};
_componentScopeButton = new ComponentScopeButton(_componentBuilder, menuBuilder);
_changeRequirementButton = new ChangeRequirementButton(_componentBuilder);
}
示例15: write
import org.datacleaner.api.Renderer; //导入依赖的package包/类
@Override
public void write(final AnalysisResult result, final DataCleanerConfiguration configuration,
final Supplier<Writer> writerRef, final Supplier<OutputStream> outputStreamRef) throws Exception {
final Writer writer = writerRef.get();
writer.write("SUCCESS!\n");
final RendererFactory rendererFactory = new RendererFactory(configuration);
for (final Entry<ComponentJob, AnalyzerResult> entry : result.getResultMap().entrySet()) {
final ComponentJob componentJob = entry.getKey();
final AnalyzerResult analyzerResult = entry.getValue();
final String name = LabelUtils.getLabel(componentJob);
writer.write("\nRESULT: ");
writer.write(name);
writer.write('\n');
final Renderer<? super AnalyzerResult, ? extends CharSequence> renderer =
rendererFactory.getRenderer(analyzerResult, TextRenderingFormat.class);
if (renderer == null) {
throw new IllegalStateException("No text renderer found for result: " + analyzerResult);
}
final CharSequence renderedResult = renderer.render(analyzerResult);
writer.write(renderedResult.toString());
writer.write('\n');
}
}