-
Notifications
You must be signed in to change notification settings - Fork 145
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
Using System.getProperty("line.separator") instead of '\n' and adding pre-caching of licenses text #35
Changes from 2 commits
b9ab1cd
ddb0e51
5332c39
5615cde
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,19 +23,29 @@ public class ApacheSoftwareLicense20 extends License { | |
|
||
private static final long serialVersionUID = 4854000061990891449L; | ||
|
||
private String cachedSummaryText = null; | ||
private String cachedFullText = null; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,19 +23,29 @@ public class BSD3ClauseLicense extends License { | |
|
||
private static final long serialVersionUID = -5205394619884057474L; | ||
|
||
private String cachedSummaryText = null; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,19 +21,29 @@ | |
|
||
public class CreativeCommonsAttributionNoDerivs30Unported extends License { | ||
|
||
private String cachedSummaryText = null; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,19 +21,29 @@ | |
|
||
public class GnuGeneralPublicLicense20 extends License { | ||
|
||
private String cachedSummaryText = null; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,19 +21,29 @@ | |
|
||
public class GnuGeneralPublicLicense30 extends License { | ||
|
||
private String cachedSummaryText = null; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,19 +22,29 @@ | |
|
||
public class GnuLesserGeneralPublicLicense21 extends License { | ||
|
||
private String cachedSummaryText = null; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,19 +22,29 @@ | |
public class ISCLicense extends License { | ||
private static final long serialVersionUID = -4636435634132169860L; | ||
|
||
private String cachedSummaryText = null; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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"); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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(); | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,19 +23,29 @@ public class MITLicense extends License { | |
|
||
private static final long serialVersionUID = 5673599951781482594L; | ||
|
||
private String cachedSummaryText = null; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 | ||
|
There was a problem hiding this comment.
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)