diff options
| author | Andrey Loskutov | 2015-04-05 14:53:34 +0000 |
|---|---|---|
| committer | Andrey Loskutov | 2015-04-05 14:53:34 +0000 |
| commit | c21b10add6637ba71ad6a82a5b4fa7a5d572e611 (patch) | |
| tree | 69706d3223eabdbdd4f594ff3ef16a0c87c65b5b | |
| parent | 05ebbc7b4891a24ca95be20f5ebf33cf9e2b8833 (diff) | |
| download | eclipse.platform.ui-c21b10add6637ba71ad6a82a5b4fa7a5d572e611.tar.gz eclipse.platform.ui-c21b10add6637ba71ad6a82a5b4fa7a5d572e611.tar.xz eclipse.platform.ui-c21b10add6637ba71ad6a82a5b4fa7a5d572e611.zip | |
Bug 418661 - [Metadata] Get rid of compile warnings in platform projects
in official build - part 4
Cleaned up and updated to Java 7 org.eclipse.e4.ui.css.core
Change-Id: I7786b827560d5accf8f4540c9a52957136b14d05
Signed-off-by: Andrey Loskutov <loskutov@gmx.de>
36 files changed, 714 insertions, 784 deletions
diff --git a/bundles/org.eclipse.e4.ui.css.core/.classpath b/bundles/org.eclipse.e4.ui.css.core/.classpath index 4c62a8048e6..e8ea977a694 100644 --- a/bundles/org.eclipse.e4.ui.css.core/.classpath +++ b/bundles/org.eclipse.e4.ui.css.core/.classpath @@ -2,6 +2,6 @@ <classpath> <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/> <classpathentry kind="src" path="src"/> - <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/> + <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7"/> <classpathentry kind="output" path="bin"/> </classpath> diff --git a/bundles/org.eclipse.e4.ui.css.core/.settings/org.eclipse.jdt.core.prefs b/bundles/org.eclipse.e4.ui.css.core/.settings/org.eclipse.jdt.core.prefs index e412012b2ad..cb3755ef506 100644 --- a/bundles/org.eclipse.e4.ui.css.core/.settings/org.eclipse.jdt.core.prefs +++ b/bundles/org.eclipse.e4.ui.css.core/.settings/org.eclipse.jdt.core.prefs @@ -1,14 +1,104 @@ eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.annotation.inheritNullAnnotations=disabled +org.eclipse.jdt.core.compiler.annotation.missingNonNullByDefaultAnnotation=ignore +org.eclipse.jdt.core.compiler.annotation.nonnull=org.eclipse.jdt.annotation.NonNull +org.eclipse.jdt.core.compiler.annotation.nonnullbydefault=org.eclipse.jdt.annotation.NonNullByDefault +org.eclipse.jdt.core.compiler.annotation.nullable=org.eclipse.jdt.annotation.Nullable +org.eclipse.jdt.core.compiler.annotation.nullanalysis=disabled org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 +org.eclipse.jdt.core.compiler.codegen.methodParameters=do not generate +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7 org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve -org.eclipse.jdt.core.compiler.compliance=1.6 +org.eclipse.jdt.core.compiler.compliance=1.7 org.eclipse.jdt.core.compiler.debug.lineNumber=generate org.eclipse.jdt.core.compiler.debug.localVariable=generate org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=warning org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.autoboxing=ignore +org.eclipse.jdt.core.compiler.problem.comparingIdentical=warning +org.eclipse.jdt.core.compiler.problem.deadCode=warning +org.eclipse.jdt.core.compiler.problem.deprecation=warning +org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode=disabled +org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=disabled +org.eclipse.jdt.core.compiler.problem.discouragedReference=warning +org.eclipse.jdt.core.compiler.problem.emptyStatement=ignore org.eclipse.jdt.core.compiler.problem.enumIdentifier=error -org.eclipse.jdt.core.compiler.source=1.6 +org.eclipse.jdt.core.compiler.problem.explicitlyClosedAutoCloseable=ignore +org.eclipse.jdt.core.compiler.problem.fallthroughCase=ignore +org.eclipse.jdt.core.compiler.problem.fatalOptionalError=disabled +org.eclipse.jdt.core.compiler.problem.fieldHiding=ignore +org.eclipse.jdt.core.compiler.problem.finalParameterBound=warning +org.eclipse.jdt.core.compiler.problem.finallyBlockNotCompletingNormally=warning +org.eclipse.jdt.core.compiler.problem.forbiddenReference=error +org.eclipse.jdt.core.compiler.problem.hiddenCatchBlock=warning +org.eclipse.jdt.core.compiler.problem.includeNullInfoFromAsserts=disabled +org.eclipse.jdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod=warning +org.eclipse.jdt.core.compiler.problem.incompleteEnumSwitch=warning +org.eclipse.jdt.core.compiler.problem.indirectStaticAccess=ignore +org.eclipse.jdt.core.compiler.problem.localVariableHiding=ignore +org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=warning +org.eclipse.jdt.core.compiler.problem.missingDefaultCase=ignore +org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=ignore +org.eclipse.jdt.core.compiler.problem.missingEnumCaseDespiteDefault=disabled +org.eclipse.jdt.core.compiler.problem.missingHashCodeMethod=ignore +org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=warning +org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotationForInterfaceMethodImplementation=enabled +org.eclipse.jdt.core.compiler.problem.missingSerialVersion=warning +org.eclipse.jdt.core.compiler.problem.missingSynchronizedOnInheritedMethod=ignore +org.eclipse.jdt.core.compiler.problem.noEffectAssignment=warning +org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion=warning +org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral=ignore +org.eclipse.jdt.core.compiler.problem.nonnullParameterAnnotationDropped=warning +org.eclipse.jdt.core.compiler.problem.nullAnnotationInferenceConflict=error +org.eclipse.jdt.core.compiler.problem.nullReference=warning +org.eclipse.jdt.core.compiler.problem.nullSpecViolation=error +org.eclipse.jdt.core.compiler.problem.nullUncheckedConversion=warning +org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod=warning +org.eclipse.jdt.core.compiler.problem.parameterAssignment=ignore +org.eclipse.jdt.core.compiler.problem.possibleAccidentalBooleanAssignment=ignore +org.eclipse.jdt.core.compiler.problem.potentialNullReference=ignore +org.eclipse.jdt.core.compiler.problem.potentiallyUnclosedCloseable=ignore +org.eclipse.jdt.core.compiler.problem.rawTypeReference=warning +org.eclipse.jdt.core.compiler.problem.redundantNullAnnotation=warning +org.eclipse.jdt.core.compiler.problem.redundantNullCheck=ignore +org.eclipse.jdt.core.compiler.problem.redundantSpecificationOfTypeArguments=ignore +org.eclipse.jdt.core.compiler.problem.redundantSuperinterface=ignore +org.eclipse.jdt.core.compiler.problem.reportMethodCanBePotentiallyStatic=ignore +org.eclipse.jdt.core.compiler.problem.reportMethodCanBeStatic=ignore +org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=disabled +org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=warning +org.eclipse.jdt.core.compiler.problem.suppressOptionalErrors=disabled +org.eclipse.jdt.core.compiler.problem.suppressWarnings=enabled +org.eclipse.jdt.core.compiler.problem.syntacticNullAnalysisForFields=disabled +org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation=ignore +org.eclipse.jdt.core.compiler.problem.typeParameterHiding=warning +org.eclipse.jdt.core.compiler.problem.unavoidableGenericTypeProblems=disabled +org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=warning +org.eclipse.jdt.core.compiler.problem.unclosedCloseable=warning +org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=ignore +org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=warning +org.eclipse.jdt.core.compiler.problem.unnecessaryElse=ignore +org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=warning +org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore +org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=ignore +org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionExemptExceptionAndThrowable=enabled +org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionIncludeDocCommentReference=enabled +org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionWhenOverriding=disabled +org.eclipse.jdt.core.compiler.problem.unusedExceptionParameter=ignore +org.eclipse.jdt.core.compiler.problem.unusedImport=warning +org.eclipse.jdt.core.compiler.problem.unusedLabel=warning +org.eclipse.jdt.core.compiler.problem.unusedLocal=warning +org.eclipse.jdt.core.compiler.problem.unusedObjectAllocation=ignore +org.eclipse.jdt.core.compiler.problem.unusedParameter=ignore +org.eclipse.jdt.core.compiler.problem.unusedParameterIncludeDocCommentReference=enabled +org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract=disabled +org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disabled +org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning +org.eclipse.jdt.core.compiler.problem.unusedTypeParameter=ignore +org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning +org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning +org.eclipse.jdt.core.compiler.source=1.7 org.eclipse.jdt.core.formatter.align_type_members_on_columns=false org.eclipse.jdt.core.formatter.alignment_for_arguments_in_allocation_expression=16 org.eclipse.jdt.core.formatter.alignment_for_arguments_in_annotation=0 diff --git a/bundles/org.eclipse.e4.ui.css.core/META-INF/MANIFEST.MF b/bundles/org.eclipse.e4.ui.css.core/META-INF/MANIFEST.MF index 8afba82fe02..24757a0b288 100644 --- a/bundles/org.eclipse.e4.ui.css.core/META-INF/MANIFEST.MF +++ b/bundles/org.eclipse.e4.ui.css.core/META-INF/MANIFEST.MF @@ -38,5 +38,5 @@ Require-Bundle: org.w3c.css.sac;bundle-version="1.3.0", org.apache.batik.css;bundle-version="1.7.0", org.eclipse.equinox.common;bundle-version="[3.5.0,4.0.0)", org.eclipse.core.runtime;bundle-version="[3.6.0,4.0.0)" -Bundle-RequiredExecutionEnvironment: JavaSE-1.6 +Bundle-RequiredExecutionEnvironment: JavaSE-1.7 Import-Package: org.w3c.dom.css;version="2.0.0" diff --git a/bundles/org.eclipse.e4.ui.css.core/build.properties b/bundles/org.eclipse.e4.ui.css.core/build.properties index e760ad46bc4..b767f86dc9b 100644 --- a/bundles/org.eclipse.e4.ui.css.core/build.properties +++ b/bundles/org.eclipse.e4.ui.css.core/build.properties @@ -1,5 +1,5 @@ ############################################################################### -# Copyright (c) 2010, 2011 IBM Corporation and others. +# Copyright (c) 2010, 2015 IBM Corporation and others. # All rights reserved. This program and the accompanying materials # are made available under the terms of the Eclipse Public License v1.0 # which accompanies this distribution, and is available at @@ -17,3 +17,4 @@ bin.includes = META-INF/,\ src.includes = schema/,\ apache_about_files/,\ about.html +jre.compilation.profile = JavaSE-1.7 diff --git a/bundles/org.eclipse.e4.ui.css.core/src/org/eclipse/e4/ui/css/core/dom/ElementAdapter.java b/bundles/org.eclipse.e4.ui.css.core/src/org/eclipse/e4/ui/css/core/dom/ElementAdapter.java index d860f54ae2d..c68e95c766f 100644 --- a/bundles/org.eclipse.e4.ui.css.core/src/org/eclipse/e4/ui/css/core/dom/ElementAdapter.java +++ b/bundles/org.eclipse.e4.ui.css.core/src/org/eclipse/e4/ui/css/core/dom/ElementAdapter.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2008, 2014 Angelo Zerr and others. + * Copyright (c) 2008, 2015 Angelo Zerr and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -38,11 +38,11 @@ public abstract class ElementAdapter implements Element, CSSStylableElement { protected CSSEngine engine; - private Map /* <String, CSSStyleDeclaration> */defaultStyleDeclarationMap = new HashMap(); + private Map <String, CSSStyleDeclaration> defaultStyleDeclarationMap = new HashMap<>(); - private CSSExtendedProperties style = null; + private CSSExtendedProperties style; - private List staticPseudoInstances; + private List<String> staticPseudoInstances; public ElementAdapter(Object nativeWidget, CSSEngine engine) { this.nativeWidget = nativeWidget; @@ -56,7 +56,7 @@ public abstract class ElementAdapter implements Element, CSSStylableElement { */ public void addStaticPseudoInstance(String pseudoE) { if (staticPseudoInstances == null) { - staticPseudoInstances = new ArrayList(); + staticPseudoInstances = new ArrayList<>(); } staticPseudoInstances.add(pseudoE); } @@ -358,12 +358,11 @@ public abstract class ElementAdapter implements Element, CSSStylableElement { @Override public CSSStyleDeclaration getDefaultStyleDeclaration(String pseudoE) { - return (CSSStyleDeclaration) defaultStyleDeclarationMap.get(pseudoE); + return defaultStyleDeclarationMap.get(pseudoE); } @Override - public void setDefaultStyleDeclaration(String pseudoE, - CSSStyleDeclaration declaration) { + public void setDefaultStyleDeclaration(String pseudoE, CSSStyleDeclaration declaration) { this.defaultStyleDeclarationMap.put(pseudoE, declaration); } @@ -390,7 +389,7 @@ public abstract class ElementAdapter implements Element, CSSStylableElement { if (staticPseudoInstances == null) { return EMPTY_STRING; } - return (String[]) staticPseudoInstances.toArray(EMPTY_STRING); + return staticPseudoInstances.toArray(EMPTY_STRING); } @Override diff --git a/bundles/org.eclipse.e4.ui.css.core/src/org/eclipse/e4/ui/css/core/dom/ExtendedDocumentCSS.java b/bundles/org.eclipse.e4.ui.css.core/src/org/eclipse/e4/ui/css/core/dom/ExtendedDocumentCSS.java index e3943480434..399a08a927a 100644 --- a/bundles/org.eclipse.e4.ui.css.core/src/org/eclipse/e4/ui/css/core/dom/ExtendedDocumentCSS.java +++ b/bundles/org.eclipse.e4.ui.css.core/src/org/eclipse/e4/ui/css/core/dom/ExtendedDocumentCSS.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2008 Angelo Zerr and others. + * Copyright (c) 2008, 2015 Angelo Zerr and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -33,8 +33,8 @@ public interface ExtendedDocumentCSS extends DocumentCSS { public void removeAllStyleSheets(); - public List queryConditionSelector(int conditionType); + public List<?> queryConditionSelector(int conditionType); - public List querySelector(int selectorType, int conditionType); + public List<?> querySelector(int selectorType, int conditionType); } diff --git a/bundles/org.eclipse.e4.ui.css.core/src/org/eclipse/e4/ui/css/core/dom/properties/Gradient.java b/bundles/org.eclipse.e4.ui.css.core/src/org/eclipse/e4/ui/css/core/dom/properties/Gradient.java index 135a15d48f3..191938f2994 100644 --- a/bundles/org.eclipse.e4.ui.css.core/src/org/eclipse/e4/ui/css/core/dom/properties/Gradient.java +++ b/bundles/org.eclipse.e4.ui.css.core/src/org/eclipse/e4/ui/css/core/dom/properties/Gradient.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2008, 2010 Angelo Zerr and others. + * Copyright (c) 2008, 2015 Angelo Zerr and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -14,7 +14,6 @@ package org.eclipse.e4.ui.css.core.dom.properties; import java.util.ArrayList; import java.util.List; - import org.w3c.dom.css.CSSPrimitiveValue; /** @@ -23,11 +22,11 @@ import org.w3c.dom.css.CSSPrimitiveValue; */ public class Gradient { - private final List rgbs = new ArrayList(); - private final List percents = new ArrayList(); + private final List<Object> rgbs = new ArrayList<>(); + private final List<Integer> percents = new ArrayList<>(); //TODO see bug #278077 - private final List values = new ArrayList(); + private final List<CSSPrimitiveValue> values = new ArrayList<>(); private boolean isLinear = true; @@ -61,15 +60,15 @@ public class Gradient { this.vertical = vertical; } - public List getRGBs() { + public List<Object> getRGBs() { return rgbs; } - public List getValues() { + public List<CSSPrimitiveValue> getValues() { return values; } - public List getPercents() { + public List<Integer> getPercents() { return percents; } diff --git a/bundles/org.eclipse.e4.ui.css.core/src/org/eclipse/e4/ui/css/core/exceptions/UnsupportedClassCSSPropertyException.java b/bundles/org.eclipse.e4.ui.css.core/src/org/eclipse/e4/ui/css/core/exceptions/UnsupportedClassCSSPropertyException.java index c122098c9e5..f4fb1c15f59 100644 --- a/bundles/org.eclipse.e4.ui.css.core/src/org/eclipse/e4/ui/css/core/exceptions/UnsupportedClassCSSPropertyException.java +++ b/bundles/org.eclipse.e4.ui.css.core/src/org/eclipse/e4/ui/css/core/exceptions/UnsupportedClassCSSPropertyException.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2008 Angelo Zerr and others. + * Copyright (c) 2008, 2015 Angelo Zerr and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -22,9 +22,9 @@ import org.eclipse.e4.ui.css.core.dom.properties.providers.CSSPropertyHandlerLaz */ public class UnsupportedClassCSSPropertyException extends Exception { private static final long serialVersionUID = 1L; - private Class clazz; + private Class<?> clazz; - public UnsupportedClassCSSPropertyException(Class clazz) { + public UnsupportedClassCSSPropertyException(Class<?> clazz) { this.clazz = clazz; } diff --git a/bundles/org.eclipse.e4.ui.css.core/src/org/eclipse/e4/ui/css/core/impl/dom/CSSComputedStyleImpl.java b/bundles/org.eclipse.e4.ui.css.core/src/org/eclipse/e4/ui/css/core/impl/dom/CSSComputedStyleImpl.java index 746e20e7ffa..a63707b4586 100644 --- a/bundles/org.eclipse.e4.ui.css.core/src/org/eclipse/e4/ui/css/core/impl/dom/CSSComputedStyleImpl.java +++ b/bundles/org.eclipse.e4.ui.css.core/src/org/eclipse/e4/ui/css/core/impl/dom/CSSComputedStyleImpl.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2008, 2013 Angelo Zerr and others. + * Copyright (c) 2008, 2015 Angelo Zerr and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -25,8 +25,7 @@ import org.w3c.dom.css.CSSStyleDeclaration; * styles coming from Condition Selector (ex : Label#MyId) and other selectors * (ex : Label). */ -public class CSSComputedStyleImpl extends CSSStyleDeclarationImpl implements - CSSStyleDeclaration { +public class CSSComputedStyleImpl extends CSSStyleDeclarationImpl implements CSSStyleDeclaration { private List<StyleWrapper> styleRules; @@ -35,10 +34,10 @@ public class CSSComputedStyleImpl extends CSSStyleDeclarationImpl implements this.styleRules = styleRules; // TODO [rst] Optimize: A list of StyleWrapper instances could be sorted // only once after reading the stylesheet(s). - Collections.sort( this.styleRules, StyleWrapper.COMPARATOR ); - Iterator iterator = this.styleRules.iterator(); - while (iterator.hasNext()) { - StyleWrapper styleWrapper = (StyleWrapper) iterator.next(); + Collections.sort( this.styleRules, StyleWrapper.COMPARATOR ); + Iterator<StyleWrapper> iterator = this.styleRules.iterator(); + while (iterator.hasNext()) { + StyleWrapper styleWrapper = iterator.next(); addCSSPropertyList(((CSSStyleDeclarationImpl) styleWrapper.style).getCSSPropertyList()); } } diff --git a/bundles/org.eclipse.e4.ui.css.core/src/org/eclipse/e4/ui/css/core/impl/dom/CSSPropertyListImpl.java b/bundles/org.eclipse.e4.ui.css.core/src/org/eclipse/e4/ui/css/core/impl/dom/CSSPropertyListImpl.java index 06efe41422e..15afefbe3ad 100644 --- a/bundles/org.eclipse.e4.ui.css.core/src/org/eclipse/e4/ui/css/core/impl/dom/CSSPropertyListImpl.java +++ b/bundles/org.eclipse.e4.ui.css.core/src/org/eclipse/e4/ui/css/core/impl/dom/CSSPropertyListImpl.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2008, 2013 Angelo Zerr and others. + * Copyright (c) 2008, 2015 Angelo Zerr and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -22,24 +22,16 @@ import org.eclipse.e4.ui.css.core.dom.CSSPropertyList; */ public class CSSPropertyListImpl implements CSSPropertyList { - private List properties = null; + private List<CSSProperty> properties; public CSSPropertyListImpl() { } - /* - * (non-Javadoc) - * @see org.eclipse.e4.css.core.dom.CSSPropertyList#getLength() - */ @Override public int getLength() { return (properties != null) ? properties.size() : 0; } - /* - * (non-Javadoc) - * @see org.eclipse.e4.css.core.dom.CSSPropertyList#item(int) - */ @Override public CSSProperty item(int index) { return (properties != null) ? (CSSProperty) properties.get(index) @@ -51,7 +43,7 @@ public class CSSPropertyListImpl implements CSSPropertyList { */ public void add(CSSProperty property) { if (properties == null) { - properties = new ArrayList(); + properties = new ArrayList<>(); } properties.add(property); } @@ -63,7 +55,7 @@ public class CSSPropertyListImpl implements CSSPropertyList { */ public void insert(CSSProperty property, int index) { if (properties == null) { - properties = new ArrayList(); + properties = new ArrayList<>(); } properties.add(index, property); } @@ -74,15 +66,11 @@ public class CSSPropertyListImpl implements CSSPropertyList { */ public void delete(int index) { if (properties == null) { - properties = new ArrayList(); + properties = new ArrayList<>(); } properties.remove(index); } - /* - * (non-Javadoc) - * @see java.lang.Object#toString() - */ @Override public String toString() { StringBuffer sb = new StringBuffer(); diff --git a/bundles/org.eclipse.e4.ui.css.core/src/org/eclipse/e4/ui/css/core/impl/dom/DocumentCSSImpl.java b/bundles/org.eclipse.e4.ui.css.core/src/org/eclipse/e4/ui/css/core/impl/dom/DocumentCSSImpl.java index fa185d30a4e..2ed7382bef8 100644 --- a/bundles/org.eclipse.e4.ui.css.core/src/org/eclipse/e4/ui/css/core/impl/dom/DocumentCSSImpl.java +++ b/bundles/org.eclipse.e4.ui.css.core/src/org/eclipse/e4/ui/css/core/impl/dom/DocumentCSSImpl.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2008, 2013 Angelo Zerr and others. + * Copyright (c) 2008, 2015 Angelo Zerr and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -41,39 +41,23 @@ public class DocumentCSSImpl implements ExtendedDocumentCSS { /** * key=selector type, value = CSSStyleDeclaration */ - private Map styleDeclarationMap = null; + private Map<Integer, List<?>> styleDeclarationMap; - /* - * (non-Javadoc) - * @see org.w3c.dom.stylesheets.DocumentStyle#getStyleSheets() - */ @Override public StyleSheetList getStyleSheets() { return styleSheetList; } - /* - * (non-Javadoc) - * @see org.w3c.dom.css.DocumentCSS#getOverrideStyle(org.w3c.dom.Element, java.lang.String) - */ @Override public CSSStyleDeclaration getOverrideStyle(Element element, String s) { return null; } - /* - * (non-Javadoc) - * @see org.eclipse.e4.css.core.dom.ExtendedDocumentCSS#addStyleSheet(org.w3c.dom.stylesheets.StyleSheet) - */ @Override public void addStyleSheet(StyleSheet styleSheet) { styleSheetList.addStyleSheet(styleSheet); } - /* - * (non-Javadoc) - * @see org.eclipse.e4.css.core.dom.ExtendedDocumentCSS#removeAllStyleSheets() - */ @Override public void removeAllStyleSheets() { styleSheetList.removeAllStyleSheets(); @@ -81,13 +65,13 @@ public class DocumentCSSImpl implements ExtendedDocumentCSS { } @Override - public List queryConditionSelector(int conditionType) { + public List<?> queryConditionSelector(int conditionType) { return querySelector(Selector.SAC_CONDITIONAL_SELECTOR, conditionType); } @Override - public List querySelector(int selectorType, int conditionType) { - List list = getCSSStyleDeclarationList(selectorType, conditionType); + public List<?> querySelector(int selectorType, int conditionType) { + List<?> list = getCSSStyleDeclarationList(selectorType, conditionType); if (list != null) { return list; } @@ -133,14 +117,12 @@ public class DocumentCSSImpl implements ExtendedDocumentCSS { return list; } - protected List getCSSStyleDeclarationList(int selectorType, - int conditionType) { + protected List<?> getCSSStyleDeclarationList(int selectorType, int conditionType) { Integer key = getKey(selectorType, conditionType); - return (List) getStyleDeclarationMap().get(key); + return getStyleDeclarationMap().get(key); } - protected void setCSSStyleDeclarationList(List list, int selectorType, - int conditionType) { + protected void setCSSStyleDeclarationList(List<?> list, int selectorType, int conditionType) { Integer key = getKey(selectorType, conditionType); getStyleDeclarationMap().put(key, list); } @@ -162,9 +144,9 @@ public class DocumentCSSImpl implements ExtendedDocumentCSS { return OTHER_SAC_SELECTOR; } - protected Map getStyleDeclarationMap() { + protected Map<Integer, List<?>> getStyleDeclarationMap() { if (styleDeclarationMap == null) { - styleDeclarationMap = new HashMap(); + styleDeclarationMap = new HashMap<>(); } return styleDeclarationMap; } diff --git a/bundles/org.eclipse.e4.ui.css.core/src/org/eclipse/e4/ui/css/core/impl/dom/MediaListImpl.java b/bundles/org.eclipse.e4.ui.css.core/src/org/eclipse/e4/ui/css/core/impl/dom/MediaListImpl.java index eb0229c3549..c6d372cfa16 100644 --- a/bundles/org.eclipse.e4.ui.css.core/src/org/eclipse/e4/ui/css/core/impl/dom/MediaListImpl.java +++ b/bundles/org.eclipse.e4.ui.css.core/src/org/eclipse/e4/ui/css/core/impl/dom/MediaListImpl.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2008, 2013 Angelo Zerr and others. + * Copyright (c) 2008, 2015 Angelo Zerr and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -20,10 +20,10 @@ import org.w3c.dom.stylesheets.MediaList; public class MediaListImpl implements MediaList { - private List mediaList = null; + private List<String> mediaList; public MediaListImpl(SACMediaList media) { - mediaList = new ArrayList(); + mediaList = new ArrayList<>(); for (int i = 0; i < media.getLength(); i++) { mediaList.add(media.item(i)); } @@ -32,7 +32,9 @@ public class MediaListImpl implements MediaList { @Override public void appendMedium(String newMedium) throws DOMException { - if (mediaList.contains(newMedium)) mediaList.remove(newMedium); + if (mediaList.contains(newMedium)) { + mediaList.remove(newMedium); + } mediaList.add(newMedium); } @@ -62,15 +64,19 @@ public class MediaListImpl implements MediaList { @Override public String item(int index) { - if (index > mediaList.size()) return null; - return (String) mediaList.get(index); + if (index > mediaList.size()) { + return null; + } + return mediaList.get(index); } @Override public void setMediaText(String mediaText) throws DOMException { while (mediaText.length() > 0) { int next = mediaText.indexOf(','); - if (next == -1) next = mediaText.length(); + if (next == -1) { + next = mediaText.length(); + } String media = mediaText.substring(0, next); appendMedium(media.trim()); if (next + 1 < mediaText.length()) { diff --git a/bundles/org.eclipse.e4.ui.css.core/src/org/eclipse/e4/ui/css/core/impl/dom/StyleSheetListImpl.java b/bundles/org.eclipse.e4.ui.css.core/src/org/eclipse/e4/ui/css/core/impl/dom/StyleSheetListImpl.java index e49965ad52e..d036eff8be0 100644 --- a/bundles/org.eclipse.e4.ui.css.core/src/org/eclipse/e4/ui/css/core/impl/dom/StyleSheetListImpl.java +++ b/bundles/org.eclipse.e4.ui.css.core/src/org/eclipse/e4/ui/css/core/impl/dom/StyleSheetListImpl.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2008, 2013 Angelo Zerr and others. + * Copyright (c) 2008, 2015 Angelo Zerr and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -23,27 +23,17 @@ import org.w3c.dom.stylesheets.StyleSheetList; */ public class StyleSheetListImpl implements StyleSheetList { - private List styleSheets = null; + private List<StyleSheet> styleSheets; + - /* - * (non-Javadoc) - * - * @see org.w3c.dom.stylesheets.StyleSheetList#getLength() - */ @Override public int getLength() { return (styleSheets != null) ? styleSheets.size() : 0; } - /* - * (non-Javadoc) - * - * @see org.w3c.dom.stylesheets.StyleSheetList#item(int) - */ @Override public StyleSheet item(int index) { - return (styleSheets != null) ? (StyleSheet) styleSheets.get(index) - : null; + return (styleSheets != null) ? (StyleSheet) styleSheets.get(index) : null; } /** @@ -52,8 +42,9 @@ public class StyleSheetListImpl implements StyleSheetList { * @param styleSheet */ public void addStyleSheet(StyleSheet styleSheet) { - if (styleSheets == null) - styleSheets = new ArrayList(); + if (styleSheets == null) { + styleSheets = new ArrayList<>(); + } styleSheets.add(styleSheet); } diff --git a/bundles/org.eclipse.e4.ui.css.core/src/org/eclipse/e4/ui/css/core/impl/dom/parsers/AbstractCSSParser.java b/bundles/org.eclipse.e4.ui.css.core/src/org/eclipse/e4/ui/css/core/impl/dom/parsers/AbstractCSSParser.java index 73b8f1e4664..52702b9b6da 100644 --- a/bundles/org.eclipse.e4.ui.css.core/src/org/eclipse/e4/ui/css/core/impl/dom/parsers/AbstractCSSParser.java +++ b/bundles/org.eclipse.e4.ui.css.core/src/org/eclipse/e4/ui/css/core/impl/dom/parsers/AbstractCSSParser.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2008, 2013 Angelo Zerr and others. + * Copyright (c) 2008, 2015 Angelo Zerr and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -45,108 +45,62 @@ public class AbstractCSSParser implements CSSParser { } // SAC - private Parser parser = null; + private Parser parser; private DocumentHandlerFactory documentHandlerFactory; private ISACParserFactory parserFactory; - private ConditionFactory conditionFactory = null; - private SelectorFactory selectorFactory = null; + private ConditionFactory conditionFactory; + private SelectorFactory selectorFactory; - /* - * (non-Javadoc) - * - * @see org.eclipse.e4.ui.css.core.dom.parsers.CSSParser#parseStyleSheet(org.w3c.css.sac.InputSource) - */ @Override public CSSStyleSheet parseStyleSheet(InputSource source) throws IOException { - ExtendedDocumentHandler documentHandler = getDocumentHandlerFactory() - .makeDocumentHandler(); + ExtendedDocumentHandler documentHandler = getDocumentHandlerFactory().makeDocumentHandler(); Parser parser = getParser(); parser.setDocumentHandler(documentHandler); parser.parseStyleSheet(source); return (CSSStyleSheet) documentHandler.getNodeRoot(); } - /* - * (non-Javadoc) - * - * @see org.eclipse.e4.ui.css.core.dom.parsers.CSSParser#parseStyleDeclaration(org.w3c.css.sac.InputSource) - */ @Override - public CSSStyleDeclaration parseStyleDeclaration(InputSource source) - throws IOException { - CSSStyleDeclarationImpl styleDeclaration = new CSSStyleDeclarationImpl( - null); - parseStyleDeclaration(((styleDeclaration)), - source); + public CSSStyleDeclaration parseStyleDeclaration(InputSource source) throws IOException { + CSSStyleDeclarationImpl styleDeclaration = new CSSStyleDeclarationImpl(null); + parseStyleDeclaration(((styleDeclaration)), source); return styleDeclaration; } - /* - * (non-Javadoc) - * - * @see org.eclipse.e4.ui.css.core.dom.parsers.CSSParser#parseStyleDeclaration(org.w3c.dom.css.CSSStyleDeclaration, - * org.w3c.css.sac.InputSource) - */ @Override - public void parseStyleDeclaration(CSSStyleDeclaration styleDeclaration, - InputSource source) throws IOException { - Stack stack = new Stack(); + public void parseStyleDeclaration(CSSStyleDeclaration styleDeclaration, InputSource source) throws IOException { + Stack<Object> stack = new Stack<>(); stack.push(styleDeclaration); - ExtendedDocumentHandler documentHandler = getDocumentHandlerFactory() - .makeDocumentHandler(); + ExtendedDocumentHandler documentHandler = getDocumentHandlerFactory().makeDocumentHandler(); documentHandler.setNodeStack(stack); Parser parser = getParser(); parser.setDocumentHandler(documentHandler); parser.parseStyleDeclaration(source); } - /* - * (non-Javadoc) - * - * @see org.eclipse.e4.ui.css.core.dom.parsers.CSSParser#parsePropertyValue(org.w3c.css.sac.InputSource) - */ @Override public CSSValue parsePropertyValue(InputSource source) throws IOException { Parser parser = getParser(); - ExtendedDocumentHandler documentHandler = getDocumentHandlerFactory() - .makeDocumentHandler(); + ExtendedDocumentHandler documentHandler = getDocumentHandlerFactory().makeDocumentHandler(); parser.setDocumentHandler(documentHandler); return CSSValueFactory.newValue(parser.parsePropertyValue(source)); } - /* - * (non-Javadoc) - * - * @see org.eclipse.e4.ui.css.core.dom.parsers.CSSParser#parseRule(org.w3c.css.sac.InputSource) - */ @Override public CSSRule parseRule(InputSource source) throws IOException { // TODO Auto-generated method stub return null; } - /* - * (non-Javadoc) - * - * @see - * org.eclipse.e4.ui.css.core.dom.parsers.CSSParser#parseSelectors(org.w3c - * .css.sac.InputSource) - */ @Override public SelectorList parseSelectors(InputSource source) throws IOException { - ExtendedDocumentHandler documentHandler = getDocumentHandlerFactory() - .makeDocumentHandler(); + ExtendedDocumentHandler documentHandler = getDocumentHandlerFactory().makeDocumentHandler(); Parser parser = getParser(); parser.setDocumentHandler(documentHandler); return parser.parseSelectors(source); } - /* - * (non-Javadoc) - * - * @see org.eclipse.e4.ui.css.core.dom.parsers.CSSParser#setParentStyleSheet(org.w3c.dom.css.CSSStyleSheet) - */ @Override public void setParentStyleSheet(CSSStyleSheet parentStyleSheet) { @@ -170,8 +124,7 @@ public class AbstractCSSParser implements CSSParser { * @param documentHandlerFactory */ @Override - public void setDocumentHandlerFactory( - DocumentHandlerFactory documentHandlerFactory) { + public void setDocumentHandlerFactory(DocumentHandlerFactory documentHandlerFactory) { this.documentHandlerFactory = documentHandlerFactory; } @@ -229,41 +182,21 @@ public class AbstractCSSParser implements CSSParser { this.parserFactory = parserFactory; } - /* - * (non-Javadoc) - * - * @see org.eclipse.e4.ui.css.core.dom.parsers.CSSParser#getConditionFactory() - */ @Override public ConditionFactory getConditionFactory() { return conditionFactory; } - /* - * (non-Javadoc) - * - * @see org.eclipse.e4.ui.css.core.dom.parsers.CSSParser#setConditionFactory(org.w3c.css.sac.ConditionFactory) - */ @Override public void setConditionFactory(ConditionFactory conditionFactory) { this.conditionFactory = conditionFactory; } - /* - * (non-Javadoc) - * - * @see org.eclipse.e4.ui.css.core.dom.parsers.CSSParser#getSelectorFactory() - */ @Override public SelectorFactory getSelectorFactory() { return selectorFactory; } - /* - * (non-Javadoc) - * - * @see org.eclipse.e4.ui.css.core.dom.parsers.CSSParser#setSelectorFactory(org.w3c.css.sac.SelectorFactory) - */ @Override public void setSelectorFactory(SelectorFactory selectorFactory) { this.selectorFactory = selectorFactory; diff --git a/bundles/org.eclipse.e4.ui.css.core/src/org/eclipse/e4/ui/css/core/impl/engine/CSSElementContextImpl.java b/bundles/org.eclipse.e4.ui.css.core/src/org/eclipse/e4/ui/css/core/impl/engine/CSSElementContextImpl.java index 2bcd0174e26..c569e5a0adb 100644 --- a/bundles/org.eclipse.e4.ui.css.core/src/org/eclipse/e4/ui/css/core/impl/engine/CSSElementContextImpl.java +++ b/bundles/org.eclipse.e4.ui.css.core/src/org/eclipse/e4/ui/css/core/impl/engine/CSSElementContextImpl.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2008 Angelo Zerr and others. + * Copyright (c) 2008, 2015 Angelo Zerr and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -12,7 +12,6 @@ package org.eclipse.e4.ui.css.core.impl.engine; import java.util.HashMap; import java.util.Map; - import org.eclipse.e4.ui.css.core.dom.CSSStylableElement; import org.eclipse.e4.ui.css.core.dom.IElementProvider; import org.eclipse.e4.ui.css.core.engine.CSSElementContext; @@ -22,7 +21,7 @@ public class CSSElementContextImpl implements CSSElementContext { private Element element; - private Map datas = null; + private Map<Object, Object> datas; private IElementProvider elementProvider; @@ -32,15 +31,17 @@ public class CSSElementContextImpl implements CSSElementContext { @Override public void setData(Object key, Object value) { - if (datas == null) - datas = new HashMap(); + if (datas == null) { + datas = new HashMap<>(); + } datas.put(key, value); } @Override public Object getData(Object key) { - if (datas == null) + if (datas == null) { return null; + } return datas.get(key); } @@ -51,18 +52,17 @@ public class CSSElementContextImpl implements CSSElementContext { @Override public void setElement(Element newElement) { - if (element != null && element instanceof CSSStylableElement - && newElement instanceof CSSStylableElement) { - ((CSSStylableElement) newElement) - .copyDefaultStyleDeclarations(((CSSStylableElement) element)); + if (element != null && element instanceof CSSStylableElement && newElement instanceof CSSStylableElement) { + ((CSSStylableElement) newElement).copyDefaultStyleDeclarations(((CSSStylableElement) element)); } this.element = newElement; } @Override public boolean elementMustBeRefreshed(IElementProvider elementProvider) { - if (this.elementProvider == null) + if (this.elementProvider == null) { return (elementProvider != null); + } return !this.elementProvider.equals(elementProvider); } diff --git a/bundles/org.eclipse.e4.ui.css.core/src/org/eclipse/e4/ui/css/core/impl/engine/CSSEngineImpl.java b/bundles/org.eclipse.e4.ui.css.core/src/org/eclipse/e4/ui/css/core/impl/engine/CSSEngineImpl.java index 8c996aa3fc4..39fbfd9240b 100644 --- a/bundles/org.eclipse.e4.ui.css.core/src/org/eclipse/e4/ui/css/core/impl/engine/CSSEngineImpl.java +++ b/bundles/org.eclipse.e4.ui.css.core/src/org/eclipse/e4/ui/css/core/impl/engine/CSSEngineImpl.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2008, 2012 Angelo Zerr and others. + * Copyright (c) 2008, 2015 Angelo Zerr and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -28,9 +28,9 @@ public abstract class CSSEngineImpl extends AbstractCSSEngine { public static final ConditionFactory CONDITIONFACTORY_INSTANCE = new CSSConditionFactoryImpl( null, "class", null, "id"); - private CSSPropertyHandlerSimpleProviderImpl handlerProvider = null; + private CSSPropertyHandlerSimpleProviderImpl handlerProvider; - private CSSPropertyHandlerLazyProviderImpl lazyHandlerProvider = null; + private CSSPropertyHandlerLazyProviderImpl lazyHandlerProvider; public CSSEngineImpl() { super(); @@ -60,7 +60,7 @@ public abstract class CSSEngineImpl extends AbstractCSSEngine { return parser; } - public void registerCSSPropertyHandler(Class cl, ICSSPropertyHandler handler) { + public void registerCSSPropertyHandler(Class<?> cl, ICSSPropertyHandler handler) { initHandlerProviderIfNeed(); handlerProvider.registerCSSPropertyHandler(cl, handler); } @@ -72,8 +72,7 @@ public abstract class CSSEngineImpl extends AbstractCSSEngine { } } - public void registerCSSProperty(String propertyName, - Class propertyHandlerClass) { + public void registerCSSProperty(String propertyName, Class<? extends ICSSPropertyHandler> propertyHandlerClass) { initHandlerProviderIfNeed(); handlerProvider.registerCSSProperty(propertyName, propertyHandlerClass); } diff --git a/bundles/org.eclipse.e4.ui.css.core/src/org/eclipse/e4/ui/css/core/impl/sac/AbstractElementSelector.java b/bundles/org.eclipse.e4.ui.css.core/src/org/eclipse/e4/ui/css/core/impl/sac/AbstractElementSelector.java index 44e5b31c63f..eb5c6450247 100644 --- a/bundles/org.eclipse.e4.ui.css.core/src/org/eclipse/e4/ui/css/core/impl/sac/AbstractElementSelector.java +++ b/bundles/org.eclipse.e4.ui.css.core/src/org/eclipse/e4/ui/css/core/impl/sac/AbstractElementSelector.java @@ -21,71 +21,67 @@ package org.eclipse.e4.ui.css.core.impl.sac; import java.util.Set; - import org.w3c.css.sac.ElementSelector; /** * This class provides an abstract implementation of the ElementSelector * interface. */ -public abstract class AbstractElementSelector - implements ElementSelector, - ExtendedSelector { - - /** - * The namespace URI. - */ - protected String namespaceURI; - - /** - * The local name. - */ - protected String localName; - - /** - * Creates a new ElementSelector object. - */ - protected AbstractElementSelector(String uri, String name) { - namespaceURI = uri; - localName = name; - } - - /** - * Indicates whether some other object is "equal to" this one. - * @param obj the reference object with which to compare. - */ - @Override +public abstract class AbstractElementSelector implements ElementSelector, ExtendedSelector { + + /** + * The namespace URI. + */ + protected String namespaceURI; + + /** + * The local name. + */ + protected String localName; + + /** + * Creates a new ElementSelector object. + */ + protected AbstractElementSelector(String uri, String name) { + namespaceURI = uri; + localName = name; + } + + /** + * Indicates whether some other object is "equal to" this one. + * @param obj the reference object with which to compare. + */ + @Override public boolean equals(Object obj) { - if (obj == null || (obj.getClass() != getClass())) { - return false; - } - AbstractElementSelector s = (AbstractElementSelector)obj; - return (s.namespaceURI.equals(namespaceURI) && - s.localName.equals(localName)); - } - - /** - * <b>SAC</b>: Implements {@link - * org.w3c.css.sac.ElementSelector#getNamespaceURI()}. - */ - @Override + if (obj == null || (obj.getClass() != getClass())) { + return false; + } + AbstractElementSelector s = (AbstractElementSelector)obj; + return (s.namespaceURI.equals(namespaceURI) && s.localName.equals(localName)); + } + + /** + * <b>SAC</b>: Implements {@link + * org.w3c.css.sac.ElementSelector#getNamespaceURI()}. + */ + @Override public String getNamespaceURI() { - return namespaceURI; - } - - /** - * <b>SAC</b>: Implements {@link - * org.w3c.css.sac.ElementSelector#getLocalName()}. - */ - @Override + return namespaceURI; + } + + /** + * <b>SAC</b>: Implements {@link + * org.w3c.css.sac.ElementSelector#getLocalName()}. + */ + @Override public String getLocalName() { - return localName; - } - - /** - * Fills the given set with the attribute names found in this selector. - */ - @Override - public void fillAttributeSet(Set attrSet) { - } + return localName; + } + + /** + * Fills the given set with the attribute names found in this selector. + */ + @Override + public void fillAttributeSet(Set<String> attrSet) { + } } diff --git a/bundles/org.eclipse.e4.ui.css.core/src/org/eclipse/e4/ui/css/core/impl/sac/CSSAndConditionImpl.java b/bundles/org.eclipse.e4.ui.css.core/src/org/eclipse/e4/ui/css/core/impl/sac/CSSAndConditionImpl.java index 977347285fa..c236fa1cb57 100644 --- a/bundles/org.eclipse.e4.ui.css.core/src/org/eclipse/e4/ui/css/core/impl/sac/CSSAndConditionImpl.java +++ b/bundles/org.eclipse.e4.ui.css.core/src/org/eclipse/e4/ui/css/core/impl/sac/CSSAndConditionImpl.java @@ -21,7 +21,6 @@ package org.eclipse.e4.ui.css.core.impl.sac; import java.util.Set; - import org.w3c.css.sac.Condition; import org.w3c.dom.Element; @@ -30,45 +29,45 @@ import org.w3c.dom.Element; * {@link org.w3c.css.sac.CombinatorCondition} interface. */ public class CSSAndConditionImpl extends AbstractCombinatorCondition { - /** - * Creates a new CombinatorCondition object. - */ - public CSSAndConditionImpl(Condition c1, Condition c2) { - super(c1, c2); - } + /** + * Creates a new CombinatorCondition object. + */ + public CSSAndConditionImpl(Condition c1, Condition c2) { + super(c1, c2); + } - /** - * <b>SAC</b>: Implements {@link - * org.w3c.css.sac.Condition#getConditionType()}. - */ - @Override + /** + * <b>SAC</b>: Implements {@link + * org.w3c.css.sac.Condition#getConditionType()}. + */ + @Override public short getConditionType() { - return SAC_AND_CONDITION; - } + return SAC_AND_CONDITION; + } - /** - * Tests whether this condition matches the given element. - */ - @Override + /** + * Tests whether this condition matches the given element. + */ + @Override public boolean match(Element e, String pseudoE) { - return ((ExtendedCondition)getFirstCondition()).match(e, pseudoE) && - ((ExtendedCondition)getSecondCondition()).match(e, pseudoE); - } + return ((ExtendedCondition)getFirstCondition()).match(e, pseudoE) && + ((ExtendedCondition)getSecondCondition()).match(e, pseudoE); + } - /** - * Fills the given set with the attribute names found in this selector. - */ - @Override - public void fillAttributeSet(Set attrSet) { - ((ExtendedCondition)getFirstCondition()).fillAttributeSet(attrSet); - ((ExtendedCondition)getSecondCondition()).fillAttributeSet(attrSet); - } + /** + * Fills the given set with the attribute names found in this selector. + */ + @Override + public void fillAttributeSet(Set<String> attrSet) { + ((ExtendedCondition)getFirstCondition()).fillAttributeSet(attrSet); + ((ExtendedCondition)getSecondCondition()).fillAttributeSet(attrSet); + } - /** - * Returns a text representation of this object. - */ - @Override + /** + * Returns a text representation of this object. + */ + @Override public String toString() { - return String.valueOf( getFirstCondition() ) + getSecondCondition(); - } + return String.valueOf( getFirstCondition() ) + getSecondCondition(); + } } diff --git a/bundles/org.eclipse.e4.ui.css.core/src/org/eclipse/e4/ui/css/core/impl/sac/CSSAttributeConditionImpl.java b/bundles/org.eclipse.e4.ui.css.core/src/org/eclipse/e4/ui/css/core/impl/sac/CSSAttributeConditionImpl.java index 219ad9c36fc..58fa2642c56 100644 --- a/bundles/org.eclipse.e4.ui.css.core/src/org/eclipse/e4/ui/css/core/impl/sac/CSSAttributeConditionImpl.java +++ b/bundles/org.eclipse.e4.ui.css.core/src/org/eclipse/e4/ui/css/core/impl/sac/CSSAttributeConditionImpl.java @@ -134,7 +134,7 @@ public class CSSAttributeConditionImpl extends AbstractAttributeCondition { * Fills the given set with the attribute names found in this selector. */ @Override - public void fillAttributeSet(Set attrSet) { + public void fillAttributeSet(Set<String> attrSet) { attrSet.add(localName); } diff --git a/bundles/org.eclipse.e4.ui.css.core/src/org/eclipse/e4/ui/css/core/impl/sac/CSSChildSelectorImpl.java b/bundles/org.eclipse.e4.ui.css.core/src/org/eclipse/e4/ui/css/core/impl/sac/CSSChildSelectorImpl.java index 9252d4575a6..87d6b0acd03 100644 --- a/bundles/org.eclipse.e4.ui.css.core/src/org/eclipse/e4/ui/css/core/impl/sac/CSSChildSelectorImpl.java +++ b/bundles/org.eclipse.e4.ui.css.core/src/org/eclipse/e4/ui/css/core/impl/sac/CSSChildSelectorImpl.java @@ -21,7 +21,6 @@ package org.eclipse.e4.ui.css.core.impl.sac; import java.util.Set; - import org.w3c.css.sac.Selector; import org.w3c.css.sac.SimpleSelector; import org.w3c.dom.Element; @@ -33,54 +32,54 @@ import org.w3c.dom.Node; */ public class CSSChildSelectorImpl extends AbstractDescendantSelector { - /** - * Creates a new CSSChildSelector object. - */ - public CSSChildSelectorImpl(Selector ancestor, SimpleSelector simple) { - super(ancestor, simple); - } + /** + * Creates a new CSSChildSelector object. + */ + public CSSChildSelectorImpl(Selector ancestor, SimpleSelector simple) { + super(ancestor, simple); + } - /** - * <b>SAC</b>: Implements {@link - * org.w3c.css.sac.Selector#getSelectorType()}. - */ - @Override + /** + * <b>SAC</b>: Implements {@link + * org.w3c.css.sac.Selector#getSelectorType()}. + */ + @Override public short getSelectorType() { - return SAC_CHILD_SELECTOR; - } + return SAC_CHILD_SELECTOR; + } - /** - * Tests whether this selector matches the given element. - */ - @Override + /** + * Tests whether this selector matches the given element. + */ + @Override public boolean match(Element e, String pseudoE) { - Node n = e.getParentNode(); - if (n != null && n.getNodeType() == Node.ELEMENT_NODE) { - return ((ExtendedSelector)getAncestorSelector()).match((Element)n, - null) && - ((ExtendedSelector)getSimpleSelector()).match(e, pseudoE); - } - return false; - } + Node n = e.getParentNode(); + if (n != null && n.getNodeType() == Node.ELEMENT_NODE) { + return ((ExtendedSelector)getAncestorSelector()).match((Element)n, + null) && + ((ExtendedSelector)getSimpleSelector()).match(e, pseudoE); + } + return false; + } - /** - * Fills the given set with the attribute names found in this selector. - */ - @Override - public void fillAttributeSet(Set attrSet) { - ((ExtendedSelector)getAncestorSelector()).fillAttributeSet(attrSet); - ((ExtendedSelector)getSimpleSelector()).fillAttributeSet(attrSet); - } + /** + * Fills the given set with the attribute names found in this selector. + */ + @Override + public void fillAttributeSet(Set<String> attrSet) { + ((ExtendedSelector)getAncestorSelector()).fillAttributeSet(attrSet); + ((ExtendedSelector)getSimpleSelector()).fillAttributeSet(attrSet); + } - /** - * Returns a representation of the selector. - */ - @Override + /** + * Returns a representation of the selector. + */ + @Override public String toString() { - SimpleSelector s = getSimpleSelector(); - if (s.getSelectorType() == SAC_PSEUDO_ELEMENT_SELECTOR) { - return String.valueOf( getAncestorSelector() ) + s; - } - return getAncestorSelector() + " > " + s; - } + SimpleSelector s = getSimpleSelector(); + if (s.getSelectorType() == SAC_PSEUDO_ELEMENT_SELECTOR) { + return String.valueOf( getAncestorSelector() ) + s; + } + return getAncestorSelector() + " > " + s; + } } diff --git a/bundles/org.eclipse.e4.ui.css.core/src/org/eclipse/e4/ui/css/core/impl/sac/CSSConditionalSelectorImpl.java b/bundles/org.eclipse.e4.ui.css.core/src/org/eclipse/e4/ui/css/core/impl/sac/CSSConditionalSelectorImpl.java index d10461f57ec..0a7085589b7 100644 --- a/bundles/org.eclipse.e4.ui.css.core/src/org/eclipse/e4/ui/css/core/impl/sac/CSSConditionalSelectorImpl.java +++ b/bundles/org.eclipse.e4.ui.css.core/src/org/eclipse/e4/ui/css/core/impl/sac/CSSConditionalSelectorImpl.java @@ -21,7 +21,6 @@ package org.eclipse.e4.ui.css.core.impl.sac; import java.util.Set; - import org.w3c.css.sac.Condition; import org.w3c.css.sac.ConditionalSelector; import org.w3c.css.sac.SimpleSelector; @@ -31,101 +30,99 @@ import org.w3c.dom.Element; * This class provides an implementation of the * {@link org.w3c.css.sac.ConditionalSelector} interface. */ -public class CSSConditionalSelectorImpl - implements ConditionalSelector, - ExtendedSelector { - - /** - * The simple selector. - */ - protected SimpleSelector simpleSelector; - - /** - * The condition. - */ - protected Condition condition; - - /** - * Creates a new ConditionalSelector object. - */ - public CSSConditionalSelectorImpl(SimpleSelector s, Condition c) { - simpleSelector = s; - condition = c; - } - - /** - * Indicates whether some other object is "equal to" this one. - * @param obj the reference object with which to compare. - */ - @Override +public class CSSConditionalSelectorImpl implements ConditionalSelector, ExtendedSelector { + + /** + * The simple selector. + */ + protected SimpleSelector simpleSelector; + + /** + * The condition. + */ + protected Condition condition; + + /** + * Creates a new ConditionalSelector object. + */ + public CSSConditionalSelectorImpl(SimpleSelector s, Condition c) { + simpleSelector = s; + condition = c; + } + + /** + * Indicates whether some other object is "equal to" this one. + * @param obj the reference object with which to compare. + */ + @Override public boolean equals(Object obj) { - if (obj == null || (obj.getClass() != getClass())) { - return false; - } - CSSConditionalSelectorImpl s = (CSSConditionalSelectorImpl)obj; - return (s.simpleSelector.equals(simpleSelector) && - s.condition.equals(condition)); - } - - /** - * <b>SAC</b>: Implements {@link - * org.w3c.css.sac.Selector#getSelectorType()}. - */ - @Override + if (obj == null || (obj.getClass() != getClass())) { + return false; + } + CSSConditionalSelectorImpl s = (CSSConditionalSelectorImpl)obj; + return (s.simpleSelector.equals(simpleSelector) && + s.condition.equals(condition)); + } + + /** + * <b>SAC</b>: Implements {@link + * org.w3c.css.sac.Selector#getSelectorType()}. + */ + @Override public short getSelectorType() { - return SAC_CONDITIONAL_SELECTOR; - } + return SAC_CONDITIONAL_SELECTOR; + } - /** - * Tests whether this selector matches the given element. - */ - @Override + /** + * Tests whether this selector matches the given element. + */ + @Override public boolean match(Element e, String pseudoE) { - return ((ExtendedSelector)getSimpleSelector()).match(e, pseudoE) && - ((ExtendedCondition)getCondition()).match(e, pseudoE); - } - - /** - * Fills the given set with the attribute names found in this selector. - */ - @Override - public void fillAttributeSet(Set attrSet) { - ((ExtendedSelector)getSimpleSelector()).fillAttributeSet(attrSet); - ((ExtendedCondition)getCondition()).fillAttributeSet(attrSet); - } - - /** - * Returns the specificity of this selector. - */ - @Override + return ((ExtendedSelector)getSimpleSelector()).match(e, pseudoE) && + ((ExtendedCondition)getCondition()).match(e, pseudoE); + } + + /** + * Fills the given set with the attribute names found in this selector. + */ + @Override + public void fillAttributeSet(Set<String> attrSet) { + ((ExtendedSelector)getSimpleSelector()).fillAttributeSet(attrSet); + ((ExtendedCondition)getCondition()).fillAttributeSet(attrSet); + } + + /** + * Returns the specificity of this selector. + */ + @Override public int getSpecificity() { - return ((ExtendedSelector)getSimpleSelector()).getSpecificity() + - ((ExtendedCondition)getCondition()).getSpecificity(); - } - - /** - * <b>SAC</b>: Implements {@link - * org.w3c.css.sac.ConditionalSelector#getSimpleSelector()}. - */ - @Override + return ((ExtendedSelector)getSimpleSelector()).getSpecificity() + + ((ExtendedCondition)getCondition()).getSpecificity(); + } + + /** + * <b>SAC</b>: Implements {@link + * org.w3c.css.sac.ConditionalSelector#getSimpleSelector()}. + */ + @Override public SimpleSelector getSimpleSelector() { - return simpleSelector; - } - - /** - * <b>SAC</b>: Implements {@link - * org.w3c.css.sac.ConditionalSelector#getCondition()}. - */ - @Override + return simpleSelector; + } + + /** + * <b>SAC</b>: Implements {@link + * org.w3c.css.sac.ConditionalSelector#getCondition()}. + */ + @Override public Condition getCondition() { - return condition; - } + return condition; + } - /** - * Returns a representation of the selector. - */ - @Override + /** + * Returns a representation of the selector. + */ + @Override public String toString() { - return String.valueOf( simpleSelector ) + condition; - } + return String.valueOf( simpleSelector ) + condition; + } } diff --git a/bundles/org.eclipse.e4.ui.css.core/src/org/eclipse/e4/ui/css/core/impl/sac/CSSDescendantSelectorImpl.java b/bundles/org.eclipse.e4.ui.css.core/src/org/eclipse/e4/ui/css/core/impl/sac/CSSDescendantSelectorImpl.java index dfc7e804ab7..078f9fb0ad8 100644 --- a/bundles/org.eclipse.e4.ui.css.core/src/org/eclipse/e4/ui/css/core/impl/sac/CSSDescendantSelectorImpl.java +++ b/bundles/org.eclipse.e4.ui.css.core/src/org/eclipse/e4/ui/css/core/impl/sac/CSSDescendantSelectorImpl.java @@ -21,7 +21,6 @@ package org.eclipse.e4.ui.css.core.impl.sac; import java.util.Set; - import org.w3c.css.sac.Selector; import org.w3c.css.sac.SimpleSelector; import org.w3c.dom.Element; @@ -33,52 +32,53 @@ import org.w3c.dom.Node; */ public class CSSDescendantSelectorImpl extends AbstractDescendantSelector { - /** - * Creates a new CSSDescendantSelector object. - */ - public CSSDescendantSelectorImpl(Selector ancestor, SimpleSelector simple) { - super(ancestor, simple); - } + /** + * Creates a new CSSDescendantSelector object. + */ + public CSSDescendantSelectorImpl(Selector ancestor, SimpleSelector simple) { + super(ancestor, simple); + } - /** - * <b>SAC</b>: Implements {@link - * org.w3c.css.sac.Selector#getSelectorType()}. - */ - @Override + /** + * <b>SAC</b>: Implements {@link + * org.w3c.css.sac.Selector#getSelectorType()}. + */ + @Override public short getSelectorType() { - return SAC_DESCENDANT_SELECTOR; - } + return SAC_DESCENDANT_SELECTOR; + } - /** - * Tests whether this selector matches the given element. - */ - @Override + /** + * Tests whether this selector matches the given element. + */ + @Override public boolean match(Element e, String pseudoE) { - ExtendedSelector p = (ExtendedSelector)getAncestorSelector(); - if (!((ExtendedSelector)getSimpleSelector()).match(e,pseudoE)) - return false; - for (Node n = e.getParentNode(); n != null; n = n.getParentNode()) { - if (n.getNodeType() == Node.ELEMENT_NODE && - p.match((Element)n, null)) { - return true; - } - } - return false; - } + ExtendedSelector p = (ExtendedSelector)getAncestorSelector(); + if (!((ExtendedSelector)getSimpleSelector()).match(e,pseudoE)) { + return false; + } + for (Node n = e.getParentNode(); n != null; n = n.getParentNode()) { + if (n.getNodeType() == Node.ELEMENT_NODE && + p.match((Element)n, null)) { + return true; + } + } + return false; + } - /** - * Fills the given set with the attribute names found in this selector. - */ - @Override - public void fillAttributeSet(Set attrSet) { - ((ExtendedSelector)getSimpleSelector()).fillAttributeSet(attrSet); - } + /** + * Fills the given set with the attribute names found in this selector. + */ + @Override + public void fillAttributeSet(Set<String> attrSet) { + ((ExtendedSelector)getSimpleSelector()).fillAttributeSet(attrSet); + } - /** - * Returns a representation of the selector. - */ - @Override + /** + * Returns a representation of the selector. + */ + @Override public String toString() { - return getAncestorSelector() + " " + getSimpleSelector(); - } + return getAncestorSelector() + " " + getSimpleSelector(); + } } diff --git a/bundles/org.eclipse.e4.ui.css.core/src/org/eclipse/e4/ui/css/core/impl/sac/CSSDirectAdjacentSelectorImpl.java b/bundles/org.eclipse.e4.ui.css.core/src/org/eclipse/e4/ui/css/core/impl/sac/CSSDirectAdjacentSelectorImpl.java index 13bab4913f2..219d85e5d71 100644 --- a/bundles/org.eclipse.e4.ui.css.core/src/org/eclipse/e4/ui/css/core/impl/sac/CSSDirectAdjacentSelectorImpl.java +++ b/bundles/org.eclipse.e4.ui.css.core/src/org/eclipse/e4/ui/css/core/impl/sac/CSSDirectAdjacentSelectorImpl.java @@ -21,7 +21,6 @@ package org.eclipse.e4.ui.css.core.impl.sac; import java.util.Set; - import org.w3c.css.sac.Selector; import org.w3c.css.sac.SimpleSelector; import org.w3c.dom.Element; @@ -33,55 +32,56 @@ import org.w3c.dom.Node; */ public class CSSDirectAdjacentSelectorImpl extends AbstractSiblingSelector { - /** - * Creates a new CSSDirectAdjacentSelector object. - */ - public CSSDirectAdjacentSelectorImpl(short type, - Selector parent, - SimpleSelector simple) { - super(type, parent, simple); - } - - /** - * <b>SAC</b>: Implements {@link - * org.w3c.css.sac.Selector#getSelectorType()}. - */ - @Override + /** + * Creates a new CSSDirectAdjacentSelector object. + */ + public CSSDirectAdjacentSelectorImpl(short type, Selector parent, SimpleSelector simple) { + super(type, parent, simple); + } + + /** + * <b>SAC</b>: Implements {@link + * org.w3c.css.sac.Selector#getSelectorType()}. + */ + @Override public short getSelectorType() { - return SAC_DIRECT_ADJACENT_SELECTOR; - } + return SAC_DIRECT_ADJACENT_SELECTOR; + } - /** - * Tests whether this selector matches the given element. - */ - @Override + /** + * Tests whether this selector matches the given element. + */ + @Override public boolean match(Element e, String pseudoE) { - Node n = e; - if (!((ExtendedSelector)getSiblingSelector()).match(e, pseudoE)) - return false; - while ((n = n.getPreviousSibling()) != null && - n.getNodeType() != Node.ELEMENT_NODE); - - if (n == null) - return false; - - return ((ExtendedSelector)getSelector()).match((Element)n, null); - } - - /** - * Fills the given set with the attribute names found in this selector. - */ - @Override - public void fillAttributeSet(Set attrSet) { - ((ExtendedSelector)getSelector()).fillAttributeSet(attrSet); - ((ExtendedSelector)getSiblingSelector()).fillAttributeSet(attrSet); - } - - /** - * Returns a representation of the selector. - */ - @Override + Node n = e; + if (!((ExtendedSelector)getSiblingSelector()).match(e, pseudoE)) { + return false; + } + while ((n = n.getPreviousSibling()) != null && n.getNodeType() != Node.ELEMENT_NODE) { + ; + } + + if (n == null) { + return false; + } + + return ((ExtendedSelector)getSelector()).match((Element)n, null); + } + + /** + * Fills the given set with the attribute names found in this selector. + */ + @Override + public void fillAttributeSet(Set<String> attrSet) { + ((ExtendedSelector)getSelector()).fillAttributeSet(attrSet); + ((ExtendedSelector)getSiblingSelector()).fillAttributeSet(attrSet); + } + + /** + * Returns a representation of the selector. + */ + @Override public String toString() { - return getSelector() + " + " + getSiblingSelector(); - } + return getSelector() + " + " + getSiblingSelector(); + } } diff --git a/bundles/org.eclipse.e4.ui.css.core/src/org/eclipse/e4/ui/css/core/impl/sac/CSSDocumentHandlerImpl.java b/bundles/org.eclipse.e4.ui.css.core/src/org/eclipse/e4/ui/css/core/impl/sac/CSSDocumentHandlerImpl.java index 7aba018450c..91f4198a56a 100644 --- a/bundles/org.eclipse.e4.ui.css.core/src/org/eclipse/e4/ui/css/core/impl/sac/CSSDocumentHandlerImpl.java +++ b/bundles/org.eclipse.e4.ui.css.core/src/org/eclipse/e4/ui/css/core/impl/sac/CSSDocumentHandlerImpl.java @@ -1,5 +1,4 @@ /******************************************************************************* - * Copyright (c) 2008, 2009 Angelo Zerr and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -12,7 +11,6 @@ package org.eclipse.e4.ui.css.core.impl.sac; import java.util.Stack; - import org.eclipse.e4.ui.css.core.dom.CSSProperty; import org.eclipse.e4.ui.css.core.impl.dom.CSSImportRuleImpl; import org.eclipse.e4.ui.css.core.impl.dom.CSSPageRuleImpl; @@ -39,8 +37,8 @@ import org.w3c.dom.css.CSSStyleSheet; */ public class CSSDocumentHandlerImpl implements ExtendedDocumentHandler { - private Stack nodeStack; - private Object nodeRoot = null; + private Stack<Object> nodeStack; + private Object nodeRoot; private CSSStyleSheet parentStyleSheet; @@ -99,10 +97,10 @@ public class CSSDocumentHandlerImpl implements ExtendedDocumentHandler { public void namespaceDeclaration(String prefix, String uri) throws CSSException { //TODO replace with eclipse logging -// if (logger.isDebugEnabled()) { -// logger.debug("Declare namespace [prefix=" + prefix + ", uri=" + uri -// + "]"); -// } + // if (logger.isDebugEnabled()) { + // logger.debug("Declare namespace [prefix=" + prefix + ", uri=" + uri + // + "]"); + // } } @Override @@ -124,27 +122,27 @@ public class CSSDocumentHandlerImpl implements ExtendedDocumentHandler { public void startMedia(SACMediaList media) throws CSSException { ignore = true; -// // Create the media rule and add it to the rule list -// CSSMediaRuleImpl mr = new CSSMediaRuleImpl(parentStyleSheet, null, -// new MediaListImpl(media)); -// if (!getNodeStack().empty()) { -// ((CSSRuleListImpl) getNodeStack().peek()).add(mr); -// } -// -// // Create the rule list -// CSSRuleListImpl rules = new CSSRuleListImpl(); -// mr.setRuleList(rules); -// getNodeStack().push(mr); -// getNodeStack().push(rules); + // // Create the media rule and add it to the rule list + // CSSMediaRuleImpl mr = new CSSMediaRuleImpl(parentStyleSheet, null, + // new MediaListImpl(media)); + // if (!getNodeStack().empty()) { + // ((CSSRuleListImpl) getNodeStack().peek()).add(mr); + // } + // + // // Create the rule list + // CSSRuleListImpl rules = new CSSRuleListImpl(); + // mr.setRuleList(rules); + // getNodeStack().push(mr); + // getNodeStack().push(rules); } @Override public void endMedia(SACMediaList media) throws CSSException { ignore = false; -// // Pop the rule list and media rule nodes -// getNodeStack().pop(); -// nodeRoot = getNodeStack().pop(); + // // Pop the rule list and media rule nodes + // getNodeStack().pop(); + // nodeRoot = getNodeStack().pop(); } @Override @@ -175,26 +173,26 @@ public class CSSDocumentHandlerImpl implements ExtendedDocumentHandler { @Override public void startFontFace() throws CSSException { ignore = true; -// // Create the font face rule and add it to the rule list -// CSSFontFaceRuleImpl fontFaceRule = new CSSFontFaceRuleImpl( -// parentStyleSheet, null); -// if (!getNodeStack().empty()) { -// ((CSSRuleListImpl) getNodeStack().peek()).add(fontFaceRule); -// } -// -// // Create the style declaration -// CSSStyleDeclarationImpl decl = new CSSStyleDeclarationImpl(fontFaceRule); -// fontFaceRule.setStyle(decl); -// getNodeStack().push(fontFaceRule); -// getNodeStack().push(decl); + // // Create the font face rule and add it to the rule list + // CSSFontFaceRuleImpl fontFaceRule = new CSSFontFaceRuleImpl( + // parentStyleSheet, null); + // if (!getNodeStack().empty()) { + // ((CSSRuleListImpl) getNodeStack().peek()).add(fontFaceRule); + // } + // + // // Create the style declaration + // CSSStyleDeclarationImpl decl = new CSSStyleDeclarationImpl(fontFaceRule); + // fontFaceRule.setStyle(decl); + // getNodeStack().push(fontFaceRule); + // getNodeStack().push(decl); } @Override public void endFontFace() throws CSSException { ignore = false; -// // Pop both the style declaration and the font face rule nodes -// getNodeStack().pop(); -// nodeRoot = getNodeStack().pop(); + // // Pop both the style declaration and the font face rule nodes + // getNodeStack().pop(); + // nodeRoot = getNodeStack().pop(); } @Override @@ -226,8 +224,7 @@ public class CSSDocumentHandlerImpl implements ExtendedDocumentHandler { public void property(String name, LexicalUnit value, boolean important) throws CSSException { if (!ignore) { - CSSStyleDeclarationImpl decl = (CSSStyleDeclarationImpl) getNodeStack() - .peek(); + CSSStyleDeclarationImpl decl = (CSSStyleDeclarationImpl) getNodeStack().peek(); decl.addProperty(getCSSProperty(decl, name, value, important)); } } @@ -243,13 +240,14 @@ public class CSSDocumentHandlerImpl implements ExtendedDocumentHandler { } @Override - public void setNodeStack(Stack nodeStack) { + public void setNodeStack(Stack<Object> nodeStack) { this.nodeStack = nodeStack; } - public Stack getNodeStack() { - if (nodeStack == null) - nodeStack = new Stack(); + public Stack<Object> getNodeStack() { + if (nodeStack == null) { + nodeStack = new Stack<>(); + } return nodeStack; } diff --git a/bundles/org.eclipse.e4.ui.css.core/src/org/eclipse/e4/ui/css/core/impl/sac/CSSIdConditionImpl.java b/bundles/org.eclipse.e4.ui.css.core/src/org/eclipse/e4/ui/css/core/impl/sac/CSSIdConditionImpl.java index 5da6dd2cca8..27d33bc68dd 100644 --- a/bundles/org.eclipse.e4.ui.css.core/src/org/eclipse/e4/ui/css/core/impl/sac/CSSIdConditionImpl.java +++ b/bundles/org.eclipse.e4.ui.css.core/src/org/eclipse/e4/ui/css/core/impl/sac/CSSIdConditionImpl.java @@ -21,7 +21,6 @@ package org.eclipse.e4.ui.css.core.impl.sac; import java.util.Set; - import org.eclipse.e4.ui.css.core.dom.CSSStylableElement; import org.w3c.dom.Element; @@ -94,10 +93,12 @@ public class CSSIdConditionImpl extends AbstractAttributeCondition { String id = null; if (e instanceof CSSStylableElement) { id = ((CSSStylableElement) e).getCSSId(); - } else + } else { id = e.getAttribute("id"); - if (id == null) + } + if (id == null) { return false; + } return id.equals(getValue()); // return super.match(e, pseudoE); } @@ -106,7 +107,7 @@ public class CSSIdConditionImpl extends AbstractAttributeCondition { * Fills the given set with the attribute names found in this selector. */ @Override - public void fillAttributeSet(Set attrSet) { + public void fillAttributeSet(Set<String> attrSet) { attrSet.add(localName); } diff --git a/bundles/org.eclipse.e4.ui.css.core/src/org/eclipse/e4/ui/css/core/impl/sac/CSSLangConditionImpl.java b/bundles/org.eclipse.e4.ui.css.core/src/org/eclipse/e4/ui/css/core/impl/sac/CSSLangConditionImpl.java index acf836f8f91..f2a0909da6f 100644 --- a/bundles/org.eclipse.e4.ui.css.core/src/org/eclipse/e4/ui/css/core/impl/sac/CSSLangConditionImpl.java +++ b/bundles/org.eclipse.e4.ui.css.core/src/org/eclipse/e4/ui/css/core/impl/sac/CSSLangConditionImpl.java @@ -21,7 +21,6 @@ package org.eclipse.e4.ui.css.core.impl.sac; import java.util.Set; - import org.w3c.css.sac.LangCondition; import org.w3c.dom.Element; @@ -29,92 +28,90 @@ import org.w3c.dom.Element; * This class provides an implementation of the * {@link org.w3c.css.sac.LangCondition} interface. */ -public class CSSLangConditionImpl - implements LangCondition, - ExtendedCondition { - /** - * The language. - */ - protected String lang; - - /** - * The language with a hyphen suffixed. - */ - protected String langHyphen; - - /** - * Creates a new LangCondition object. - */ - public CSSLangConditionImpl(String lang) { - this.lang = lang.toLowerCase(); - this.langHyphen = lang + '-'; - } - - /** - * Indicates whether some other object is "equal to" this one. - * @param obj the reference object with which to compare. - */ - @Override +public class CSSLangConditionImpl implements LangCondition, ExtendedCondition { + /** + * The language. + */ + protected String lang; + + /** + * The language with a hyphen suffixed. + */ + protected String langHyphen; + + /** + * Creates a new LangCondition object. + */ + public CSSLangConditionImpl(String lang) { + this.lang = lang.toLowerCase(); + this.langHyphen = lang + '-'; + } + + /** + * Indicates whether some other object is "equal to" this one. + * @param obj the reference object with which to compare. + */ + @Override public boolean equals(Object obj) { - if (obj == null || (obj.getClass() != getClass())) { - return false; - } - CSSLangConditionImpl c = (CSSLangConditionImpl)obj; - return c.lang.equals(lang); - } - - /** - * <b>SAC</b>: Implements {@link - * org.w3c.css.sac.Condition#getConditionType()}. - */ - @Override + if (obj == null || (obj.getClass() != getClass())) { + return false; + } + CSSLangConditionImpl c = (CSSLangConditionImpl)obj; + return c.lang.equals(lang); + } + + /** + * <b>SAC</b>: Implements {@link + * org.w3c.css.sac.Condition#getConditionType()}. + */ + @Override public short getConditionType() { - return SAC_LANG_CONDITION; - } + return SAC_LANG_CONDITION; + } - /** - * <b>SAC</b>: Implements {@link org.w3c.css.sac.LangCondition#getLang()}. - */ - @Override + /** + * <b>SAC</b>: Implements {@link org.w3c.css.sac.LangCondition#getLang()}. + */ + @Override public String getLang() { - return lang; - } + return lang; + } - /** - * Returns the specificity of this condition. - */ - @Override + /** + * Returns the specificity of this condition. + */ + @Override public int getSpecificity() { - return 1 << 8; - } + return 1 << 8; + } - /** - * Tests whether this condition matches the given element. - */ - @Override + /** + * Tests whether this condition matches the given element. + */ + @Override public boolean match(Element e, String pseudoE) { - String s = e.getAttribute("lang").toLowerCase(); - if (s.equals(lang) || s.startsWith(langHyphen)) { - return true; - } -// s = e.getAttributeNS(XMLConstants.XML_NAMESPACE_URI, -// XMLConstants.XML_LANG_ATTRIBUTE).toLowerCase(); - return s.equals(lang) || s.startsWith(langHyphen); - } - - /** - * Fills the given set with the attribute names found in this selector. - */ - @Override - public void fillAttributeSet(Set attrSet) { - attrSet.add("lang"); - } - - /** - * Returns a text representation of this object. - */ - @Override + String s = e.getAttribute("lang").toLowerCase(); + if (s.equals(lang) || s.startsWith(langHyphen)) { + return true; + } + // s = e.getAttributeNS(XMLConstants.XML_NAMESPACE_URI, + // XMLConstants.XML_LANG_ATTRIBUTE).toLowerCase(); + return s.equals(lang) || s.startsWith(langHyphen); + } + + /** + * Fills the given set with the attribute names found in this selector. + */ + @Override + public void fillAttributeSet(Set<String> attrSet) { + attrSet.add("lang"); + } + + /** + * Returns a text representation of this object. + */ + @Override public String toString() { - return ":lang(" + lang + ')'; - } + return ":lang(" + lang + ')'; + } } diff --git a/bundles/org.eclipse.e4.ui.css.core/src/org/eclipse/e4/ui/css/core/impl/sac/CSSPseudoClassConditionImpl.java b/bundles/org.eclipse.e4.ui.css.core/src/org/eclipse/e4/ui/css/core/impl/sac/CSSPseudoClassConditionImpl.java index c46486ba24b..5ee68d854d9 100644 --- a/bundles/org.eclipse.e4.ui.css.core/src/org/eclipse/e4/ui/css/core/impl/sac/CSSPseudoClassConditionImpl.java +++ b/bundles/org.eclipse.e4.ui.css.core/src/org/eclipse/e4/ui/css/core/impl/sac/CSSPseudoClassConditionImpl.java @@ -21,7 +21,6 @@ package org.eclipse.e4.ui.css.core.impl.sac; import java.util.Set; - import org.eclipse.e4.ui.css.core.dom.CSSStylableElement; import org.w3c.dom.Element; @@ -109,15 +108,18 @@ public class CSSPseudoClassConditionImpl extends AbstractAttributeCondition { */ @Override public boolean match(Element e, String pseudoE) { - if (pseudoE != null && !pseudoE.equals(getValue())) + if (pseudoE != null && !pseudoE.equals(getValue())) { // pseudo instance is filled, it is not valid. return false; - if (!(e instanceof CSSStylableElement)) + } + if (!(e instanceof CSSStylableElement)) { return false; + } CSSStylableElement element = (CSSStylableElement) e; boolean isPseudoInstanceOf = element.isPseudoInstanceOf(getValue()); - if (!isPseudoInstanceOf) + if (!isPseudoInstanceOf) { return false; + } if (pseudoE == null) { // pseudo element is not filled. // test if this CSSPseudoClassCondition is NOT a static pseudo @@ -131,7 +133,7 @@ public class CSSPseudoClassConditionImpl extends AbstractAttributeCondition { * Fills the given set with the attribute names found in this selector. */ @Override - public void fillAttributeSet(Set attrSet) { + public void fillAttributeSet(Set<String> attrSet) { } /** diff --git a/bundles/org.eclipse.e4.ui.css.core/src/org/eclipse/e4/ui/css/core/impl/sac/ExtendedCondition.java b/bundles/org.eclipse.e4.ui.css.core/src/org/eclipse/e4/ui/css/core/impl/sac/ExtendedCondition.java index 295bf6d6023..26c1a21acd4 100644 --- a/bundles/org.eclipse.e4.ui.css.core/src/org/eclipse/e4/ui/css/core/impl/sac/ExtendedCondition.java +++ b/bundles/org.eclipse.e4.ui.css.core/src/org/eclipse/e4/ui/css/core/impl/sac/ExtendedCondition.java @@ -21,7 +21,6 @@ package org.eclipse.e4.ui.css.core.impl.sac; import java.util.Set; - import org.w3c.css.sac.Condition; import org.w3c.dom.Element; @@ -31,18 +30,18 @@ import org.w3c.dom.Element; */ public interface ExtendedCondition extends Condition { - /** - * Tests whether this condition matches the given element. - */ - boolean match(Element e, String pseudoE); + /** + * Tests whether this condition matches the given element. + */ + boolean match(Element e, String pseudoE); - /** - * Returns the specificity of this condition. - */ - int getSpecificity(); + /** + * Returns the specificity of this condition. + */ + int getSpecificity(); - /** - * Fills the given set with the attribute names found in this selector. - */ - void fillAttributeSet(Set attrSet); + /** + * Fills the given set with the attribute names found in this selector. + */ + void fillAttributeSet(Set<String> attrSet); } diff --git a/bundles/org.eclipse.e4.ui.css.core/src/org/eclipse/e4/ui/css/core/impl/sac/ExtendedSelector.java b/bundles/org.eclipse.e4.ui.css.core/src/org/eclipse/e4/ui/css/core/impl/sac/ExtendedSelector.java index 62f9925fe96..08733998888 100644 --- a/bundles/org.eclipse.e4.ui.css.core/src/org/eclipse/e4/ui/css/core/impl/sac/ExtendedSelector.java +++ b/bundles/org.eclipse.e4.ui.css.core/src/org/eclipse/e4/ui/css/core/impl/sac/ExtendedSelector.java @@ -21,7 +21,6 @@ package org.eclipse.e4.ui.css.core.impl.sac; import java.util.Set; - import org.w3c.css.sac.Selector; import org.w3c.dom.Element; @@ -43,5 +42,5 @@ public interface ExtendedSelector extends Selector { /** * Fills the given set with the attribute names found in this selector. */ - void fillAttributeSet(Set attrSet); + void fillAttributeSet(Set<String> attrSet); } diff --git a/bundles/org.eclipse.e4.ui.css.core/src/org/eclipse/e4/ui/css/core/impl/sac/SACParserFactoryImpl.java b/bundles/org.eclipse.e4.ui.css.core/src/org/eclipse/e4/ui/css/core/impl/sac/SACParserFactoryImpl.java index 1b991503558..c6957707565 100644 --- a/bundles/org.eclipse.e4.ui.css.core/src/org/eclipse/e4/ui/css/core/impl/sac/SACParserFactoryImpl.java +++ b/bundles/org.eclipse.e4.ui.css.core/src/org/eclipse/e4/ui/css/core/impl/sac/SACParserFactoryImpl.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2008 Angelo Zerr and others. + * Copyright (c) 2008, 2015 Angelo Zerr and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -12,7 +12,6 @@ package org.eclipse.e4.ui.css.core.impl.sac; import java.util.HashMap; import java.util.Map; - import org.eclipse.e4.ui.css.core.SACConstants; import org.eclipse.e4.ui.css.core.sac.SACParserFactory; import org.w3c.css.sac.Parser; @@ -23,7 +22,7 @@ import org.w3c.css.sac.Parser; */ public class SACParserFactoryImpl extends SACParserFactory { - private static Map parsers = new HashMap(); + private static Map<String, String> parsers = new HashMap<>(); static { // Register Flute SAC Parser @@ -41,19 +40,12 @@ public class SACParserFactoryImpl extends SACParserFactory { super.setPreferredParserName(SACConstants.SACPARSER_BATIK); } - /* - * (non-Javadoc) - * - * @see org.akrogen.tkui.core.css.sac.SACParserFactory#makeParser(java.lang.String) - */ @Override - public Parser makeParser(String name) throws ClassNotFoundException, - IllegalAccessException, InstantiationException, - NullPointerException, ClassCastException { - String classNameParser = (String) parsers.get(name); + public Parser makeParser(String name) throws ClassNotFoundException, IllegalAccessException, InstantiationException, + NullPointerException, ClassCastException { + String classNameParser = parsers.get(name); if (classNameParser != null) { - Class classParser = super.getClass().getClassLoader().loadClass( - classNameParser); + Class<?> classParser = super.getClass().getClassLoader().loadClass(classNameParser); return (Parser) classParser.newInstance(); } throw new IllegalAccessException("SAC parser with name=" + name diff --git a/bundles/org.eclipse.e4.ui.css.core/src/org/eclipse/e4/ui/css/core/resources/AbstractResourcesRegistry.java b/bundles/org.eclipse.e4.ui.css.core/src/org/eclipse/e4/ui/css/core/resources/AbstractResourcesRegistry.java index 1af8d730bc0..8c0506d3b44 100644 --- a/bundles/org.eclipse.e4.ui.css.core/src/org/eclipse/e4/ui/css/core/resources/AbstractResourcesRegistry.java +++ b/bundles/org.eclipse.e4.ui.css.core/src/org/eclipse/e4/ui/css/core/resources/AbstractResourcesRegistry.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2008, 2013 Angelo Zerr and others. + * Copyright (c) 2008, 2015 Angelo Zerr and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -13,8 +13,8 @@ package org.eclipse.e4.ui.css.core.resources; import java.util.Collections; import java.util.HashMap; -import java.util.Iterator; import java.util.Map; +import java.util.Map.Entry; import java.util.Set; /** @@ -26,48 +26,36 @@ import java.util.Set; */ public abstract class AbstractResourcesRegistry implements IResourcesRegistry { - private Map allResourcesMap = null; + private Map<Object, Map<Object, Object>> allResourcesMap; - /* - * (non-Javadoc) - * - * @see org.eclipse.e4.ui.core.css.resources.IResourcesRegistry#getResource(java.lang.Object, - * java.lang.Object) - */ @Override public Object getResource(Object type, Object key) { if (allResourcesMap == null) { return null; } - Map resourcesMap = (Map) allResourcesMap.get(type); + Map<Object, Object> resourcesMap = allResourcesMap.get(type); if (resourcesMap == null) { return null; } return resourcesMap.get(key); } - /* - * (non-Javadoc) - * - * @see org.eclipse.e4.ui.core.css.resources.IResourcesRegistry#registerResource(java.lang.Object, - * java.lang.Object, java.lang.Object) - */ @Override public void registerResource(Object type, Object key, Object resource) { if (allResourcesMap == null) { - allResourcesMap = new HashMap(); + allResourcesMap = new HashMap<>(); } - Map resourcesMap = (Map) allResourcesMap.get(type); + Map<Object, Object> resourcesMap = allResourcesMap.get(type); if (resourcesMap == null) { - resourcesMap = new HashMap(); + resourcesMap = new HashMap<>(); allResourcesMap.put(type, resourcesMap); } resourcesMap.put(key, resource); } - protected Map getCacheByType(Object type) { + protected Map<Object, Object> getCacheByType(Object type) { if (allResourcesMap != null) { - Map resourcesMap = (Map) allResourcesMap.get(type); + Map<Object, Object> resourcesMap = allResourcesMap.get(type); if (resourcesMap != null) { return resourcesMap; } @@ -75,18 +63,12 @@ public abstract class AbstractResourcesRegistry implements IResourcesRegistry { return Collections.EMPTY_MAP; } - /* - * (non-Javadoc) - * - * @see org.eclipse.e4.ui.core.css.resources.IResourcesRegistry#unregisterResource(java.lang.Object, - * java.lang.Object) - */ @Override public void unregisterResource(Object type, Object key) { if (allResourcesMap == null) { return; } - Map resourcesMap = (Map) allResourcesMap.get(type); + Map<Object, Object> resourcesMap = allResourcesMap.get(type); if (resourcesMap == null) { return; } @@ -99,7 +81,7 @@ public abstract class AbstractResourcesRegistry implements IResourcesRegistry { public void unregisterResource(Object resource) { Object type = getResourceType(resource); if (type != null) { - Map resourcesMap = (Map) allResourcesMap.get(type); + Map<Object, Object> resourcesMap = allResourcesMap.get(type); if (resourcesMap != null) { resourcesMap.remove(resource); } @@ -110,33 +92,23 @@ public abstract class AbstractResourcesRegistry implements IResourcesRegistry { return resource.getClass(); } - /* - * (non-Javadoc) - * - * @see org.eclipse.e4.ui.core.css.resources.IResourcesRegistry#dispose() - */ @Override public void dispose() { if (allResourcesMap == null) { return; } // Loop for all resources stored into cache - Set allResources = allResourcesMap.entrySet(); - for (Iterator iterator = allResources.iterator(); iterator.hasNext();) { - Map.Entry entry = (Map.Entry) iterator.next(); + Set<Entry<Object, Map<Object, Object>>> allResources = allResourcesMap.entrySet(); + for (Entry<Object, Map<Object, Object>> entry : allResources) { Object type = entry.getKey(); - Map resourcesMap = (Map) entry.getValue(); - Set resources = resourcesMap.entrySet(); - for (Iterator iterator2 = resources.iterator(); iterator2.hasNext();) { - Map.Entry entry2 = (Map.Entry) iterator2.next(); + Set<Entry<Object, Object>> resources = entry.getValue().entrySet(); + for (Entry<Object, Object> entry2 : resources) { // Dispose the current resource. - disposeResource(type, entry2.getKey(), entry2 - .getValue()); + disposeResource(type, entry2.getKey(), entry2.getValue()); } } allResourcesMap = null; } - public abstract void disposeResource(Object type, Object key, - Object resource); + public abstract void disposeResource(Object type, Object key, Object resource); } diff --git a/bundles/org.eclipse.e4.ui.css.core/src/org/eclipse/e4/ui/css/core/sac/ExtendedDocumentHandler.java b/bundles/org.eclipse.e4.ui.css.core/src/org/eclipse/e4/ui/css/core/sac/ExtendedDocumentHandler.java index 47393b283b0..33a557efda0 100644 --- a/bundles/org.eclipse.e4.ui.css.core/src/org/eclipse/e4/ui/css/core/sac/ExtendedDocumentHandler.java +++ b/bundles/org.eclipse.e4.ui.css.core/src/org/eclipse/e4/ui/css/core/sac/ExtendedDocumentHandler.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2008 Angelo Zerr and others. + * Copyright (c) 2008, 2015 Angelo Zerr and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -11,7 +11,6 @@ package org.eclipse.e4.ui.css.core.sac; import java.util.Stack; - import org.w3c.css.sac.DocumentHandler; /** @@ -31,5 +30,5 @@ public interface ExtendedDocumentHandler extends DocumentHandler { * * @param statck */ - public void setNodeStack(Stack statck); + public void setNodeStack(Stack<Object> statck); } diff --git a/bundles/org.eclipse.e4.ui.css.core/src/org/eclipse/e4/ui/css/core/serializers/CSSSerializerConfiguration.java b/bundles/org.eclipse.e4.ui.css.core/src/org/eclipse/e4/ui/css/core/serializers/CSSSerializerConfiguration.java index 1ea98e25ae2..c5da3502ec1 100644 --- a/bundles/org.eclipse.e4.ui.css.core/src/org/eclipse/e4/ui/css/core/serializers/CSSSerializerConfiguration.java +++ b/bundles/org.eclipse.e4.ui.css.core/src/org/eclipse/e4/ui/css/core/serializers/CSSSerializerConfiguration.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2008 Angelo Zerr and others. + * Copyright (c) 2008, 2015 Angelo Zerr and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -21,7 +21,7 @@ public class CSSSerializerConfiguration { private static final String[] EMPTY_STRING = new String[0]; - private List attributesFilter = null; + private List<String> attributesFilter; /** * Add attribute name <code>attributeName</code> to filter. @@ -29,8 +29,9 @@ public class CSSSerializerConfiguration { * @param attributeName */ public void addAttributeFilter(String attributeName) { - if (attributesFilter == null) - attributesFilter = new ArrayList(); + if (attributesFilter == null) { + attributesFilter = new ArrayList<>(); + } attributesFilter.add(attributeName); } @@ -40,8 +41,9 @@ public class CSSSerializerConfiguration { * @return */ public String[] getAttributesFilter() { - if (attributesFilter != null) - return (String[]) attributesFilter.toArray(EMPTY_STRING); + if (attributesFilter != null) { + return attributesFilter.toArray(EMPTY_STRING); + } return EMPTY_STRING; } diff --git a/bundles/org.eclipse.e4.ui.css.core/src/org/eclipse/e4/ui/css/core/util/impl/resources/ResourcesLocatorManager.java b/bundles/org.eclipse.e4.ui.css.core/src/org/eclipse/e4/ui/css/core/util/impl/resources/ResourcesLocatorManager.java index 38207683fa4..2917bd9a31d 100644 --- a/bundles/org.eclipse.e4.ui.css.core/src/org/eclipse/e4/ui/css/core/util/impl/resources/ResourcesLocatorManager.java +++ b/bundles/org.eclipse.e4.ui.css.core/src/org/eclipse/e4/ui/css/core/util/impl/resources/ResourcesLocatorManager.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2008, 2012 Angelo Zerr and others. + * Copyright (c) 2008, 2015 Angelo Zerr and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -14,7 +14,6 @@ package org.eclipse.e4.ui.css.core.util.impl.resources; import java.io.InputStream; import java.io.Reader; import java.util.ArrayList; -import java.util.Iterator; import java.util.List; import org.eclipse.e4.ui.css.core.util.resources.IResourceLocator; import org.eclipse.e4.ui.css.core.util.resources.IResourcesLocatorManager; @@ -33,21 +32,17 @@ public class ResourcesLocatorManager implements IResourcesLocatorManager { /** * List of IResourceLocator instance which was registered. */ - private List uriResolvers = null; + private List<IResourceLocator> uriResolvers; public ResourcesLocatorManager() { registerResourceLocator(new HttpResourcesLocatorImpl()); } - /* - * (non-Javadoc) - * - * @see org.eclipse.e4.ui.css.core.util.resources.IResourcesLocatorManager#registerResourceLocator(org.eclipse.e4.ui.css.core.util.resources.IResourceLocator) - */ @Override public void registerResourceLocator(IResourceLocator resourceLocator) { - if (uriResolvers == null) - uriResolvers = new ArrayList(); + if (uriResolvers == null) { + uriResolvers = new ArrayList<>(); + } if (resourceLocator instanceof OSGiResourceLocator) { uriResolvers.add(0, resourceLocator); } else { @@ -55,59 +50,54 @@ public class ResourcesLocatorManager implements IResourcesLocatorManager { } } - /* - * (non-Javadoc) - * - * @see org.eclipse.e4.ui.css.core.util.resources.IResourcesLocatorManager#unregisterResourceLocator(org.eclipse.e4.ui.css.core.util.resources.IResourceLocator) - */ @Override public void unregisterResourceLocator(IResourceLocator resourceLocator) { - if (uriResolvers == null) + if (uriResolvers == null) { return; + } uriResolvers.remove(resourceLocator); } - /* - * (non-Javadoc) - * - * @see org.eclipse.e4.ui.css.core.util.resources.IURIResolver#resolve(java.lang.String) - */ @Override public String resolve(String uri) { - if (StringUtils.isEmpty(uri)) + if (StringUtils.isEmpty(uri)) { return null; - if (uriResolvers == null) + } + if (uriResolvers == null) { return null; + } // Loop for IResourceLocator registered and return the uri resolved // as soon as an IResourceLocator return an uri resolved which is not // null. - for (Iterator iterator = uriResolvers.iterator(); iterator.hasNext();) { - IResourceLocator resolver = (IResourceLocator) iterator.next(); + for (IResourceLocator resolver : uriResolvers) { String s = resolver.resolve(uri); - if (s != null) + if (s != null) { return s; + } } return null; } @Override public InputStream getInputStream(String uri) throws Exception { - if (StringUtils.isEmpty(uri)) + if (StringUtils.isEmpty(uri)) { return null; - if (uriResolvers == null) + } + if (uriResolvers == null) { return null; + } // Loop for IResourceLocator registered and return the InputStream from // the uri resolved // as soon as an IResourceLocator return an uri resolved which is not // null. - for (Iterator iterator = uriResolvers.iterator(); iterator.hasNext();) { - IResourceLocator resolver = (IResourceLocator) iterator.next(); + for (IResourceLocator resolver : uriResolvers) { String s = resolver.resolve(uri); if (s != null) { InputStream inputStream = resolver.getInputStream(uri); - if (inputStream != null) + if (inputStream != null) { return inputStream; + } } } return null; @@ -115,21 +105,23 @@ public class ResourcesLocatorManager implements IResourcesLocatorManager { @Override public Reader getReader(String uri) throws Exception { - if (StringUtils.isEmpty(uri)) + if (StringUtils.isEmpty(uri)) { return null; - if (uriResolvers == null) + } + if (uriResolvers == null) { return null; + } // Loop for IResourceLocator registered and return the Reader from // the uri resolved // as soon as an IResourceLocator return an uri resolved which is not // null. - for (Iterator iterator = uriResolvers.iterator(); iterator.hasNext();) { - IResourceLocator resolver = (IResourceLocator) iterator.next(); + for (IResourceLocator resolver : uriResolvers) { String s = resolver.resolve(uri); if (s != null) { Reader reader = resolver.getReader(uri); - if (reader != null) + if (reader != null) { return reader; + } } } diff --git a/bundles/org.eclipse.e4.ui.css.core/src/org/eclipse/e4/ui/css/core/utils/StringUtils.java b/bundles/org.eclipse.e4.ui.css.core/src/org/eclipse/e4/ui/css/core/utils/StringUtils.java index 08865dbafdd..95297ac2e60 100644 --- a/bundles/org.eclipse.e4.ui.css.core/src/org/eclipse/e4/ui/css/core/utils/StringUtils.java +++ b/bundles/org.eclipse.e4.ui.css.core/src/org/eclipse/e4/ui/css/core/utils/StringUtils.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2008, 2010 Angelo Zerr and others. + * Copyright (c) 2008, 2015 Angelo Zerr and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -60,11 +60,11 @@ public class StringUtils { * @return */ public static String[] split(String line, String delim) { - List list = new ArrayList(); - for (StringTokenizer t = new StringTokenizer(line, delim); t - .hasMoreTokens(); list.add(t.nextToken())) + List<String> list = new ArrayList<>(); + for (StringTokenizer t = new StringTokenizer(line, delim); t.hasMoreTokens(); list.add(t.nextToken())) { ; - return (String[]) list.toArray(new String[list.size()]); + } + return list.toArray(new String[list.size()]); } /** @@ -183,8 +183,8 @@ public class StringUtils { if (delimiters == null) { return Character.isWhitespace(ch); } - for (int i = 0, isize = delimiters.length; i < isize; i++) { - if (ch == delimiters[i]) { + for (char delimiter : delimiters) { + if (ch == delimiter) { return true; } } diff --git a/bundles/org.eclipse.e4.ui.css.swt/src/org/eclipse/e4/ui/css/swt/resources/SWTResourcesRegistry.java b/bundles/org.eclipse.e4.ui.css.swt/src/org/eclipse/e4/ui/css/swt/resources/SWTResourcesRegistry.java index f3ddd822169..0ffb323bd03 100644 --- a/bundles/org.eclipse.e4.ui.css.swt/src/org/eclipse/e4/ui/css/swt/resources/SWTResourcesRegistry.java +++ b/bundles/org.eclipse.e4.ui.css.swt/src/org/eclipse/e4/ui/css/swt/resources/SWTResourcesRegistry.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2008, 2009 Angelo Zerr and others. + * Copyright (c) 2008, 2015 Angelo Zerr and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -14,7 +14,7 @@ package org.eclipse.e4.ui.css.swt.resources; import java.util.ArrayList; import java.util.Iterator; import java.util.List; -import java.util.Map; +import java.util.Map.Entry; import org.eclipse.e4.ui.css.core.resources.AbstractResourcesRegistry; import org.eclipse.swt.SWT; import org.eclipse.swt.graphics.Color; @@ -139,13 +139,12 @@ public class SWTResourcesRegistry extends AbstractResourcesRegistry { return false; } - public List<Object> removeResourcesByKeyTypeAndType(Class<?> keyType, - Class<?>... types) { + public List<Object> removeResourcesByKeyTypeAndType(Class<?> keyType, Class<?>... types) { List<Object> removedResources = new ArrayList<Object>(); for (Class<?> cls : types) { - Iterator<Map.Entry<?, ?>> iter = getCacheByType(cls).entrySet().iterator(); + Iterator<Entry<Object, Object>> iter = getCacheByType(cls).entrySet().iterator(); while (iter.hasNext()) { - Map.Entry<?, ?> entry = iter.next(); + Entry<Object, Object> entry = iter.next(); if (keyType.isAssignableFrom(entry.getKey().getClass())) { removedResources.add(entry.getValue()); iter.remove(); |
