Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using System.getProperty("line.separator") instead of '\n' and adding pre-caching of licenses text #35

Merged
merged 4 commits into from
Oct 3, 2014
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -23,19 +23,29 @@ public class ApacheSoftwareLicense20 extends License {

private static final long serialVersionUID = 4854000061990891449L;

private String cachedSummaryText = null;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use the naming convention used in this project (m-prefixed)

private String cachedFullText = null;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use the naming convention used in this project (m-prefixed)


@Override
public String getName() {
return "Apache Software License 2.0";
}

@Override
public String getSummaryText(final Context context) {
return getContent(context, R.raw.asl_20_summary);
if (cachedSummaryText == null) {
cachedSummaryText = getContent(context, R.raw.asl_20_summary);
}

return cachedSummaryText;
}

@Override
public String getFullText(final Context context) {
return getContent(context, R.raw.asl_20_full);
if (cachedFullText == null) {
cachedFullText = getContent(context, R.raw.asl_20_full);
}
return cachedFullText;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,19 +23,29 @@ public class BSD3ClauseLicense extends License {

private static final long serialVersionUID = -5205394619884057474L;

private String cachedSummaryText = null;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use the naming convention used in this project (m-prefixed)

private String cachedFullText = null;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use the naming convention used in this project (m-prefixed)


@Override
public String getName() {
return "BSD 3-Clause License";
}

@Override
public String getSummaryText(final Context context) {
return getContent(context, R.raw.bsd3_summary);
if (cachedSummaryText == null) {
cachedSummaryText = getContent(context, R.raw.bsd3_summary);
}

return cachedSummaryText;
}

@Override
public String getFullText(final Context context) {
return getContent(context, R.raw.bsd3_full);
if (cachedFullText == null) {
cachedFullText = getContent(context, R.raw.bsd3_full);
}
return cachedFullText;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,19 +21,29 @@

public class CreativeCommonsAttributionNoDerivs30Unported extends License {

private String cachedSummaryText = null;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use the naming convention used in this project (m-prefixed)

private String cachedFullText = null;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use the naming convention used in this project (m-prefixed)


@Override
public String getName() {
return "Creative Commons Attribution-NoDerivs 3.0 Unported";
}

@Override
public String getSummaryText(final Context context) {
return getContent(context, R.raw.ccand_30_summary);
if (cachedSummaryText == null) {
cachedSummaryText = getContent(context, R.raw.ccand_30_summary);
}

return cachedSummaryText;
}

@Override
public String getFullText(final Context context) {
return getContent(context, R.raw.ccand_30_full);
if (cachedFullText == null) {
cachedFullText = getContent(context, R.raw.ccand_30_full);
}
return cachedFullText;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,19 +21,29 @@

public class GnuGeneralPublicLicense20 extends License {

private String cachedSummaryText = null;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use the naming convention used in this project (m-prefixed)

private String cachedFullText = null;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use the naming convention used in this project (m-prefixed)


@Override
public String getName() {
return "GNU General Public License 2.0";
}

@Override
public String getSummaryText(final Context context) {
return getContent(context, R.raw.gpl_20_summary);
if (cachedSummaryText == null) {
cachedSummaryText = getContent(context, R.raw.gpl_20_summary);
}

return cachedSummaryText;
}

@Override
public String getFullText(final Context context) {
return getContent(context, R.raw.gpl_20_full);
if (cachedFullText == null) {
cachedFullText = getContent(context, R.raw.gpl_20_full);
}
return cachedFullText;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,19 +21,29 @@

public class GnuGeneralPublicLicense30 extends License {

private String cachedSummaryText = null;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use the naming convention used in this project (m-prefixed)

private String cachedFullText = null;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use the naming convention used in this project (m-prefixed)


@Override
public String getName() {
return "GNU General Public License 3.0";
}

@Override
public String getSummaryText(final Context context) {
return getContent(context, R.raw.gpl_30_summary);
if (cachedSummaryText == null) {
cachedSummaryText = getContent(context, R.raw.gpl_30_summary);
}

return cachedSummaryText;
}

@Override
public String getFullText(final Context context) {
return getContent(context, R.raw.gpl_30_full);
if (cachedFullText == null) {
cachedFullText = getContent(context, R.raw.gpl_30_full);
}
return cachedFullText;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,19 +22,29 @@

public class GnuLesserGeneralPublicLicense21 extends License {

private String cachedSummaryText = null;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use the naming convention used in this project (m-prefixed)

private String cachedFullText = null;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use the naming convention used in this project (m-prefixed)


@Override
public String getName() {
return "GNU Lesser General Public License 2.1";
}

@Override
public String getSummaryText(final Context context) {
return getContent(context, R.raw.lgpl_21_summary);
if (cachedSummaryText == null) {
cachedSummaryText = getContent(context, R.raw.lgpl_21_summary);
}

return cachedSummaryText;
}

@Override
public String getFullText(final Context context) {
return getContent(context, R.raw.lgpl_21_full);
if (cachedFullText == null) {
cachedFullText = getContent(context, R.raw.lgpl_21_full);
}
return cachedFullText;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,19 +22,29 @@
public class ISCLicense extends License {
private static final long serialVersionUID = -4636435634132169860L;

private String cachedSummaryText = null;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use the naming convention used in this project (m-prefixed)

private String cachedFullText = null;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use the naming convention used in this project (m-prefixed)


@Override
public String getName() {
return "ISC License";
}

@Override
public String getSummaryText(final Context context) {
return getContent(context, R.raw.isc_summary);
if (cachedSummaryText == null) {
cachedSummaryText = getContent(context, R.raw.isc_summary);
}

return cachedSummaryText;
}

@Override
public String getFullText(final Context context) {
return getContent(context, R.raw.isc_full);
if (cachedFullText == null) {
cachedFullText = getContent(context, R.raw.isc_full);
}
return cachedFullText;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,10 @@ protected String getContent(final Context context, final int contentResourceId)

private String toString(final BufferedReader reader) throws IOException {
final StringBuilder builder = new StringBuilder();
String lineSeparator = System.getProperty("line.separator");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make that a constant

String line = null;
while ((line = reader.readLine()) != null) {
builder.append(line).append('\n');
builder.append(line).append(lineSeparator);
}
return builder.toString();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,19 +23,29 @@ public class MITLicense extends License {

private static final long serialVersionUID = 5673599951781482594L;

private String cachedSummaryText = null;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use the naming convention used in this project (m-prefixed)

private String cachedFullText = null;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use the naming convention used in this project (m-prefixed)


@Override
public String getName() {
return "MIT License";
}

@Override
public String getSummaryText(final Context context) {
return getContent(context, R.raw.mit_summary);
if (cachedSummaryText == null) {
cachedSummaryText = getContent(context, R.raw.mit_summary);
}

return cachedSummaryText;
}

@Override
public String getFullText(final Context context) {
return getContent(context, R.raw.mit_full);
if (cachedFullText == null) {
cachedFullText = getContent(context, R.raw.mit_full);
}
return cachedFullText;
}

@Override
Expand Down