Skip to content

Commit

Permalink
Require Java 8
Browse files Browse the repository at this point in the history
  • Loading branch information
slachiewicz committed Mar 19, 2022
1 parent cb6bbef commit 25b010a
Show file tree
Hide file tree
Showing 11 changed files with 168 additions and 194 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@
<properties>
<mavenVersion>2.2.1</mavenVersion>
<jdependVersion>2.9.1</jdependVersion>
<mojo.java.target>1.5</mojo.java.target>
<mojo.java.target>1.8</mojo.java.target>
<scmpublish.content>target/staging/${project.artifactId}</scmpublish.content>
</properties>

Expand Down
11 changes: 3 additions & 8 deletions src/main/java/org/codehaus/mojo/jdepend/AbstractJDependMojo.java
Original file line number Diff line number Diff line change
Expand Up @@ -125,12 +125,7 @@ public void executeReport( Locale locale )
*/
public boolean canGenerateReport()
{
File srcDir = new File( classDirectory );
if ( !srcDir.exists() )
{
return false;
}
return true;
return new File( classDirectory ).exists();
}

/**
Expand All @@ -143,15 +138,15 @@ public boolean canGenerateReport()
*/
private String[] getArgumentList( String argument, String locationXMLreportFile, String classDir )
{
List<String> argList = new ArrayList<String>();
List<String> argList = new ArrayList<>();

argList.add( argument );

argList.add( locationXMLreportFile );

argList.add( classDir );

return (String[]) argList.toArray( new String[argList.size()] );
return argList.toArray( new String[0] );
}

public void generateReport( Locale locale )
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/codehaus/mojo/jdepend/JDependMojo.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
* @author [email protected]
* @version $Id$
*/
@Mojo( name = "generate", requiresProject = true )
@Mojo( name = "generate" )
@Execute( phase = LifecyclePhase.COMPILE )
public class JDependMojo
extends AbstractJDependMojo
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
*
* @author Karl-Heinz Marbaise
*/
@Mojo( name = "generate-no-fork", requiresProject = true, defaultPhase = LifecyclePhase.SITE )
@Mojo( name = "generate-no-fork", defaultPhase = LifecyclePhase.SITE )
public class JDependNoForkMojo
extends AbstractJDependMojo
{
Expand Down
229 changes: 104 additions & 125 deletions src/main/java/org/codehaus/mojo/jdepend/JDependXMLReportParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public JDependXMLReportParser( File xmlFile )
SAXParserFactory factory = SAXParserFactory.newInstance();

/* Create an empty stack */
stack = new Stack<String>();
stack = new Stack<>();

SAXParser saxParser = factory.newSAXParser();

Expand All @@ -89,7 +89,6 @@ public JDependXMLReportParser( File xmlFile )
* org.xml.sax.Attributes)
*/
public void startElement( String namespaceURI, String sName, String qName, Attributes attrs )
throws SAXException
{

/* Push element name into stack */
Expand All @@ -99,38 +98,37 @@ public void startElement( String namespaceURI, String sName, String qName, Attri
// text
buffer = new StringBuffer();

if ( qName.equals( "Packages" ) )
switch ( qName )
{
packages = new ArrayList<JDPackage>();
}
else if ( qName.equals( "Package" ) )
{
if ( isParentElement( "Packages" ) )
{
jdpackage = new JDPackage();

if ( attrs != null )
case "Packages":
packages = new ArrayList<>();
break;
case "Package":
if ( isParentElement( "Packages" ) )
{
jdpackage.setPackageName( attrs.getValue( 0 ) );
}
}
else if ( isParentElement( "Cycles" ) )
{
cyclePackage = new CyclePackage();
jdpackage = new JDPackage();

if ( attrs != null )
if ( attrs != null )
{
jdpackage.setPackageName( attrs.getValue( 0 ) );
}
}
else if ( isParentElement( "Cycles" ) )
{
cyclePackage.setName( attrs.getValue( 0 ) );
cyclePackage = new CyclePackage();

if ( attrs != null )
{
cyclePackage.setName( attrs.getValue( 0 ) );
}
}
}
}
else if ( qName.equals( "Stats" ) )
{
stats = new Stats();
}
else if ( qName.equals( "Cycles" ) )
{
cycles = new ArrayList<CyclePackage>();
break;
case "Stats":
stats = new Stats();
break;
case "Cycles":
cycles = new ArrayList<>();
break;
}
}

Expand All @@ -139,99 +137,89 @@ else if ( qName.equals( "Cycles" ) )
* @see org.xml.sax.helpers.DefaultHandler#endElement(java.lang.String, java.lang.String, java.lang.String)
*/
public void endElement( String namespaceURI, String sName, String qName )
throws SAXException
{

String elementValue = buffer != null ? buffer.toString().trim() : null;

if ( qName.equals( "Package" ) )
switch ( qName )
{
if ( isParentElement( "Packages" ) )
{
if ( errFlag == false )
case "Package":
if ( isParentElement( "Packages" ) )
{
jdpackage.setStats( stats );
if ( !errFlag )
{
jdpackage.setStats( stats );

packages.add( jdpackage );
packages.add( jdpackage );
}
errFlag = false;
}
errFlag = false;
}
else if ( isParentElement( "DependsUpon" ) )
{
jdpackage.addDependsUpon( elementValue );
}
else if ( isParentElement( "UsedBy" ) )
{
jdpackage.addUsedBy( elementValue );
}
else if ( isParentElement( "Package" ) )
{
cyclePackage.addPackageList( elementValue );
}
else if ( isParentElement( "Cycles" ) )
{
cycles.add( cyclePackage );
}
}
else if ( qName.equals( "TotalClasses" ) )
{
stats.setTotalClasses( elementValue );
}
else if ( qName.equals( "ConcreteClasses" ) )
{
if ( isParentElement( "Stats" ) )
{
stats.setConcreteClasses( elementValue );
}
}
else if ( qName.equals( "AbstractClasses" ) )
{
if ( isParentElement( "Stats" ) )
{
stats.setAbstractClasses( elementValue );
}
}
else if ( qName.equals( "Ca" ) )
{
stats.setCa( elementValue );
}
else if ( qName.equals( "Ce" ) )
{
stats.setCe( elementValue );
}
else if ( qName.equals( "A" ) )
{
stats.setA( elementValue );
}
else if ( qName.equals( "I" ) )
{
stats.setI( elementValue );
}
else if ( qName.equals( "D" ) )
{
stats.setD( elementValue );
}
else if ( qName.equals( "V" ) )
{
stats.setV( elementValue );
}
else if ( qName.equals( "Class" ) )
{
if ( isParentElement( "AbstractClasses" ) )
{
jdpackage.addAbstractClasses( elementValue );
}
else if ( isParentElement( "ConcreteClasses" ) )
{
jdpackage.addConcreteClasses( elementValue );
}
}
else if ( qName.equals( "error" ) )
{
if ( isParentElement( "Package" ) )
{
errFlag = true;
}
else if ( isParentElement( "DependsUpon" ) )
{
jdpackage.addDependsUpon( elementValue );
}
else if ( isParentElement( "UsedBy" ) )
{
jdpackage.addUsedBy( elementValue );
}
else if ( isParentElement( "Package" ) )
{
cyclePackage.addPackageList( elementValue );
}
else if ( isParentElement( "Cycles" ) )
{
cycles.add( cyclePackage );
}
break;
case "TotalClasses":
stats.setTotalClasses( elementValue );
break;
case "ConcreteClasses":
if ( isParentElement( "Stats" ) )
{
stats.setConcreteClasses( elementValue );
}
break;
case "AbstractClasses":
if ( isParentElement( "Stats" ) )
{
stats.setAbstractClasses( elementValue );
}
break;
case "Ca":
stats.setCa( elementValue );
break;
case "Ce":
stats.setCe( elementValue );
break;
case "A":
stats.setA( elementValue );
break;
case "I":
stats.setI( elementValue );
break;
case "D":
stats.setD( elementValue );
break;
case "V":
stats.setV( elementValue );
break;
case "Class":
if ( isParentElement( "AbstractClasses" ) )
{
jdpackage.addAbstractClasses( elementValue );
}
else if ( isParentElement( "ConcreteClasses" ) )
{
jdpackage.addConcreteClasses( elementValue );
}
break;
case "error":
if ( isParentElement( "Package" ) )
{
errFlag = true;
}
break;
}

if ( stack.size() != 0 )
Expand All @@ -248,7 +236,6 @@ else if ( qName.equals( "error" ) )
* @see org.xml.sax.helpers.DefaultHandler#characters(char[], int, int)
*/
public void characters( char[] buff, int offset, int len )
throws SAXException
{
if ( buffer != null )
{
Expand Down Expand Up @@ -277,11 +264,7 @@ public Stats getStats()
*/
private int getParentIndex()
{
int parentIndex = 0;

parentIndex = stack.size() - 2;

return parentIndex;
return stack.size() - 2;
}

/**
Expand All @@ -290,10 +273,6 @@ private int getParentIndex()
*/
private boolean isParentElement( String parentElement )
{
boolean isParent = false;

isParent = stack.get( getParentIndex() ).toString().equals( parentElement );

return isParent;
return stack.get( getParentIndex() ).equals( parentElement );
}
}
Loading

0 comments on commit 25b010a

Please sign in to comment.