repo_name stringlengths 7 104 | file_path stringlengths 13 198 | context stringlengths 67 7.15k | import_statement stringlengths 16 4.43k | code stringlengths 40 6.98k | prompt stringlengths 227 8.27k | next_line stringlengths 8 795 |
|---|---|---|---|---|---|---|
UKHomeOffice/email-api | src/test/java/uk/gov/homeoffice/emailapi/templatedemailfactory/TemplatedEmailFactoryImplTest.java | // Path: src/main/java/uk/gov/homeoffice/emailapi/entities/TemplatedEmail.java
// @ApiModel(description = "Enough information to populate and send and email based on a template")
// @JsonDeserialize(as = TemplatedEmailImpl.class)
// @JsonSerialize(as = TemplatedEmailImpl.class)
// public interface TemplatedEmail {
// @ApiModelProperty(value = "Sender of the email in format \"example@example.org\" or \"Annie Example <annie@example.com>\"", required = true)
// String getSender();
//
// @ApiModelProperty(value = "Subject of the email", required = true)
// String getSubject();
//
// @ApiModelProperty(value = "If a recipient uses HTML to view their they will see this template", required = true)
// String getHtmlTemplate();
//
// @ApiModelProperty(value = "If a recipient uses TXT to view their they will see this template", required = true)
// String getTextTemplate();
//
// @ApiModelProperty(value = "Variables to pass to both templates with string keys, and any JSON Number, String, Array, Object as the value ", required = true)
// Map<String, Object> getVariables();
//
// @ApiModelProperty(value = "Array of recipients in an array of strings in format \"example@example.org\" or \"Annie Example <annie@example.com>\"", required = true)
// Collection<String> getRecipients();
// }
//
// Path: src/main/java/uk/gov/homeoffice/emailapi/entities/TemplatedEmailImpl.java
// public class TemplatedEmailImpl implements TemplatedEmail {
//
// @JsonProperty @NotEmpty private final Collection<String> recipients;
//
// @JsonProperty @Email private final String sender;
//
// @JsonProperty @NotEmpty private final String subject;
//
// @JsonProperty @NotEmpty private final String htmlTemplate;
//
// @JsonProperty private final Map<String, Object> variables;
//
// @JsonProperty @NotEmpty private final String textTemplate;
//
// @JsonCreator
// public TemplatedEmailImpl(@JsonProperty("recipients") Collection<String> recipients,
// @JsonProperty("sender") String sender, @JsonProperty("subject") String subject,
// @JsonProperty("htmlTemplate") String htmlTemplate,
// @JsonProperty("variables") final Map<String, Object> variables,
// @JsonProperty("textTemplate") String textTemplate) {
//
// this.recipients = recipients;
// this.sender = sender;
// this.subject = subject;
// this.htmlTemplate = htmlTemplate;
// this.variables = variables;
// this.textTemplate = textTemplate;
// }
//
// @Override
// public String getSender() {
// return sender;
// }
//
// @Override
// public String getSubject() {
// return subject;
// }
//
// @Override
// public String getHtmlTemplate() {
// return htmlTemplate;
// }
//
// @Override
// public String getTextTemplate() {
// return textTemplate;
// }
//
// @Override
// public Map<String, Object> getVariables() {
// return variables;
// }
//
// @Override
// public Collection<String> getRecipients() {
// return recipients;
// }
// }
//
// Path: src/main/java/uk/gov/homeoffice/emailapi/templatedemailfactory/addressparsing/InternetAddressParser.java
// public interface InternetAddressParser {
//
// Collection<InternetAddress> getInternetAddresses(Collection<String> unparsedRecipients)
// throws InternetAddressParsingException;
// }
//
// Path: src/main/java/uk/gov/homeoffice/emailapi/templatedemailfactory/addressparsing/InternetAddressParsingException.java
// public class InternetAddressParsingException extends Exception {
// public InternetAddressParsingException(final Throwable cause) {
// super(cause);
// }
// }
//
// Path: src/main/java/uk/gov/homeoffice/emailapi/templatedemailfactory/serverconfig/HtmlEmailFactory.java
// public interface HtmlEmailFactory {
// HtmlEmail getHtmlEmail();
// }
//
// Path: src/main/java/uk/gov/homeoffice/emailapi/templatedemailfactory/templating/TemplatePopulator.java
// public interface TemplatePopulator {
// String populateTemplate(String template, Map<String, Object> variables)
// throws TemplatePopulatorIOException, TemplatePopulatorParsingException;
// }
| import org.apache.commons.mail.HtmlEmail;
import org.junit.Before;
import org.junit.Test;
import org.mockito.Matchers;
import uk.gov.homeoffice.emailapi.entities.TemplatedEmail;
import uk.gov.homeoffice.emailapi.entities.TemplatedEmailImpl;
import uk.gov.homeoffice.emailapi.templatedemailfactory.addressparsing.InternetAddressParser;
import uk.gov.homeoffice.emailapi.templatedemailfactory.addressparsing.InternetAddressParsingException;
import uk.gov.homeoffice.emailapi.templatedemailfactory.serverconfig.HtmlEmailFactory;
import uk.gov.homeoffice.emailapi.templatedemailfactory.templating.TemplatePopulator;
import javax.mail.internet.InternetAddress;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.core.IsEqual.equalTo;
import static org.mockito.Mockito.*; | package uk.gov.homeoffice.emailapi.templatedemailfactory;
public class TemplatedEmailFactoryImplTest {
public static final String TEMPLATE_CONTENTS = "Template Contents";
private TemplatePopulator templatePopulator;
private ArrayList<InternetAddress> internetAddresses;
private TemplatedEmailFactoryImpl templatedEmailFactory;
@Before
public void setupSubject() throws InternetAddressParsingException {
templatePopulator = mock(TemplatePopulator.class);
internetAddresses = new ArrayList<>();
final InternetAddressParser internetAddressParser = mock(InternetAddressParser.class);
when(internetAddressParser.getInternetAddresses(Matchers.<Collection<String>>any()))
.thenReturn(internetAddresses);
| // Path: src/main/java/uk/gov/homeoffice/emailapi/entities/TemplatedEmail.java
// @ApiModel(description = "Enough information to populate and send and email based on a template")
// @JsonDeserialize(as = TemplatedEmailImpl.class)
// @JsonSerialize(as = TemplatedEmailImpl.class)
// public interface TemplatedEmail {
// @ApiModelProperty(value = "Sender of the email in format \"example@example.org\" or \"Annie Example <annie@example.com>\"", required = true)
// String getSender();
//
// @ApiModelProperty(value = "Subject of the email", required = true)
// String getSubject();
//
// @ApiModelProperty(value = "If a recipient uses HTML to view their they will see this template", required = true)
// String getHtmlTemplate();
//
// @ApiModelProperty(value = "If a recipient uses TXT to view their they will see this template", required = true)
// String getTextTemplate();
//
// @ApiModelProperty(value = "Variables to pass to both templates with string keys, and any JSON Number, String, Array, Object as the value ", required = true)
// Map<String, Object> getVariables();
//
// @ApiModelProperty(value = "Array of recipients in an array of strings in format \"example@example.org\" or \"Annie Example <annie@example.com>\"", required = true)
// Collection<String> getRecipients();
// }
//
// Path: src/main/java/uk/gov/homeoffice/emailapi/entities/TemplatedEmailImpl.java
// public class TemplatedEmailImpl implements TemplatedEmail {
//
// @JsonProperty @NotEmpty private final Collection<String> recipients;
//
// @JsonProperty @Email private final String sender;
//
// @JsonProperty @NotEmpty private final String subject;
//
// @JsonProperty @NotEmpty private final String htmlTemplate;
//
// @JsonProperty private final Map<String, Object> variables;
//
// @JsonProperty @NotEmpty private final String textTemplate;
//
// @JsonCreator
// public TemplatedEmailImpl(@JsonProperty("recipients") Collection<String> recipients,
// @JsonProperty("sender") String sender, @JsonProperty("subject") String subject,
// @JsonProperty("htmlTemplate") String htmlTemplate,
// @JsonProperty("variables") final Map<String, Object> variables,
// @JsonProperty("textTemplate") String textTemplate) {
//
// this.recipients = recipients;
// this.sender = sender;
// this.subject = subject;
// this.htmlTemplate = htmlTemplate;
// this.variables = variables;
// this.textTemplate = textTemplate;
// }
//
// @Override
// public String getSender() {
// return sender;
// }
//
// @Override
// public String getSubject() {
// return subject;
// }
//
// @Override
// public String getHtmlTemplate() {
// return htmlTemplate;
// }
//
// @Override
// public String getTextTemplate() {
// return textTemplate;
// }
//
// @Override
// public Map<String, Object> getVariables() {
// return variables;
// }
//
// @Override
// public Collection<String> getRecipients() {
// return recipients;
// }
// }
//
// Path: src/main/java/uk/gov/homeoffice/emailapi/templatedemailfactory/addressparsing/InternetAddressParser.java
// public interface InternetAddressParser {
//
// Collection<InternetAddress> getInternetAddresses(Collection<String> unparsedRecipients)
// throws InternetAddressParsingException;
// }
//
// Path: src/main/java/uk/gov/homeoffice/emailapi/templatedemailfactory/addressparsing/InternetAddressParsingException.java
// public class InternetAddressParsingException extends Exception {
// public InternetAddressParsingException(final Throwable cause) {
// super(cause);
// }
// }
//
// Path: src/main/java/uk/gov/homeoffice/emailapi/templatedemailfactory/serverconfig/HtmlEmailFactory.java
// public interface HtmlEmailFactory {
// HtmlEmail getHtmlEmail();
// }
//
// Path: src/main/java/uk/gov/homeoffice/emailapi/templatedemailfactory/templating/TemplatePopulator.java
// public interface TemplatePopulator {
// String populateTemplate(String template, Map<String, Object> variables)
// throws TemplatePopulatorIOException, TemplatePopulatorParsingException;
// }
// Path: src/test/java/uk/gov/homeoffice/emailapi/templatedemailfactory/TemplatedEmailFactoryImplTest.java
import org.apache.commons.mail.HtmlEmail;
import org.junit.Before;
import org.junit.Test;
import org.mockito.Matchers;
import uk.gov.homeoffice.emailapi.entities.TemplatedEmail;
import uk.gov.homeoffice.emailapi.entities.TemplatedEmailImpl;
import uk.gov.homeoffice.emailapi.templatedemailfactory.addressparsing.InternetAddressParser;
import uk.gov.homeoffice.emailapi.templatedemailfactory.addressparsing.InternetAddressParsingException;
import uk.gov.homeoffice.emailapi.templatedemailfactory.serverconfig.HtmlEmailFactory;
import uk.gov.homeoffice.emailapi.templatedemailfactory.templating.TemplatePopulator;
import javax.mail.internet.InternetAddress;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.core.IsEqual.equalTo;
import static org.mockito.Mockito.*;
package uk.gov.homeoffice.emailapi.templatedemailfactory;
public class TemplatedEmailFactoryImplTest {
public static final String TEMPLATE_CONTENTS = "Template Contents";
private TemplatePopulator templatePopulator;
private ArrayList<InternetAddress> internetAddresses;
private TemplatedEmailFactoryImpl templatedEmailFactory;
@Before
public void setupSubject() throws InternetAddressParsingException {
templatePopulator = mock(TemplatePopulator.class);
internetAddresses = new ArrayList<>();
final InternetAddressParser internetAddressParser = mock(InternetAddressParser.class);
when(internetAddressParser.getInternetAddresses(Matchers.<Collection<String>>any()))
.thenReturn(internetAddresses);
| final HtmlEmailFactory htmlEmailFactory = mock(HtmlEmailFactory.class); |
UKHomeOffice/email-api | src/main/java/uk/gov/homeoffice/emailapi/templatedemailfactory/TemplatedEmailFactoryImpl.java | // Path: src/main/java/uk/gov/homeoffice/emailapi/entities/TemplatedEmail.java
// @ApiModel(description = "Enough information to populate and send and email based on a template")
// @JsonDeserialize(as = TemplatedEmailImpl.class)
// @JsonSerialize(as = TemplatedEmailImpl.class)
// public interface TemplatedEmail {
// @ApiModelProperty(value = "Sender of the email in format \"example@example.org\" or \"Annie Example <annie@example.com>\"", required = true)
// String getSender();
//
// @ApiModelProperty(value = "Subject of the email", required = true)
// String getSubject();
//
// @ApiModelProperty(value = "If a recipient uses HTML to view their they will see this template", required = true)
// String getHtmlTemplate();
//
// @ApiModelProperty(value = "If a recipient uses TXT to view their they will see this template", required = true)
// String getTextTemplate();
//
// @ApiModelProperty(value = "Variables to pass to both templates with string keys, and any JSON Number, String, Array, Object as the value ", required = true)
// Map<String, Object> getVariables();
//
// @ApiModelProperty(value = "Array of recipients in an array of strings in format \"example@example.org\" or \"Annie Example <annie@example.com>\"", required = true)
// Collection<String> getRecipients();
// }
//
// Path: src/main/java/uk/gov/homeoffice/emailapi/templatedemailfactory/addressparsing/InternetAddressParser.java
// public interface InternetAddressParser {
//
// Collection<InternetAddress> getInternetAddresses(Collection<String> unparsedRecipients)
// throws InternetAddressParsingException;
// }
//
// Path: src/main/java/uk/gov/homeoffice/emailapi/templatedemailfactory/addressparsing/InternetAddressParsingException.java
// public class InternetAddressParsingException extends Exception {
// public InternetAddressParsingException(final Throwable cause) {
// super(cause);
// }
// }
//
// Path: src/main/java/uk/gov/homeoffice/emailapi/templatedemailfactory/serverconfig/HtmlEmailFactory.java
// public interface HtmlEmailFactory {
// HtmlEmail getHtmlEmail();
// }
//
// Path: src/main/java/uk/gov/homeoffice/emailapi/templatedemailfactory/templating/TemplatePopulator.java
// public interface TemplatePopulator {
// String populateTemplate(String template, Map<String, Object> variables)
// throws TemplatePopulatorIOException, TemplatePopulatorParsingException;
// }
//
// Path: src/main/java/uk/gov/homeoffice/emailapi/templatedemailfactory/templating/TemplatePopulatorIOException.java
// public class TemplatePopulatorIOException extends Exception {
// public TemplatePopulatorIOException(final Throwable cause) {
// super(cause);
// }
// }
//
// Path: src/main/java/uk/gov/homeoffice/emailapi/templatedemailfactory/templating/TemplatePopulatorParsingException.java
// public class TemplatePopulatorParsingException extends Exception {
// public TemplatePopulatorParsingException(Throwable cause) {
// super(cause);
// }
//
// public TemplatePopulatorParsingException(String message) {
// super(message);
// }
// }
| import org.apache.commons.mail.EmailException;
import org.apache.commons.mail.HtmlEmail;
import uk.gov.homeoffice.emailapi.entities.TemplatedEmail;
import uk.gov.homeoffice.emailapi.templatedemailfactory.addressparsing.InternetAddressParser;
import uk.gov.homeoffice.emailapi.templatedemailfactory.addressparsing.InternetAddressParsingException;
import uk.gov.homeoffice.emailapi.templatedemailfactory.serverconfig.HtmlEmailFactory;
import uk.gov.homeoffice.emailapi.templatedemailfactory.templating.TemplatePopulator;
import uk.gov.homeoffice.emailapi.templatedemailfactory.templating.TemplatePopulatorIOException;
import uk.gov.homeoffice.emailapi.templatedemailfactory.templating.TemplatePopulatorParsingException;
import javax.mail.internet.InternetAddress;
import java.util.Collection; | package uk.gov.homeoffice.emailapi.templatedemailfactory;
public class TemplatedEmailFactoryImpl implements TemplatedEmailFactory {
private final TemplatePopulator templateEngine; | // Path: src/main/java/uk/gov/homeoffice/emailapi/entities/TemplatedEmail.java
// @ApiModel(description = "Enough information to populate and send and email based on a template")
// @JsonDeserialize(as = TemplatedEmailImpl.class)
// @JsonSerialize(as = TemplatedEmailImpl.class)
// public interface TemplatedEmail {
// @ApiModelProperty(value = "Sender of the email in format \"example@example.org\" or \"Annie Example <annie@example.com>\"", required = true)
// String getSender();
//
// @ApiModelProperty(value = "Subject of the email", required = true)
// String getSubject();
//
// @ApiModelProperty(value = "If a recipient uses HTML to view their they will see this template", required = true)
// String getHtmlTemplate();
//
// @ApiModelProperty(value = "If a recipient uses TXT to view their they will see this template", required = true)
// String getTextTemplate();
//
// @ApiModelProperty(value = "Variables to pass to both templates with string keys, and any JSON Number, String, Array, Object as the value ", required = true)
// Map<String, Object> getVariables();
//
// @ApiModelProperty(value = "Array of recipients in an array of strings in format \"example@example.org\" or \"Annie Example <annie@example.com>\"", required = true)
// Collection<String> getRecipients();
// }
//
// Path: src/main/java/uk/gov/homeoffice/emailapi/templatedemailfactory/addressparsing/InternetAddressParser.java
// public interface InternetAddressParser {
//
// Collection<InternetAddress> getInternetAddresses(Collection<String> unparsedRecipients)
// throws InternetAddressParsingException;
// }
//
// Path: src/main/java/uk/gov/homeoffice/emailapi/templatedemailfactory/addressparsing/InternetAddressParsingException.java
// public class InternetAddressParsingException extends Exception {
// public InternetAddressParsingException(final Throwable cause) {
// super(cause);
// }
// }
//
// Path: src/main/java/uk/gov/homeoffice/emailapi/templatedemailfactory/serverconfig/HtmlEmailFactory.java
// public interface HtmlEmailFactory {
// HtmlEmail getHtmlEmail();
// }
//
// Path: src/main/java/uk/gov/homeoffice/emailapi/templatedemailfactory/templating/TemplatePopulator.java
// public interface TemplatePopulator {
// String populateTemplate(String template, Map<String, Object> variables)
// throws TemplatePopulatorIOException, TemplatePopulatorParsingException;
// }
//
// Path: src/main/java/uk/gov/homeoffice/emailapi/templatedemailfactory/templating/TemplatePopulatorIOException.java
// public class TemplatePopulatorIOException extends Exception {
// public TemplatePopulatorIOException(final Throwable cause) {
// super(cause);
// }
// }
//
// Path: src/main/java/uk/gov/homeoffice/emailapi/templatedemailfactory/templating/TemplatePopulatorParsingException.java
// public class TemplatePopulatorParsingException extends Exception {
// public TemplatePopulatorParsingException(Throwable cause) {
// super(cause);
// }
//
// public TemplatePopulatorParsingException(String message) {
// super(message);
// }
// }
// Path: src/main/java/uk/gov/homeoffice/emailapi/templatedemailfactory/TemplatedEmailFactoryImpl.java
import org.apache.commons.mail.EmailException;
import org.apache.commons.mail.HtmlEmail;
import uk.gov.homeoffice.emailapi.entities.TemplatedEmail;
import uk.gov.homeoffice.emailapi.templatedemailfactory.addressparsing.InternetAddressParser;
import uk.gov.homeoffice.emailapi.templatedemailfactory.addressparsing.InternetAddressParsingException;
import uk.gov.homeoffice.emailapi.templatedemailfactory.serverconfig.HtmlEmailFactory;
import uk.gov.homeoffice.emailapi.templatedemailfactory.templating.TemplatePopulator;
import uk.gov.homeoffice.emailapi.templatedemailfactory.templating.TemplatePopulatorIOException;
import uk.gov.homeoffice.emailapi.templatedemailfactory.templating.TemplatePopulatorParsingException;
import javax.mail.internet.InternetAddress;
import java.util.Collection;
package uk.gov.homeoffice.emailapi.templatedemailfactory;
public class TemplatedEmailFactoryImpl implements TemplatedEmailFactory {
private final TemplatePopulator templateEngine; | private final InternetAddressParser addressParser; |
UKHomeOffice/email-api | src/main/java/uk/gov/homeoffice/emailapi/templatedemailfactory/TemplatedEmailFactoryImpl.java | // Path: src/main/java/uk/gov/homeoffice/emailapi/entities/TemplatedEmail.java
// @ApiModel(description = "Enough information to populate and send and email based on a template")
// @JsonDeserialize(as = TemplatedEmailImpl.class)
// @JsonSerialize(as = TemplatedEmailImpl.class)
// public interface TemplatedEmail {
// @ApiModelProperty(value = "Sender of the email in format \"example@example.org\" or \"Annie Example <annie@example.com>\"", required = true)
// String getSender();
//
// @ApiModelProperty(value = "Subject of the email", required = true)
// String getSubject();
//
// @ApiModelProperty(value = "If a recipient uses HTML to view their they will see this template", required = true)
// String getHtmlTemplate();
//
// @ApiModelProperty(value = "If a recipient uses TXT to view their they will see this template", required = true)
// String getTextTemplate();
//
// @ApiModelProperty(value = "Variables to pass to both templates with string keys, and any JSON Number, String, Array, Object as the value ", required = true)
// Map<String, Object> getVariables();
//
// @ApiModelProperty(value = "Array of recipients in an array of strings in format \"example@example.org\" or \"Annie Example <annie@example.com>\"", required = true)
// Collection<String> getRecipients();
// }
//
// Path: src/main/java/uk/gov/homeoffice/emailapi/templatedemailfactory/addressparsing/InternetAddressParser.java
// public interface InternetAddressParser {
//
// Collection<InternetAddress> getInternetAddresses(Collection<String> unparsedRecipients)
// throws InternetAddressParsingException;
// }
//
// Path: src/main/java/uk/gov/homeoffice/emailapi/templatedemailfactory/addressparsing/InternetAddressParsingException.java
// public class InternetAddressParsingException extends Exception {
// public InternetAddressParsingException(final Throwable cause) {
// super(cause);
// }
// }
//
// Path: src/main/java/uk/gov/homeoffice/emailapi/templatedemailfactory/serverconfig/HtmlEmailFactory.java
// public interface HtmlEmailFactory {
// HtmlEmail getHtmlEmail();
// }
//
// Path: src/main/java/uk/gov/homeoffice/emailapi/templatedemailfactory/templating/TemplatePopulator.java
// public interface TemplatePopulator {
// String populateTemplate(String template, Map<String, Object> variables)
// throws TemplatePopulatorIOException, TemplatePopulatorParsingException;
// }
//
// Path: src/main/java/uk/gov/homeoffice/emailapi/templatedemailfactory/templating/TemplatePopulatorIOException.java
// public class TemplatePopulatorIOException extends Exception {
// public TemplatePopulatorIOException(final Throwable cause) {
// super(cause);
// }
// }
//
// Path: src/main/java/uk/gov/homeoffice/emailapi/templatedemailfactory/templating/TemplatePopulatorParsingException.java
// public class TemplatePopulatorParsingException extends Exception {
// public TemplatePopulatorParsingException(Throwable cause) {
// super(cause);
// }
//
// public TemplatePopulatorParsingException(String message) {
// super(message);
// }
// }
| import org.apache.commons.mail.EmailException;
import org.apache.commons.mail.HtmlEmail;
import uk.gov.homeoffice.emailapi.entities.TemplatedEmail;
import uk.gov.homeoffice.emailapi.templatedemailfactory.addressparsing.InternetAddressParser;
import uk.gov.homeoffice.emailapi.templatedemailfactory.addressparsing.InternetAddressParsingException;
import uk.gov.homeoffice.emailapi.templatedemailfactory.serverconfig.HtmlEmailFactory;
import uk.gov.homeoffice.emailapi.templatedemailfactory.templating.TemplatePopulator;
import uk.gov.homeoffice.emailapi.templatedemailfactory.templating.TemplatePopulatorIOException;
import uk.gov.homeoffice.emailapi.templatedemailfactory.templating.TemplatePopulatorParsingException;
import javax.mail.internet.InternetAddress;
import java.util.Collection; | package uk.gov.homeoffice.emailapi.templatedemailfactory;
public class TemplatedEmailFactoryImpl implements TemplatedEmailFactory {
private final TemplatePopulator templateEngine;
private final InternetAddressParser addressParser; | // Path: src/main/java/uk/gov/homeoffice/emailapi/entities/TemplatedEmail.java
// @ApiModel(description = "Enough information to populate and send and email based on a template")
// @JsonDeserialize(as = TemplatedEmailImpl.class)
// @JsonSerialize(as = TemplatedEmailImpl.class)
// public interface TemplatedEmail {
// @ApiModelProperty(value = "Sender of the email in format \"example@example.org\" or \"Annie Example <annie@example.com>\"", required = true)
// String getSender();
//
// @ApiModelProperty(value = "Subject of the email", required = true)
// String getSubject();
//
// @ApiModelProperty(value = "If a recipient uses HTML to view their they will see this template", required = true)
// String getHtmlTemplate();
//
// @ApiModelProperty(value = "If a recipient uses TXT to view their they will see this template", required = true)
// String getTextTemplate();
//
// @ApiModelProperty(value = "Variables to pass to both templates with string keys, and any JSON Number, String, Array, Object as the value ", required = true)
// Map<String, Object> getVariables();
//
// @ApiModelProperty(value = "Array of recipients in an array of strings in format \"example@example.org\" or \"Annie Example <annie@example.com>\"", required = true)
// Collection<String> getRecipients();
// }
//
// Path: src/main/java/uk/gov/homeoffice/emailapi/templatedemailfactory/addressparsing/InternetAddressParser.java
// public interface InternetAddressParser {
//
// Collection<InternetAddress> getInternetAddresses(Collection<String> unparsedRecipients)
// throws InternetAddressParsingException;
// }
//
// Path: src/main/java/uk/gov/homeoffice/emailapi/templatedemailfactory/addressparsing/InternetAddressParsingException.java
// public class InternetAddressParsingException extends Exception {
// public InternetAddressParsingException(final Throwable cause) {
// super(cause);
// }
// }
//
// Path: src/main/java/uk/gov/homeoffice/emailapi/templatedemailfactory/serverconfig/HtmlEmailFactory.java
// public interface HtmlEmailFactory {
// HtmlEmail getHtmlEmail();
// }
//
// Path: src/main/java/uk/gov/homeoffice/emailapi/templatedemailfactory/templating/TemplatePopulator.java
// public interface TemplatePopulator {
// String populateTemplate(String template, Map<String, Object> variables)
// throws TemplatePopulatorIOException, TemplatePopulatorParsingException;
// }
//
// Path: src/main/java/uk/gov/homeoffice/emailapi/templatedemailfactory/templating/TemplatePopulatorIOException.java
// public class TemplatePopulatorIOException extends Exception {
// public TemplatePopulatorIOException(final Throwable cause) {
// super(cause);
// }
// }
//
// Path: src/main/java/uk/gov/homeoffice/emailapi/templatedemailfactory/templating/TemplatePopulatorParsingException.java
// public class TemplatePopulatorParsingException extends Exception {
// public TemplatePopulatorParsingException(Throwable cause) {
// super(cause);
// }
//
// public TemplatePopulatorParsingException(String message) {
// super(message);
// }
// }
// Path: src/main/java/uk/gov/homeoffice/emailapi/templatedemailfactory/TemplatedEmailFactoryImpl.java
import org.apache.commons.mail.EmailException;
import org.apache.commons.mail.HtmlEmail;
import uk.gov.homeoffice.emailapi.entities.TemplatedEmail;
import uk.gov.homeoffice.emailapi.templatedemailfactory.addressparsing.InternetAddressParser;
import uk.gov.homeoffice.emailapi.templatedemailfactory.addressparsing.InternetAddressParsingException;
import uk.gov.homeoffice.emailapi.templatedemailfactory.serverconfig.HtmlEmailFactory;
import uk.gov.homeoffice.emailapi.templatedemailfactory.templating.TemplatePopulator;
import uk.gov.homeoffice.emailapi.templatedemailfactory.templating.TemplatePopulatorIOException;
import uk.gov.homeoffice.emailapi.templatedemailfactory.templating.TemplatePopulatorParsingException;
import javax.mail.internet.InternetAddress;
import java.util.Collection;
package uk.gov.homeoffice.emailapi.templatedemailfactory;
public class TemplatedEmailFactoryImpl implements TemplatedEmailFactory {
private final TemplatePopulator templateEngine;
private final InternetAddressParser addressParser; | private final HtmlEmailFactory htmlEmailFactory; |
UKHomeOffice/email-api | src/main/java/uk/gov/homeoffice/emailapi/templatedemailfactory/TemplatedEmailFactoryImpl.java | // Path: src/main/java/uk/gov/homeoffice/emailapi/entities/TemplatedEmail.java
// @ApiModel(description = "Enough information to populate and send and email based on a template")
// @JsonDeserialize(as = TemplatedEmailImpl.class)
// @JsonSerialize(as = TemplatedEmailImpl.class)
// public interface TemplatedEmail {
// @ApiModelProperty(value = "Sender of the email in format \"example@example.org\" or \"Annie Example <annie@example.com>\"", required = true)
// String getSender();
//
// @ApiModelProperty(value = "Subject of the email", required = true)
// String getSubject();
//
// @ApiModelProperty(value = "If a recipient uses HTML to view their they will see this template", required = true)
// String getHtmlTemplate();
//
// @ApiModelProperty(value = "If a recipient uses TXT to view their they will see this template", required = true)
// String getTextTemplate();
//
// @ApiModelProperty(value = "Variables to pass to both templates with string keys, and any JSON Number, String, Array, Object as the value ", required = true)
// Map<String, Object> getVariables();
//
// @ApiModelProperty(value = "Array of recipients in an array of strings in format \"example@example.org\" or \"Annie Example <annie@example.com>\"", required = true)
// Collection<String> getRecipients();
// }
//
// Path: src/main/java/uk/gov/homeoffice/emailapi/templatedemailfactory/addressparsing/InternetAddressParser.java
// public interface InternetAddressParser {
//
// Collection<InternetAddress> getInternetAddresses(Collection<String> unparsedRecipients)
// throws InternetAddressParsingException;
// }
//
// Path: src/main/java/uk/gov/homeoffice/emailapi/templatedemailfactory/addressparsing/InternetAddressParsingException.java
// public class InternetAddressParsingException extends Exception {
// public InternetAddressParsingException(final Throwable cause) {
// super(cause);
// }
// }
//
// Path: src/main/java/uk/gov/homeoffice/emailapi/templatedemailfactory/serverconfig/HtmlEmailFactory.java
// public interface HtmlEmailFactory {
// HtmlEmail getHtmlEmail();
// }
//
// Path: src/main/java/uk/gov/homeoffice/emailapi/templatedemailfactory/templating/TemplatePopulator.java
// public interface TemplatePopulator {
// String populateTemplate(String template, Map<String, Object> variables)
// throws TemplatePopulatorIOException, TemplatePopulatorParsingException;
// }
//
// Path: src/main/java/uk/gov/homeoffice/emailapi/templatedemailfactory/templating/TemplatePopulatorIOException.java
// public class TemplatePopulatorIOException extends Exception {
// public TemplatePopulatorIOException(final Throwable cause) {
// super(cause);
// }
// }
//
// Path: src/main/java/uk/gov/homeoffice/emailapi/templatedemailfactory/templating/TemplatePopulatorParsingException.java
// public class TemplatePopulatorParsingException extends Exception {
// public TemplatePopulatorParsingException(Throwable cause) {
// super(cause);
// }
//
// public TemplatePopulatorParsingException(String message) {
// super(message);
// }
// }
| import org.apache.commons.mail.EmailException;
import org.apache.commons.mail.HtmlEmail;
import uk.gov.homeoffice.emailapi.entities.TemplatedEmail;
import uk.gov.homeoffice.emailapi.templatedemailfactory.addressparsing.InternetAddressParser;
import uk.gov.homeoffice.emailapi.templatedemailfactory.addressparsing.InternetAddressParsingException;
import uk.gov.homeoffice.emailapi.templatedemailfactory.serverconfig.HtmlEmailFactory;
import uk.gov.homeoffice.emailapi.templatedemailfactory.templating.TemplatePopulator;
import uk.gov.homeoffice.emailapi.templatedemailfactory.templating.TemplatePopulatorIOException;
import uk.gov.homeoffice.emailapi.templatedemailfactory.templating.TemplatePopulatorParsingException;
import javax.mail.internet.InternetAddress;
import java.util.Collection; | package uk.gov.homeoffice.emailapi.templatedemailfactory;
public class TemplatedEmailFactoryImpl implements TemplatedEmailFactory {
private final TemplatePopulator templateEngine;
private final InternetAddressParser addressParser;
private final HtmlEmailFactory htmlEmailFactory;
public TemplatedEmailFactoryImpl(TemplatePopulator templateEngine,
InternetAddressParser addressParser, HtmlEmailFactory htmlEmailFactory) {
this.templateEngine = templateEngine;
this.addressParser = addressParser;
this.htmlEmailFactory = htmlEmailFactory;
}
| // Path: src/main/java/uk/gov/homeoffice/emailapi/entities/TemplatedEmail.java
// @ApiModel(description = "Enough information to populate and send and email based on a template")
// @JsonDeserialize(as = TemplatedEmailImpl.class)
// @JsonSerialize(as = TemplatedEmailImpl.class)
// public interface TemplatedEmail {
// @ApiModelProperty(value = "Sender of the email in format \"example@example.org\" or \"Annie Example <annie@example.com>\"", required = true)
// String getSender();
//
// @ApiModelProperty(value = "Subject of the email", required = true)
// String getSubject();
//
// @ApiModelProperty(value = "If a recipient uses HTML to view their they will see this template", required = true)
// String getHtmlTemplate();
//
// @ApiModelProperty(value = "If a recipient uses TXT to view their they will see this template", required = true)
// String getTextTemplate();
//
// @ApiModelProperty(value = "Variables to pass to both templates with string keys, and any JSON Number, String, Array, Object as the value ", required = true)
// Map<String, Object> getVariables();
//
// @ApiModelProperty(value = "Array of recipients in an array of strings in format \"example@example.org\" or \"Annie Example <annie@example.com>\"", required = true)
// Collection<String> getRecipients();
// }
//
// Path: src/main/java/uk/gov/homeoffice/emailapi/templatedemailfactory/addressparsing/InternetAddressParser.java
// public interface InternetAddressParser {
//
// Collection<InternetAddress> getInternetAddresses(Collection<String> unparsedRecipients)
// throws InternetAddressParsingException;
// }
//
// Path: src/main/java/uk/gov/homeoffice/emailapi/templatedemailfactory/addressparsing/InternetAddressParsingException.java
// public class InternetAddressParsingException extends Exception {
// public InternetAddressParsingException(final Throwable cause) {
// super(cause);
// }
// }
//
// Path: src/main/java/uk/gov/homeoffice/emailapi/templatedemailfactory/serverconfig/HtmlEmailFactory.java
// public interface HtmlEmailFactory {
// HtmlEmail getHtmlEmail();
// }
//
// Path: src/main/java/uk/gov/homeoffice/emailapi/templatedemailfactory/templating/TemplatePopulator.java
// public interface TemplatePopulator {
// String populateTemplate(String template, Map<String, Object> variables)
// throws TemplatePopulatorIOException, TemplatePopulatorParsingException;
// }
//
// Path: src/main/java/uk/gov/homeoffice/emailapi/templatedemailfactory/templating/TemplatePopulatorIOException.java
// public class TemplatePopulatorIOException extends Exception {
// public TemplatePopulatorIOException(final Throwable cause) {
// super(cause);
// }
// }
//
// Path: src/main/java/uk/gov/homeoffice/emailapi/templatedemailfactory/templating/TemplatePopulatorParsingException.java
// public class TemplatePopulatorParsingException extends Exception {
// public TemplatePopulatorParsingException(Throwable cause) {
// super(cause);
// }
//
// public TemplatePopulatorParsingException(String message) {
// super(message);
// }
// }
// Path: src/main/java/uk/gov/homeoffice/emailapi/templatedemailfactory/TemplatedEmailFactoryImpl.java
import org.apache.commons.mail.EmailException;
import org.apache.commons.mail.HtmlEmail;
import uk.gov.homeoffice.emailapi.entities.TemplatedEmail;
import uk.gov.homeoffice.emailapi.templatedemailfactory.addressparsing.InternetAddressParser;
import uk.gov.homeoffice.emailapi.templatedemailfactory.addressparsing.InternetAddressParsingException;
import uk.gov.homeoffice.emailapi.templatedemailfactory.serverconfig.HtmlEmailFactory;
import uk.gov.homeoffice.emailapi.templatedemailfactory.templating.TemplatePopulator;
import uk.gov.homeoffice.emailapi.templatedemailfactory.templating.TemplatePopulatorIOException;
import uk.gov.homeoffice.emailapi.templatedemailfactory.templating.TemplatePopulatorParsingException;
import javax.mail.internet.InternetAddress;
import java.util.Collection;
package uk.gov.homeoffice.emailapi.templatedemailfactory;
public class TemplatedEmailFactoryImpl implements TemplatedEmailFactory {
private final TemplatePopulator templateEngine;
private final InternetAddressParser addressParser;
private final HtmlEmailFactory htmlEmailFactory;
public TemplatedEmailFactoryImpl(TemplatePopulator templateEngine,
InternetAddressParser addressParser, HtmlEmailFactory htmlEmailFactory) {
this.templateEngine = templateEngine;
this.addressParser = addressParser;
this.htmlEmailFactory = htmlEmailFactory;
}
| public HtmlEmail build(final TemplatedEmail templatedEmail) |
UKHomeOffice/email-api | src/main/java/uk/gov/homeoffice/emailapi/templatedemailfactory/TemplatedEmailFactoryImpl.java | // Path: src/main/java/uk/gov/homeoffice/emailapi/entities/TemplatedEmail.java
// @ApiModel(description = "Enough information to populate and send and email based on a template")
// @JsonDeserialize(as = TemplatedEmailImpl.class)
// @JsonSerialize(as = TemplatedEmailImpl.class)
// public interface TemplatedEmail {
// @ApiModelProperty(value = "Sender of the email in format \"example@example.org\" or \"Annie Example <annie@example.com>\"", required = true)
// String getSender();
//
// @ApiModelProperty(value = "Subject of the email", required = true)
// String getSubject();
//
// @ApiModelProperty(value = "If a recipient uses HTML to view their they will see this template", required = true)
// String getHtmlTemplate();
//
// @ApiModelProperty(value = "If a recipient uses TXT to view their they will see this template", required = true)
// String getTextTemplate();
//
// @ApiModelProperty(value = "Variables to pass to both templates with string keys, and any JSON Number, String, Array, Object as the value ", required = true)
// Map<String, Object> getVariables();
//
// @ApiModelProperty(value = "Array of recipients in an array of strings in format \"example@example.org\" or \"Annie Example <annie@example.com>\"", required = true)
// Collection<String> getRecipients();
// }
//
// Path: src/main/java/uk/gov/homeoffice/emailapi/templatedemailfactory/addressparsing/InternetAddressParser.java
// public interface InternetAddressParser {
//
// Collection<InternetAddress> getInternetAddresses(Collection<String> unparsedRecipients)
// throws InternetAddressParsingException;
// }
//
// Path: src/main/java/uk/gov/homeoffice/emailapi/templatedemailfactory/addressparsing/InternetAddressParsingException.java
// public class InternetAddressParsingException extends Exception {
// public InternetAddressParsingException(final Throwable cause) {
// super(cause);
// }
// }
//
// Path: src/main/java/uk/gov/homeoffice/emailapi/templatedemailfactory/serverconfig/HtmlEmailFactory.java
// public interface HtmlEmailFactory {
// HtmlEmail getHtmlEmail();
// }
//
// Path: src/main/java/uk/gov/homeoffice/emailapi/templatedemailfactory/templating/TemplatePopulator.java
// public interface TemplatePopulator {
// String populateTemplate(String template, Map<String, Object> variables)
// throws TemplatePopulatorIOException, TemplatePopulatorParsingException;
// }
//
// Path: src/main/java/uk/gov/homeoffice/emailapi/templatedemailfactory/templating/TemplatePopulatorIOException.java
// public class TemplatePopulatorIOException extends Exception {
// public TemplatePopulatorIOException(final Throwable cause) {
// super(cause);
// }
// }
//
// Path: src/main/java/uk/gov/homeoffice/emailapi/templatedemailfactory/templating/TemplatePopulatorParsingException.java
// public class TemplatePopulatorParsingException extends Exception {
// public TemplatePopulatorParsingException(Throwable cause) {
// super(cause);
// }
//
// public TemplatePopulatorParsingException(String message) {
// super(message);
// }
// }
| import org.apache.commons.mail.EmailException;
import org.apache.commons.mail.HtmlEmail;
import uk.gov.homeoffice.emailapi.entities.TemplatedEmail;
import uk.gov.homeoffice.emailapi.templatedemailfactory.addressparsing.InternetAddressParser;
import uk.gov.homeoffice.emailapi.templatedemailfactory.addressparsing.InternetAddressParsingException;
import uk.gov.homeoffice.emailapi.templatedemailfactory.serverconfig.HtmlEmailFactory;
import uk.gov.homeoffice.emailapi.templatedemailfactory.templating.TemplatePopulator;
import uk.gov.homeoffice.emailapi.templatedemailfactory.templating.TemplatePopulatorIOException;
import uk.gov.homeoffice.emailapi.templatedemailfactory.templating.TemplatePopulatorParsingException;
import javax.mail.internet.InternetAddress;
import java.util.Collection; | package uk.gov.homeoffice.emailapi.templatedemailfactory;
public class TemplatedEmailFactoryImpl implements TemplatedEmailFactory {
private final TemplatePopulator templateEngine;
private final InternetAddressParser addressParser;
private final HtmlEmailFactory htmlEmailFactory;
public TemplatedEmailFactoryImpl(TemplatePopulator templateEngine,
InternetAddressParser addressParser, HtmlEmailFactory htmlEmailFactory) {
this.templateEngine = templateEngine;
this.addressParser = addressParser;
this.htmlEmailFactory = htmlEmailFactory;
}
public HtmlEmail build(final TemplatedEmail templatedEmail) | // Path: src/main/java/uk/gov/homeoffice/emailapi/entities/TemplatedEmail.java
// @ApiModel(description = "Enough information to populate and send and email based on a template")
// @JsonDeserialize(as = TemplatedEmailImpl.class)
// @JsonSerialize(as = TemplatedEmailImpl.class)
// public interface TemplatedEmail {
// @ApiModelProperty(value = "Sender of the email in format \"example@example.org\" or \"Annie Example <annie@example.com>\"", required = true)
// String getSender();
//
// @ApiModelProperty(value = "Subject of the email", required = true)
// String getSubject();
//
// @ApiModelProperty(value = "If a recipient uses HTML to view their they will see this template", required = true)
// String getHtmlTemplate();
//
// @ApiModelProperty(value = "If a recipient uses TXT to view their they will see this template", required = true)
// String getTextTemplate();
//
// @ApiModelProperty(value = "Variables to pass to both templates with string keys, and any JSON Number, String, Array, Object as the value ", required = true)
// Map<String, Object> getVariables();
//
// @ApiModelProperty(value = "Array of recipients in an array of strings in format \"example@example.org\" or \"Annie Example <annie@example.com>\"", required = true)
// Collection<String> getRecipients();
// }
//
// Path: src/main/java/uk/gov/homeoffice/emailapi/templatedemailfactory/addressparsing/InternetAddressParser.java
// public interface InternetAddressParser {
//
// Collection<InternetAddress> getInternetAddresses(Collection<String> unparsedRecipients)
// throws InternetAddressParsingException;
// }
//
// Path: src/main/java/uk/gov/homeoffice/emailapi/templatedemailfactory/addressparsing/InternetAddressParsingException.java
// public class InternetAddressParsingException extends Exception {
// public InternetAddressParsingException(final Throwable cause) {
// super(cause);
// }
// }
//
// Path: src/main/java/uk/gov/homeoffice/emailapi/templatedemailfactory/serverconfig/HtmlEmailFactory.java
// public interface HtmlEmailFactory {
// HtmlEmail getHtmlEmail();
// }
//
// Path: src/main/java/uk/gov/homeoffice/emailapi/templatedemailfactory/templating/TemplatePopulator.java
// public interface TemplatePopulator {
// String populateTemplate(String template, Map<String, Object> variables)
// throws TemplatePopulatorIOException, TemplatePopulatorParsingException;
// }
//
// Path: src/main/java/uk/gov/homeoffice/emailapi/templatedemailfactory/templating/TemplatePopulatorIOException.java
// public class TemplatePopulatorIOException extends Exception {
// public TemplatePopulatorIOException(final Throwable cause) {
// super(cause);
// }
// }
//
// Path: src/main/java/uk/gov/homeoffice/emailapi/templatedemailfactory/templating/TemplatePopulatorParsingException.java
// public class TemplatePopulatorParsingException extends Exception {
// public TemplatePopulatorParsingException(Throwable cause) {
// super(cause);
// }
//
// public TemplatePopulatorParsingException(String message) {
// super(message);
// }
// }
// Path: src/main/java/uk/gov/homeoffice/emailapi/templatedemailfactory/TemplatedEmailFactoryImpl.java
import org.apache.commons.mail.EmailException;
import org.apache.commons.mail.HtmlEmail;
import uk.gov.homeoffice.emailapi.entities.TemplatedEmail;
import uk.gov.homeoffice.emailapi.templatedemailfactory.addressparsing.InternetAddressParser;
import uk.gov.homeoffice.emailapi.templatedemailfactory.addressparsing.InternetAddressParsingException;
import uk.gov.homeoffice.emailapi.templatedemailfactory.serverconfig.HtmlEmailFactory;
import uk.gov.homeoffice.emailapi.templatedemailfactory.templating.TemplatePopulator;
import uk.gov.homeoffice.emailapi.templatedemailfactory.templating.TemplatePopulatorIOException;
import uk.gov.homeoffice.emailapi.templatedemailfactory.templating.TemplatePopulatorParsingException;
import javax.mail.internet.InternetAddress;
import java.util.Collection;
package uk.gov.homeoffice.emailapi.templatedemailfactory;
public class TemplatedEmailFactoryImpl implements TemplatedEmailFactory {
private final TemplatePopulator templateEngine;
private final InternetAddressParser addressParser;
private final HtmlEmailFactory htmlEmailFactory;
public TemplatedEmailFactoryImpl(TemplatePopulator templateEngine,
InternetAddressParser addressParser, HtmlEmailFactory htmlEmailFactory) {
this.templateEngine = templateEngine;
this.addressParser = addressParser;
this.htmlEmailFactory = htmlEmailFactory;
}
public HtmlEmail build(final TemplatedEmail templatedEmail) | throws EmailException, TemplatePopulatorParsingException, TemplatePopulatorIOException, |
UKHomeOffice/email-api | src/main/java/uk/gov/homeoffice/emailapi/templatedemailfactory/TemplatedEmailFactoryImpl.java | // Path: src/main/java/uk/gov/homeoffice/emailapi/entities/TemplatedEmail.java
// @ApiModel(description = "Enough information to populate and send and email based on a template")
// @JsonDeserialize(as = TemplatedEmailImpl.class)
// @JsonSerialize(as = TemplatedEmailImpl.class)
// public interface TemplatedEmail {
// @ApiModelProperty(value = "Sender of the email in format \"example@example.org\" or \"Annie Example <annie@example.com>\"", required = true)
// String getSender();
//
// @ApiModelProperty(value = "Subject of the email", required = true)
// String getSubject();
//
// @ApiModelProperty(value = "If a recipient uses HTML to view their they will see this template", required = true)
// String getHtmlTemplate();
//
// @ApiModelProperty(value = "If a recipient uses TXT to view their they will see this template", required = true)
// String getTextTemplate();
//
// @ApiModelProperty(value = "Variables to pass to both templates with string keys, and any JSON Number, String, Array, Object as the value ", required = true)
// Map<String, Object> getVariables();
//
// @ApiModelProperty(value = "Array of recipients in an array of strings in format \"example@example.org\" or \"Annie Example <annie@example.com>\"", required = true)
// Collection<String> getRecipients();
// }
//
// Path: src/main/java/uk/gov/homeoffice/emailapi/templatedemailfactory/addressparsing/InternetAddressParser.java
// public interface InternetAddressParser {
//
// Collection<InternetAddress> getInternetAddresses(Collection<String> unparsedRecipients)
// throws InternetAddressParsingException;
// }
//
// Path: src/main/java/uk/gov/homeoffice/emailapi/templatedemailfactory/addressparsing/InternetAddressParsingException.java
// public class InternetAddressParsingException extends Exception {
// public InternetAddressParsingException(final Throwable cause) {
// super(cause);
// }
// }
//
// Path: src/main/java/uk/gov/homeoffice/emailapi/templatedemailfactory/serverconfig/HtmlEmailFactory.java
// public interface HtmlEmailFactory {
// HtmlEmail getHtmlEmail();
// }
//
// Path: src/main/java/uk/gov/homeoffice/emailapi/templatedemailfactory/templating/TemplatePopulator.java
// public interface TemplatePopulator {
// String populateTemplate(String template, Map<String, Object> variables)
// throws TemplatePopulatorIOException, TemplatePopulatorParsingException;
// }
//
// Path: src/main/java/uk/gov/homeoffice/emailapi/templatedemailfactory/templating/TemplatePopulatorIOException.java
// public class TemplatePopulatorIOException extends Exception {
// public TemplatePopulatorIOException(final Throwable cause) {
// super(cause);
// }
// }
//
// Path: src/main/java/uk/gov/homeoffice/emailapi/templatedemailfactory/templating/TemplatePopulatorParsingException.java
// public class TemplatePopulatorParsingException extends Exception {
// public TemplatePopulatorParsingException(Throwable cause) {
// super(cause);
// }
//
// public TemplatePopulatorParsingException(String message) {
// super(message);
// }
// }
| import org.apache.commons.mail.EmailException;
import org.apache.commons.mail.HtmlEmail;
import uk.gov.homeoffice.emailapi.entities.TemplatedEmail;
import uk.gov.homeoffice.emailapi.templatedemailfactory.addressparsing.InternetAddressParser;
import uk.gov.homeoffice.emailapi.templatedemailfactory.addressparsing.InternetAddressParsingException;
import uk.gov.homeoffice.emailapi.templatedemailfactory.serverconfig.HtmlEmailFactory;
import uk.gov.homeoffice.emailapi.templatedemailfactory.templating.TemplatePopulator;
import uk.gov.homeoffice.emailapi.templatedemailfactory.templating.TemplatePopulatorIOException;
import uk.gov.homeoffice.emailapi.templatedemailfactory.templating.TemplatePopulatorParsingException;
import javax.mail.internet.InternetAddress;
import java.util.Collection; | package uk.gov.homeoffice.emailapi.templatedemailfactory;
public class TemplatedEmailFactoryImpl implements TemplatedEmailFactory {
private final TemplatePopulator templateEngine;
private final InternetAddressParser addressParser;
private final HtmlEmailFactory htmlEmailFactory;
public TemplatedEmailFactoryImpl(TemplatePopulator templateEngine,
InternetAddressParser addressParser, HtmlEmailFactory htmlEmailFactory) {
this.templateEngine = templateEngine;
this.addressParser = addressParser;
this.htmlEmailFactory = htmlEmailFactory;
}
public HtmlEmail build(final TemplatedEmail templatedEmail) | // Path: src/main/java/uk/gov/homeoffice/emailapi/entities/TemplatedEmail.java
// @ApiModel(description = "Enough information to populate and send and email based on a template")
// @JsonDeserialize(as = TemplatedEmailImpl.class)
// @JsonSerialize(as = TemplatedEmailImpl.class)
// public interface TemplatedEmail {
// @ApiModelProperty(value = "Sender of the email in format \"example@example.org\" or \"Annie Example <annie@example.com>\"", required = true)
// String getSender();
//
// @ApiModelProperty(value = "Subject of the email", required = true)
// String getSubject();
//
// @ApiModelProperty(value = "If a recipient uses HTML to view their they will see this template", required = true)
// String getHtmlTemplate();
//
// @ApiModelProperty(value = "If a recipient uses TXT to view their they will see this template", required = true)
// String getTextTemplate();
//
// @ApiModelProperty(value = "Variables to pass to both templates with string keys, and any JSON Number, String, Array, Object as the value ", required = true)
// Map<String, Object> getVariables();
//
// @ApiModelProperty(value = "Array of recipients in an array of strings in format \"example@example.org\" or \"Annie Example <annie@example.com>\"", required = true)
// Collection<String> getRecipients();
// }
//
// Path: src/main/java/uk/gov/homeoffice/emailapi/templatedemailfactory/addressparsing/InternetAddressParser.java
// public interface InternetAddressParser {
//
// Collection<InternetAddress> getInternetAddresses(Collection<String> unparsedRecipients)
// throws InternetAddressParsingException;
// }
//
// Path: src/main/java/uk/gov/homeoffice/emailapi/templatedemailfactory/addressparsing/InternetAddressParsingException.java
// public class InternetAddressParsingException extends Exception {
// public InternetAddressParsingException(final Throwable cause) {
// super(cause);
// }
// }
//
// Path: src/main/java/uk/gov/homeoffice/emailapi/templatedemailfactory/serverconfig/HtmlEmailFactory.java
// public interface HtmlEmailFactory {
// HtmlEmail getHtmlEmail();
// }
//
// Path: src/main/java/uk/gov/homeoffice/emailapi/templatedemailfactory/templating/TemplatePopulator.java
// public interface TemplatePopulator {
// String populateTemplate(String template, Map<String, Object> variables)
// throws TemplatePopulatorIOException, TemplatePopulatorParsingException;
// }
//
// Path: src/main/java/uk/gov/homeoffice/emailapi/templatedemailfactory/templating/TemplatePopulatorIOException.java
// public class TemplatePopulatorIOException extends Exception {
// public TemplatePopulatorIOException(final Throwable cause) {
// super(cause);
// }
// }
//
// Path: src/main/java/uk/gov/homeoffice/emailapi/templatedemailfactory/templating/TemplatePopulatorParsingException.java
// public class TemplatePopulatorParsingException extends Exception {
// public TemplatePopulatorParsingException(Throwable cause) {
// super(cause);
// }
//
// public TemplatePopulatorParsingException(String message) {
// super(message);
// }
// }
// Path: src/main/java/uk/gov/homeoffice/emailapi/templatedemailfactory/TemplatedEmailFactoryImpl.java
import org.apache.commons.mail.EmailException;
import org.apache.commons.mail.HtmlEmail;
import uk.gov.homeoffice.emailapi.entities.TemplatedEmail;
import uk.gov.homeoffice.emailapi.templatedemailfactory.addressparsing.InternetAddressParser;
import uk.gov.homeoffice.emailapi.templatedemailfactory.addressparsing.InternetAddressParsingException;
import uk.gov.homeoffice.emailapi.templatedemailfactory.serverconfig.HtmlEmailFactory;
import uk.gov.homeoffice.emailapi.templatedemailfactory.templating.TemplatePopulator;
import uk.gov.homeoffice.emailapi.templatedemailfactory.templating.TemplatePopulatorIOException;
import uk.gov.homeoffice.emailapi.templatedemailfactory.templating.TemplatePopulatorParsingException;
import javax.mail.internet.InternetAddress;
import java.util.Collection;
package uk.gov.homeoffice.emailapi.templatedemailfactory;
public class TemplatedEmailFactoryImpl implements TemplatedEmailFactory {
private final TemplatePopulator templateEngine;
private final InternetAddressParser addressParser;
private final HtmlEmailFactory htmlEmailFactory;
public TemplatedEmailFactoryImpl(TemplatePopulator templateEngine,
InternetAddressParser addressParser, HtmlEmailFactory htmlEmailFactory) {
this.templateEngine = templateEngine;
this.addressParser = addressParser;
this.htmlEmailFactory = htmlEmailFactory;
}
public HtmlEmail build(final TemplatedEmail templatedEmail) | throws EmailException, TemplatePopulatorParsingException, TemplatePopulatorIOException, |
UKHomeOffice/email-api | src/main/java/uk/gov/homeoffice/emailapi/templatedemailfactory/TemplatedEmailFactoryImpl.java | // Path: src/main/java/uk/gov/homeoffice/emailapi/entities/TemplatedEmail.java
// @ApiModel(description = "Enough information to populate and send and email based on a template")
// @JsonDeserialize(as = TemplatedEmailImpl.class)
// @JsonSerialize(as = TemplatedEmailImpl.class)
// public interface TemplatedEmail {
// @ApiModelProperty(value = "Sender of the email in format \"example@example.org\" or \"Annie Example <annie@example.com>\"", required = true)
// String getSender();
//
// @ApiModelProperty(value = "Subject of the email", required = true)
// String getSubject();
//
// @ApiModelProperty(value = "If a recipient uses HTML to view their they will see this template", required = true)
// String getHtmlTemplate();
//
// @ApiModelProperty(value = "If a recipient uses TXT to view their they will see this template", required = true)
// String getTextTemplate();
//
// @ApiModelProperty(value = "Variables to pass to both templates with string keys, and any JSON Number, String, Array, Object as the value ", required = true)
// Map<String, Object> getVariables();
//
// @ApiModelProperty(value = "Array of recipients in an array of strings in format \"example@example.org\" or \"Annie Example <annie@example.com>\"", required = true)
// Collection<String> getRecipients();
// }
//
// Path: src/main/java/uk/gov/homeoffice/emailapi/templatedemailfactory/addressparsing/InternetAddressParser.java
// public interface InternetAddressParser {
//
// Collection<InternetAddress> getInternetAddresses(Collection<String> unparsedRecipients)
// throws InternetAddressParsingException;
// }
//
// Path: src/main/java/uk/gov/homeoffice/emailapi/templatedemailfactory/addressparsing/InternetAddressParsingException.java
// public class InternetAddressParsingException extends Exception {
// public InternetAddressParsingException(final Throwable cause) {
// super(cause);
// }
// }
//
// Path: src/main/java/uk/gov/homeoffice/emailapi/templatedemailfactory/serverconfig/HtmlEmailFactory.java
// public interface HtmlEmailFactory {
// HtmlEmail getHtmlEmail();
// }
//
// Path: src/main/java/uk/gov/homeoffice/emailapi/templatedemailfactory/templating/TemplatePopulator.java
// public interface TemplatePopulator {
// String populateTemplate(String template, Map<String, Object> variables)
// throws TemplatePopulatorIOException, TemplatePopulatorParsingException;
// }
//
// Path: src/main/java/uk/gov/homeoffice/emailapi/templatedemailfactory/templating/TemplatePopulatorIOException.java
// public class TemplatePopulatorIOException extends Exception {
// public TemplatePopulatorIOException(final Throwable cause) {
// super(cause);
// }
// }
//
// Path: src/main/java/uk/gov/homeoffice/emailapi/templatedemailfactory/templating/TemplatePopulatorParsingException.java
// public class TemplatePopulatorParsingException extends Exception {
// public TemplatePopulatorParsingException(Throwable cause) {
// super(cause);
// }
//
// public TemplatePopulatorParsingException(String message) {
// super(message);
// }
// }
| import org.apache.commons.mail.EmailException;
import org.apache.commons.mail.HtmlEmail;
import uk.gov.homeoffice.emailapi.entities.TemplatedEmail;
import uk.gov.homeoffice.emailapi.templatedemailfactory.addressparsing.InternetAddressParser;
import uk.gov.homeoffice.emailapi.templatedemailfactory.addressparsing.InternetAddressParsingException;
import uk.gov.homeoffice.emailapi.templatedemailfactory.serverconfig.HtmlEmailFactory;
import uk.gov.homeoffice.emailapi.templatedemailfactory.templating.TemplatePopulator;
import uk.gov.homeoffice.emailapi.templatedemailfactory.templating.TemplatePopulatorIOException;
import uk.gov.homeoffice.emailapi.templatedemailfactory.templating.TemplatePopulatorParsingException;
import javax.mail.internet.InternetAddress;
import java.util.Collection; | package uk.gov.homeoffice.emailapi.templatedemailfactory;
public class TemplatedEmailFactoryImpl implements TemplatedEmailFactory {
private final TemplatePopulator templateEngine;
private final InternetAddressParser addressParser;
private final HtmlEmailFactory htmlEmailFactory;
public TemplatedEmailFactoryImpl(TemplatePopulator templateEngine,
InternetAddressParser addressParser, HtmlEmailFactory htmlEmailFactory) {
this.templateEngine = templateEngine;
this.addressParser = addressParser;
this.htmlEmailFactory = htmlEmailFactory;
}
public HtmlEmail build(final TemplatedEmail templatedEmail)
throws EmailException, TemplatePopulatorParsingException, TemplatePopulatorIOException, | // Path: src/main/java/uk/gov/homeoffice/emailapi/entities/TemplatedEmail.java
// @ApiModel(description = "Enough information to populate and send and email based on a template")
// @JsonDeserialize(as = TemplatedEmailImpl.class)
// @JsonSerialize(as = TemplatedEmailImpl.class)
// public interface TemplatedEmail {
// @ApiModelProperty(value = "Sender of the email in format \"example@example.org\" or \"Annie Example <annie@example.com>\"", required = true)
// String getSender();
//
// @ApiModelProperty(value = "Subject of the email", required = true)
// String getSubject();
//
// @ApiModelProperty(value = "If a recipient uses HTML to view their they will see this template", required = true)
// String getHtmlTemplate();
//
// @ApiModelProperty(value = "If a recipient uses TXT to view their they will see this template", required = true)
// String getTextTemplate();
//
// @ApiModelProperty(value = "Variables to pass to both templates with string keys, and any JSON Number, String, Array, Object as the value ", required = true)
// Map<String, Object> getVariables();
//
// @ApiModelProperty(value = "Array of recipients in an array of strings in format \"example@example.org\" or \"Annie Example <annie@example.com>\"", required = true)
// Collection<String> getRecipients();
// }
//
// Path: src/main/java/uk/gov/homeoffice/emailapi/templatedemailfactory/addressparsing/InternetAddressParser.java
// public interface InternetAddressParser {
//
// Collection<InternetAddress> getInternetAddresses(Collection<String> unparsedRecipients)
// throws InternetAddressParsingException;
// }
//
// Path: src/main/java/uk/gov/homeoffice/emailapi/templatedemailfactory/addressparsing/InternetAddressParsingException.java
// public class InternetAddressParsingException extends Exception {
// public InternetAddressParsingException(final Throwable cause) {
// super(cause);
// }
// }
//
// Path: src/main/java/uk/gov/homeoffice/emailapi/templatedemailfactory/serverconfig/HtmlEmailFactory.java
// public interface HtmlEmailFactory {
// HtmlEmail getHtmlEmail();
// }
//
// Path: src/main/java/uk/gov/homeoffice/emailapi/templatedemailfactory/templating/TemplatePopulator.java
// public interface TemplatePopulator {
// String populateTemplate(String template, Map<String, Object> variables)
// throws TemplatePopulatorIOException, TemplatePopulatorParsingException;
// }
//
// Path: src/main/java/uk/gov/homeoffice/emailapi/templatedemailfactory/templating/TemplatePopulatorIOException.java
// public class TemplatePopulatorIOException extends Exception {
// public TemplatePopulatorIOException(final Throwable cause) {
// super(cause);
// }
// }
//
// Path: src/main/java/uk/gov/homeoffice/emailapi/templatedemailfactory/templating/TemplatePopulatorParsingException.java
// public class TemplatePopulatorParsingException extends Exception {
// public TemplatePopulatorParsingException(Throwable cause) {
// super(cause);
// }
//
// public TemplatePopulatorParsingException(String message) {
// super(message);
// }
// }
// Path: src/main/java/uk/gov/homeoffice/emailapi/templatedemailfactory/TemplatedEmailFactoryImpl.java
import org.apache.commons.mail.EmailException;
import org.apache.commons.mail.HtmlEmail;
import uk.gov.homeoffice.emailapi.entities.TemplatedEmail;
import uk.gov.homeoffice.emailapi.templatedemailfactory.addressparsing.InternetAddressParser;
import uk.gov.homeoffice.emailapi.templatedemailfactory.addressparsing.InternetAddressParsingException;
import uk.gov.homeoffice.emailapi.templatedemailfactory.serverconfig.HtmlEmailFactory;
import uk.gov.homeoffice.emailapi.templatedemailfactory.templating.TemplatePopulator;
import uk.gov.homeoffice.emailapi.templatedemailfactory.templating.TemplatePopulatorIOException;
import uk.gov.homeoffice.emailapi.templatedemailfactory.templating.TemplatePopulatorParsingException;
import javax.mail.internet.InternetAddress;
import java.util.Collection;
package uk.gov.homeoffice.emailapi.templatedemailfactory;
public class TemplatedEmailFactoryImpl implements TemplatedEmailFactory {
private final TemplatePopulator templateEngine;
private final InternetAddressParser addressParser;
private final HtmlEmailFactory htmlEmailFactory;
public TemplatedEmailFactoryImpl(TemplatePopulator templateEngine,
InternetAddressParser addressParser, HtmlEmailFactory htmlEmailFactory) {
this.templateEngine = templateEngine;
this.addressParser = addressParser;
this.htmlEmailFactory = htmlEmailFactory;
}
public HtmlEmail build(final TemplatedEmail templatedEmail)
throws EmailException, TemplatePopulatorParsingException, TemplatePopulatorIOException, | InternetAddressParsingException { |
UKHomeOffice/email-api | src/main/java/uk/gov/homeoffice/emailapi/templatedemailfactory/TemplatedEmailFactory.java | // Path: src/main/java/uk/gov/homeoffice/emailapi/entities/TemplatedEmail.java
// @ApiModel(description = "Enough information to populate and send and email based on a template")
// @JsonDeserialize(as = TemplatedEmailImpl.class)
// @JsonSerialize(as = TemplatedEmailImpl.class)
// public interface TemplatedEmail {
// @ApiModelProperty(value = "Sender of the email in format \"example@example.org\" or \"Annie Example <annie@example.com>\"", required = true)
// String getSender();
//
// @ApiModelProperty(value = "Subject of the email", required = true)
// String getSubject();
//
// @ApiModelProperty(value = "If a recipient uses HTML to view their they will see this template", required = true)
// String getHtmlTemplate();
//
// @ApiModelProperty(value = "If a recipient uses TXT to view their they will see this template", required = true)
// String getTextTemplate();
//
// @ApiModelProperty(value = "Variables to pass to both templates with string keys, and any JSON Number, String, Array, Object as the value ", required = true)
// Map<String, Object> getVariables();
//
// @ApiModelProperty(value = "Array of recipients in an array of strings in format \"example@example.org\" or \"Annie Example <annie@example.com>\"", required = true)
// Collection<String> getRecipients();
// }
//
// Path: src/main/java/uk/gov/homeoffice/emailapi/templatedemailfactory/addressparsing/InternetAddressParsingException.java
// public class InternetAddressParsingException extends Exception {
// public InternetAddressParsingException(final Throwable cause) {
// super(cause);
// }
// }
//
// Path: src/main/java/uk/gov/homeoffice/emailapi/templatedemailfactory/templating/TemplatePopulatorIOException.java
// public class TemplatePopulatorIOException extends Exception {
// public TemplatePopulatorIOException(final Throwable cause) {
// super(cause);
// }
// }
//
// Path: src/main/java/uk/gov/homeoffice/emailapi/templatedemailfactory/templating/TemplatePopulatorParsingException.java
// public class TemplatePopulatorParsingException extends Exception {
// public TemplatePopulatorParsingException(Throwable cause) {
// super(cause);
// }
//
// public TemplatePopulatorParsingException(String message) {
// super(message);
// }
// }
| import org.apache.commons.mail.Email;
import org.apache.commons.mail.EmailException;
import uk.gov.homeoffice.emailapi.entities.TemplatedEmail;
import uk.gov.homeoffice.emailapi.templatedemailfactory.addressparsing.InternetAddressParsingException;
import uk.gov.homeoffice.emailapi.templatedemailfactory.templating.TemplatePopulatorIOException;
import uk.gov.homeoffice.emailapi.templatedemailfactory.templating.TemplatePopulatorParsingException; | package uk.gov.homeoffice.emailapi.templatedemailfactory;
public interface TemplatedEmailFactory {
Email build(TemplatedEmail templatedEmail) | // Path: src/main/java/uk/gov/homeoffice/emailapi/entities/TemplatedEmail.java
// @ApiModel(description = "Enough information to populate and send and email based on a template")
// @JsonDeserialize(as = TemplatedEmailImpl.class)
// @JsonSerialize(as = TemplatedEmailImpl.class)
// public interface TemplatedEmail {
// @ApiModelProperty(value = "Sender of the email in format \"example@example.org\" or \"Annie Example <annie@example.com>\"", required = true)
// String getSender();
//
// @ApiModelProperty(value = "Subject of the email", required = true)
// String getSubject();
//
// @ApiModelProperty(value = "If a recipient uses HTML to view their they will see this template", required = true)
// String getHtmlTemplate();
//
// @ApiModelProperty(value = "If a recipient uses TXT to view their they will see this template", required = true)
// String getTextTemplate();
//
// @ApiModelProperty(value = "Variables to pass to both templates with string keys, and any JSON Number, String, Array, Object as the value ", required = true)
// Map<String, Object> getVariables();
//
// @ApiModelProperty(value = "Array of recipients in an array of strings in format \"example@example.org\" or \"Annie Example <annie@example.com>\"", required = true)
// Collection<String> getRecipients();
// }
//
// Path: src/main/java/uk/gov/homeoffice/emailapi/templatedemailfactory/addressparsing/InternetAddressParsingException.java
// public class InternetAddressParsingException extends Exception {
// public InternetAddressParsingException(final Throwable cause) {
// super(cause);
// }
// }
//
// Path: src/main/java/uk/gov/homeoffice/emailapi/templatedemailfactory/templating/TemplatePopulatorIOException.java
// public class TemplatePopulatorIOException extends Exception {
// public TemplatePopulatorIOException(final Throwable cause) {
// super(cause);
// }
// }
//
// Path: src/main/java/uk/gov/homeoffice/emailapi/templatedemailfactory/templating/TemplatePopulatorParsingException.java
// public class TemplatePopulatorParsingException extends Exception {
// public TemplatePopulatorParsingException(Throwable cause) {
// super(cause);
// }
//
// public TemplatePopulatorParsingException(String message) {
// super(message);
// }
// }
// Path: src/main/java/uk/gov/homeoffice/emailapi/templatedemailfactory/TemplatedEmailFactory.java
import org.apache.commons.mail.Email;
import org.apache.commons.mail.EmailException;
import uk.gov.homeoffice.emailapi.entities.TemplatedEmail;
import uk.gov.homeoffice.emailapi.templatedemailfactory.addressparsing.InternetAddressParsingException;
import uk.gov.homeoffice.emailapi.templatedemailfactory.templating.TemplatePopulatorIOException;
import uk.gov.homeoffice.emailapi.templatedemailfactory.templating.TemplatePopulatorParsingException;
package uk.gov.homeoffice.emailapi.templatedemailfactory;
public interface TemplatedEmailFactory {
Email build(TemplatedEmail templatedEmail) | throws EmailException, TemplatePopulatorParsingException, TemplatePopulatorIOException, |
UKHomeOffice/email-api | src/main/java/uk/gov/homeoffice/emailapi/templatedemailfactory/TemplatedEmailFactory.java | // Path: src/main/java/uk/gov/homeoffice/emailapi/entities/TemplatedEmail.java
// @ApiModel(description = "Enough information to populate and send and email based on a template")
// @JsonDeserialize(as = TemplatedEmailImpl.class)
// @JsonSerialize(as = TemplatedEmailImpl.class)
// public interface TemplatedEmail {
// @ApiModelProperty(value = "Sender of the email in format \"example@example.org\" or \"Annie Example <annie@example.com>\"", required = true)
// String getSender();
//
// @ApiModelProperty(value = "Subject of the email", required = true)
// String getSubject();
//
// @ApiModelProperty(value = "If a recipient uses HTML to view their they will see this template", required = true)
// String getHtmlTemplate();
//
// @ApiModelProperty(value = "If a recipient uses TXT to view their they will see this template", required = true)
// String getTextTemplate();
//
// @ApiModelProperty(value = "Variables to pass to both templates with string keys, and any JSON Number, String, Array, Object as the value ", required = true)
// Map<String, Object> getVariables();
//
// @ApiModelProperty(value = "Array of recipients in an array of strings in format \"example@example.org\" or \"Annie Example <annie@example.com>\"", required = true)
// Collection<String> getRecipients();
// }
//
// Path: src/main/java/uk/gov/homeoffice/emailapi/templatedemailfactory/addressparsing/InternetAddressParsingException.java
// public class InternetAddressParsingException extends Exception {
// public InternetAddressParsingException(final Throwable cause) {
// super(cause);
// }
// }
//
// Path: src/main/java/uk/gov/homeoffice/emailapi/templatedemailfactory/templating/TemplatePopulatorIOException.java
// public class TemplatePopulatorIOException extends Exception {
// public TemplatePopulatorIOException(final Throwable cause) {
// super(cause);
// }
// }
//
// Path: src/main/java/uk/gov/homeoffice/emailapi/templatedemailfactory/templating/TemplatePopulatorParsingException.java
// public class TemplatePopulatorParsingException extends Exception {
// public TemplatePopulatorParsingException(Throwable cause) {
// super(cause);
// }
//
// public TemplatePopulatorParsingException(String message) {
// super(message);
// }
// }
| import org.apache.commons.mail.Email;
import org.apache.commons.mail.EmailException;
import uk.gov.homeoffice.emailapi.entities.TemplatedEmail;
import uk.gov.homeoffice.emailapi.templatedemailfactory.addressparsing.InternetAddressParsingException;
import uk.gov.homeoffice.emailapi.templatedemailfactory.templating.TemplatePopulatorIOException;
import uk.gov.homeoffice.emailapi.templatedemailfactory.templating.TemplatePopulatorParsingException; | package uk.gov.homeoffice.emailapi.templatedemailfactory;
public interface TemplatedEmailFactory {
Email build(TemplatedEmail templatedEmail) | // Path: src/main/java/uk/gov/homeoffice/emailapi/entities/TemplatedEmail.java
// @ApiModel(description = "Enough information to populate and send and email based on a template")
// @JsonDeserialize(as = TemplatedEmailImpl.class)
// @JsonSerialize(as = TemplatedEmailImpl.class)
// public interface TemplatedEmail {
// @ApiModelProperty(value = "Sender of the email in format \"example@example.org\" or \"Annie Example <annie@example.com>\"", required = true)
// String getSender();
//
// @ApiModelProperty(value = "Subject of the email", required = true)
// String getSubject();
//
// @ApiModelProperty(value = "If a recipient uses HTML to view their they will see this template", required = true)
// String getHtmlTemplate();
//
// @ApiModelProperty(value = "If a recipient uses TXT to view their they will see this template", required = true)
// String getTextTemplate();
//
// @ApiModelProperty(value = "Variables to pass to both templates with string keys, and any JSON Number, String, Array, Object as the value ", required = true)
// Map<String, Object> getVariables();
//
// @ApiModelProperty(value = "Array of recipients in an array of strings in format \"example@example.org\" or \"Annie Example <annie@example.com>\"", required = true)
// Collection<String> getRecipients();
// }
//
// Path: src/main/java/uk/gov/homeoffice/emailapi/templatedemailfactory/addressparsing/InternetAddressParsingException.java
// public class InternetAddressParsingException extends Exception {
// public InternetAddressParsingException(final Throwable cause) {
// super(cause);
// }
// }
//
// Path: src/main/java/uk/gov/homeoffice/emailapi/templatedemailfactory/templating/TemplatePopulatorIOException.java
// public class TemplatePopulatorIOException extends Exception {
// public TemplatePopulatorIOException(final Throwable cause) {
// super(cause);
// }
// }
//
// Path: src/main/java/uk/gov/homeoffice/emailapi/templatedemailfactory/templating/TemplatePopulatorParsingException.java
// public class TemplatePopulatorParsingException extends Exception {
// public TemplatePopulatorParsingException(Throwable cause) {
// super(cause);
// }
//
// public TemplatePopulatorParsingException(String message) {
// super(message);
// }
// }
// Path: src/main/java/uk/gov/homeoffice/emailapi/templatedemailfactory/TemplatedEmailFactory.java
import org.apache.commons.mail.Email;
import org.apache.commons.mail.EmailException;
import uk.gov.homeoffice.emailapi.entities.TemplatedEmail;
import uk.gov.homeoffice.emailapi.templatedemailfactory.addressparsing.InternetAddressParsingException;
import uk.gov.homeoffice.emailapi.templatedemailfactory.templating.TemplatePopulatorIOException;
import uk.gov.homeoffice.emailapi.templatedemailfactory.templating.TemplatePopulatorParsingException;
package uk.gov.homeoffice.emailapi.templatedemailfactory;
public interface TemplatedEmailFactory {
Email build(TemplatedEmail templatedEmail) | throws EmailException, TemplatePopulatorParsingException, TemplatePopulatorIOException, |
UKHomeOffice/email-api | src/main/java/uk/gov/homeoffice/emailapi/templatedemailfactory/TemplatedEmailFactory.java | // Path: src/main/java/uk/gov/homeoffice/emailapi/entities/TemplatedEmail.java
// @ApiModel(description = "Enough information to populate and send and email based on a template")
// @JsonDeserialize(as = TemplatedEmailImpl.class)
// @JsonSerialize(as = TemplatedEmailImpl.class)
// public interface TemplatedEmail {
// @ApiModelProperty(value = "Sender of the email in format \"example@example.org\" or \"Annie Example <annie@example.com>\"", required = true)
// String getSender();
//
// @ApiModelProperty(value = "Subject of the email", required = true)
// String getSubject();
//
// @ApiModelProperty(value = "If a recipient uses HTML to view their they will see this template", required = true)
// String getHtmlTemplate();
//
// @ApiModelProperty(value = "If a recipient uses TXT to view their they will see this template", required = true)
// String getTextTemplate();
//
// @ApiModelProperty(value = "Variables to pass to both templates with string keys, and any JSON Number, String, Array, Object as the value ", required = true)
// Map<String, Object> getVariables();
//
// @ApiModelProperty(value = "Array of recipients in an array of strings in format \"example@example.org\" or \"Annie Example <annie@example.com>\"", required = true)
// Collection<String> getRecipients();
// }
//
// Path: src/main/java/uk/gov/homeoffice/emailapi/templatedemailfactory/addressparsing/InternetAddressParsingException.java
// public class InternetAddressParsingException extends Exception {
// public InternetAddressParsingException(final Throwable cause) {
// super(cause);
// }
// }
//
// Path: src/main/java/uk/gov/homeoffice/emailapi/templatedemailfactory/templating/TemplatePopulatorIOException.java
// public class TemplatePopulatorIOException extends Exception {
// public TemplatePopulatorIOException(final Throwable cause) {
// super(cause);
// }
// }
//
// Path: src/main/java/uk/gov/homeoffice/emailapi/templatedemailfactory/templating/TemplatePopulatorParsingException.java
// public class TemplatePopulatorParsingException extends Exception {
// public TemplatePopulatorParsingException(Throwable cause) {
// super(cause);
// }
//
// public TemplatePopulatorParsingException(String message) {
// super(message);
// }
// }
| import org.apache.commons.mail.Email;
import org.apache.commons.mail.EmailException;
import uk.gov.homeoffice.emailapi.entities.TemplatedEmail;
import uk.gov.homeoffice.emailapi.templatedemailfactory.addressparsing.InternetAddressParsingException;
import uk.gov.homeoffice.emailapi.templatedemailfactory.templating.TemplatePopulatorIOException;
import uk.gov.homeoffice.emailapi.templatedemailfactory.templating.TemplatePopulatorParsingException; | package uk.gov.homeoffice.emailapi.templatedemailfactory;
public interface TemplatedEmailFactory {
Email build(TemplatedEmail templatedEmail)
throws EmailException, TemplatePopulatorParsingException, TemplatePopulatorIOException, | // Path: src/main/java/uk/gov/homeoffice/emailapi/entities/TemplatedEmail.java
// @ApiModel(description = "Enough information to populate and send and email based on a template")
// @JsonDeserialize(as = TemplatedEmailImpl.class)
// @JsonSerialize(as = TemplatedEmailImpl.class)
// public interface TemplatedEmail {
// @ApiModelProperty(value = "Sender of the email in format \"example@example.org\" or \"Annie Example <annie@example.com>\"", required = true)
// String getSender();
//
// @ApiModelProperty(value = "Subject of the email", required = true)
// String getSubject();
//
// @ApiModelProperty(value = "If a recipient uses HTML to view their they will see this template", required = true)
// String getHtmlTemplate();
//
// @ApiModelProperty(value = "If a recipient uses TXT to view their they will see this template", required = true)
// String getTextTemplate();
//
// @ApiModelProperty(value = "Variables to pass to both templates with string keys, and any JSON Number, String, Array, Object as the value ", required = true)
// Map<String, Object> getVariables();
//
// @ApiModelProperty(value = "Array of recipients in an array of strings in format \"example@example.org\" or \"Annie Example <annie@example.com>\"", required = true)
// Collection<String> getRecipients();
// }
//
// Path: src/main/java/uk/gov/homeoffice/emailapi/templatedemailfactory/addressparsing/InternetAddressParsingException.java
// public class InternetAddressParsingException extends Exception {
// public InternetAddressParsingException(final Throwable cause) {
// super(cause);
// }
// }
//
// Path: src/main/java/uk/gov/homeoffice/emailapi/templatedemailfactory/templating/TemplatePopulatorIOException.java
// public class TemplatePopulatorIOException extends Exception {
// public TemplatePopulatorIOException(final Throwable cause) {
// super(cause);
// }
// }
//
// Path: src/main/java/uk/gov/homeoffice/emailapi/templatedemailfactory/templating/TemplatePopulatorParsingException.java
// public class TemplatePopulatorParsingException extends Exception {
// public TemplatePopulatorParsingException(Throwable cause) {
// super(cause);
// }
//
// public TemplatePopulatorParsingException(String message) {
// super(message);
// }
// }
// Path: src/main/java/uk/gov/homeoffice/emailapi/templatedemailfactory/TemplatedEmailFactory.java
import org.apache.commons.mail.Email;
import org.apache.commons.mail.EmailException;
import uk.gov.homeoffice.emailapi.entities.TemplatedEmail;
import uk.gov.homeoffice.emailapi.templatedemailfactory.addressparsing.InternetAddressParsingException;
import uk.gov.homeoffice.emailapi.templatedemailfactory.templating.TemplatePopulatorIOException;
import uk.gov.homeoffice.emailapi.templatedemailfactory.templating.TemplatePopulatorParsingException;
package uk.gov.homeoffice.emailapi.templatedemailfactory;
public interface TemplatedEmailFactory {
Email build(TemplatedEmail templatedEmail)
throws EmailException, TemplatePopulatorParsingException, TemplatePopulatorIOException, | InternetAddressParsingException; |
UKHomeOffice/email-api | src/test/java/uk/gov/homeoffice/emailapi/service/TemplatedEmailSenderImplTest.java | // Path: src/main/java/uk/gov/homeoffice/emailapi/entities/TemplatedEmail.java
// @ApiModel(description = "Enough information to populate and send and email based on a template")
// @JsonDeserialize(as = TemplatedEmailImpl.class)
// @JsonSerialize(as = TemplatedEmailImpl.class)
// public interface TemplatedEmail {
// @ApiModelProperty(value = "Sender of the email in format \"example@example.org\" or \"Annie Example <annie@example.com>\"", required = true)
// String getSender();
//
// @ApiModelProperty(value = "Subject of the email", required = true)
// String getSubject();
//
// @ApiModelProperty(value = "If a recipient uses HTML to view their they will see this template", required = true)
// String getHtmlTemplate();
//
// @ApiModelProperty(value = "If a recipient uses TXT to view their they will see this template", required = true)
// String getTextTemplate();
//
// @ApiModelProperty(value = "Variables to pass to both templates with string keys, and any JSON Number, String, Array, Object as the value ", required = true)
// Map<String, Object> getVariables();
//
// @ApiModelProperty(value = "Array of recipients in an array of strings in format \"example@example.org\" or \"Annie Example <annie@example.com>\"", required = true)
// Collection<String> getRecipients();
// }
//
// Path: src/main/java/uk/gov/homeoffice/emailapi/templatedemailfactory/TemplatedEmailFactory.java
// public interface TemplatedEmailFactory {
// Email build(TemplatedEmail templatedEmail)
// throws EmailException, TemplatePopulatorParsingException, TemplatePopulatorIOException,
// InternetAddressParsingException;
// }
//
// Path: src/main/java/uk/gov/homeoffice/emailapi/templatedemailfactory/addressparsing/InternetAddressParsingException.java
// public class InternetAddressParsingException extends Exception {
// public InternetAddressParsingException(final Throwable cause) {
// super(cause);
// }
// }
//
// Path: src/main/java/uk/gov/homeoffice/emailapi/templatedemailfactory/templating/TemplatePopulatorIOException.java
// public class TemplatePopulatorIOException extends Exception {
// public TemplatePopulatorIOException(final Throwable cause) {
// super(cause);
// }
// }
//
// Path: src/main/java/uk/gov/homeoffice/emailapi/templatedemailfactory/templating/TemplatePopulatorParsingException.java
// public class TemplatePopulatorParsingException extends Exception {
// public TemplatePopulatorParsingException(Throwable cause) {
// super(cause);
// }
//
// public TemplatePopulatorParsingException(String message) {
// super(message);
// }
// }
| import org.apache.commons.mail.Email;
import org.apache.commons.mail.EmailException;
import org.junit.Test;
import uk.gov.homeoffice.emailapi.entities.TemplatedEmail;
import uk.gov.homeoffice.emailapi.templatedemailfactory.TemplatedEmailFactory;
import uk.gov.homeoffice.emailapi.templatedemailfactory.addressparsing.InternetAddressParsingException;
import uk.gov.homeoffice.emailapi.templatedemailfactory.templating.TemplatePopulatorIOException;
import uk.gov.homeoffice.emailapi.templatedemailfactory.templating.TemplatePopulatorParsingException;
import static org.mockito.Mockito.*; | package uk.gov.homeoffice.emailapi.service;
public class TemplatedEmailSenderImplTest {
@Test
public void itGetsATemplatedEmailAndSendsIt() | // Path: src/main/java/uk/gov/homeoffice/emailapi/entities/TemplatedEmail.java
// @ApiModel(description = "Enough information to populate and send and email based on a template")
// @JsonDeserialize(as = TemplatedEmailImpl.class)
// @JsonSerialize(as = TemplatedEmailImpl.class)
// public interface TemplatedEmail {
// @ApiModelProperty(value = "Sender of the email in format \"example@example.org\" or \"Annie Example <annie@example.com>\"", required = true)
// String getSender();
//
// @ApiModelProperty(value = "Subject of the email", required = true)
// String getSubject();
//
// @ApiModelProperty(value = "If a recipient uses HTML to view their they will see this template", required = true)
// String getHtmlTemplate();
//
// @ApiModelProperty(value = "If a recipient uses TXT to view their they will see this template", required = true)
// String getTextTemplate();
//
// @ApiModelProperty(value = "Variables to pass to both templates with string keys, and any JSON Number, String, Array, Object as the value ", required = true)
// Map<String, Object> getVariables();
//
// @ApiModelProperty(value = "Array of recipients in an array of strings in format \"example@example.org\" or \"Annie Example <annie@example.com>\"", required = true)
// Collection<String> getRecipients();
// }
//
// Path: src/main/java/uk/gov/homeoffice/emailapi/templatedemailfactory/TemplatedEmailFactory.java
// public interface TemplatedEmailFactory {
// Email build(TemplatedEmail templatedEmail)
// throws EmailException, TemplatePopulatorParsingException, TemplatePopulatorIOException,
// InternetAddressParsingException;
// }
//
// Path: src/main/java/uk/gov/homeoffice/emailapi/templatedemailfactory/addressparsing/InternetAddressParsingException.java
// public class InternetAddressParsingException extends Exception {
// public InternetAddressParsingException(final Throwable cause) {
// super(cause);
// }
// }
//
// Path: src/main/java/uk/gov/homeoffice/emailapi/templatedemailfactory/templating/TemplatePopulatorIOException.java
// public class TemplatePopulatorIOException extends Exception {
// public TemplatePopulatorIOException(final Throwable cause) {
// super(cause);
// }
// }
//
// Path: src/main/java/uk/gov/homeoffice/emailapi/templatedemailfactory/templating/TemplatePopulatorParsingException.java
// public class TemplatePopulatorParsingException extends Exception {
// public TemplatePopulatorParsingException(Throwable cause) {
// super(cause);
// }
//
// public TemplatePopulatorParsingException(String message) {
// super(message);
// }
// }
// Path: src/test/java/uk/gov/homeoffice/emailapi/service/TemplatedEmailSenderImplTest.java
import org.apache.commons.mail.Email;
import org.apache.commons.mail.EmailException;
import org.junit.Test;
import uk.gov.homeoffice.emailapi.entities.TemplatedEmail;
import uk.gov.homeoffice.emailapi.templatedemailfactory.TemplatedEmailFactory;
import uk.gov.homeoffice.emailapi.templatedemailfactory.addressparsing.InternetAddressParsingException;
import uk.gov.homeoffice.emailapi.templatedemailfactory.templating.TemplatePopulatorIOException;
import uk.gov.homeoffice.emailapi.templatedemailfactory.templating.TemplatePopulatorParsingException;
import static org.mockito.Mockito.*;
package uk.gov.homeoffice.emailapi.service;
public class TemplatedEmailSenderImplTest {
@Test
public void itGetsATemplatedEmailAndSendsIt() | throws TemplatePopulatorParsingException, InternetAddressParsingException, |
UKHomeOffice/email-api | src/test/java/uk/gov/homeoffice/emailapi/service/TemplatedEmailSenderImplTest.java | // Path: src/main/java/uk/gov/homeoffice/emailapi/entities/TemplatedEmail.java
// @ApiModel(description = "Enough information to populate and send and email based on a template")
// @JsonDeserialize(as = TemplatedEmailImpl.class)
// @JsonSerialize(as = TemplatedEmailImpl.class)
// public interface TemplatedEmail {
// @ApiModelProperty(value = "Sender of the email in format \"example@example.org\" or \"Annie Example <annie@example.com>\"", required = true)
// String getSender();
//
// @ApiModelProperty(value = "Subject of the email", required = true)
// String getSubject();
//
// @ApiModelProperty(value = "If a recipient uses HTML to view their they will see this template", required = true)
// String getHtmlTemplate();
//
// @ApiModelProperty(value = "If a recipient uses TXT to view their they will see this template", required = true)
// String getTextTemplate();
//
// @ApiModelProperty(value = "Variables to pass to both templates with string keys, and any JSON Number, String, Array, Object as the value ", required = true)
// Map<String, Object> getVariables();
//
// @ApiModelProperty(value = "Array of recipients in an array of strings in format \"example@example.org\" or \"Annie Example <annie@example.com>\"", required = true)
// Collection<String> getRecipients();
// }
//
// Path: src/main/java/uk/gov/homeoffice/emailapi/templatedemailfactory/TemplatedEmailFactory.java
// public interface TemplatedEmailFactory {
// Email build(TemplatedEmail templatedEmail)
// throws EmailException, TemplatePopulatorParsingException, TemplatePopulatorIOException,
// InternetAddressParsingException;
// }
//
// Path: src/main/java/uk/gov/homeoffice/emailapi/templatedemailfactory/addressparsing/InternetAddressParsingException.java
// public class InternetAddressParsingException extends Exception {
// public InternetAddressParsingException(final Throwable cause) {
// super(cause);
// }
// }
//
// Path: src/main/java/uk/gov/homeoffice/emailapi/templatedemailfactory/templating/TemplatePopulatorIOException.java
// public class TemplatePopulatorIOException extends Exception {
// public TemplatePopulatorIOException(final Throwable cause) {
// super(cause);
// }
// }
//
// Path: src/main/java/uk/gov/homeoffice/emailapi/templatedemailfactory/templating/TemplatePopulatorParsingException.java
// public class TemplatePopulatorParsingException extends Exception {
// public TemplatePopulatorParsingException(Throwable cause) {
// super(cause);
// }
//
// public TemplatePopulatorParsingException(String message) {
// super(message);
// }
// }
| import org.apache.commons.mail.Email;
import org.apache.commons.mail.EmailException;
import org.junit.Test;
import uk.gov.homeoffice.emailapi.entities.TemplatedEmail;
import uk.gov.homeoffice.emailapi.templatedemailfactory.TemplatedEmailFactory;
import uk.gov.homeoffice.emailapi.templatedemailfactory.addressparsing.InternetAddressParsingException;
import uk.gov.homeoffice.emailapi.templatedemailfactory.templating.TemplatePopulatorIOException;
import uk.gov.homeoffice.emailapi.templatedemailfactory.templating.TemplatePopulatorParsingException;
import static org.mockito.Mockito.*; | package uk.gov.homeoffice.emailapi.service;
public class TemplatedEmailSenderImplTest {
@Test
public void itGetsATemplatedEmailAndSendsIt() | // Path: src/main/java/uk/gov/homeoffice/emailapi/entities/TemplatedEmail.java
// @ApiModel(description = "Enough information to populate and send and email based on a template")
// @JsonDeserialize(as = TemplatedEmailImpl.class)
// @JsonSerialize(as = TemplatedEmailImpl.class)
// public interface TemplatedEmail {
// @ApiModelProperty(value = "Sender of the email in format \"example@example.org\" or \"Annie Example <annie@example.com>\"", required = true)
// String getSender();
//
// @ApiModelProperty(value = "Subject of the email", required = true)
// String getSubject();
//
// @ApiModelProperty(value = "If a recipient uses HTML to view their they will see this template", required = true)
// String getHtmlTemplate();
//
// @ApiModelProperty(value = "If a recipient uses TXT to view their they will see this template", required = true)
// String getTextTemplate();
//
// @ApiModelProperty(value = "Variables to pass to both templates with string keys, and any JSON Number, String, Array, Object as the value ", required = true)
// Map<String, Object> getVariables();
//
// @ApiModelProperty(value = "Array of recipients in an array of strings in format \"example@example.org\" or \"Annie Example <annie@example.com>\"", required = true)
// Collection<String> getRecipients();
// }
//
// Path: src/main/java/uk/gov/homeoffice/emailapi/templatedemailfactory/TemplatedEmailFactory.java
// public interface TemplatedEmailFactory {
// Email build(TemplatedEmail templatedEmail)
// throws EmailException, TemplatePopulatorParsingException, TemplatePopulatorIOException,
// InternetAddressParsingException;
// }
//
// Path: src/main/java/uk/gov/homeoffice/emailapi/templatedemailfactory/addressparsing/InternetAddressParsingException.java
// public class InternetAddressParsingException extends Exception {
// public InternetAddressParsingException(final Throwable cause) {
// super(cause);
// }
// }
//
// Path: src/main/java/uk/gov/homeoffice/emailapi/templatedemailfactory/templating/TemplatePopulatorIOException.java
// public class TemplatePopulatorIOException extends Exception {
// public TemplatePopulatorIOException(final Throwable cause) {
// super(cause);
// }
// }
//
// Path: src/main/java/uk/gov/homeoffice/emailapi/templatedemailfactory/templating/TemplatePopulatorParsingException.java
// public class TemplatePopulatorParsingException extends Exception {
// public TemplatePopulatorParsingException(Throwable cause) {
// super(cause);
// }
//
// public TemplatePopulatorParsingException(String message) {
// super(message);
// }
// }
// Path: src/test/java/uk/gov/homeoffice/emailapi/service/TemplatedEmailSenderImplTest.java
import org.apache.commons.mail.Email;
import org.apache.commons.mail.EmailException;
import org.junit.Test;
import uk.gov.homeoffice.emailapi.entities.TemplatedEmail;
import uk.gov.homeoffice.emailapi.templatedemailfactory.TemplatedEmailFactory;
import uk.gov.homeoffice.emailapi.templatedemailfactory.addressparsing.InternetAddressParsingException;
import uk.gov.homeoffice.emailapi.templatedemailfactory.templating.TemplatePopulatorIOException;
import uk.gov.homeoffice.emailapi.templatedemailfactory.templating.TemplatePopulatorParsingException;
import static org.mockito.Mockito.*;
package uk.gov.homeoffice.emailapi.service;
public class TemplatedEmailSenderImplTest {
@Test
public void itGetsATemplatedEmailAndSendsIt() | throws TemplatePopulatorParsingException, InternetAddressParsingException, |
UKHomeOffice/email-api | src/test/java/uk/gov/homeoffice/emailapi/service/TemplatedEmailSenderImplTest.java | // Path: src/main/java/uk/gov/homeoffice/emailapi/entities/TemplatedEmail.java
// @ApiModel(description = "Enough information to populate and send and email based on a template")
// @JsonDeserialize(as = TemplatedEmailImpl.class)
// @JsonSerialize(as = TemplatedEmailImpl.class)
// public interface TemplatedEmail {
// @ApiModelProperty(value = "Sender of the email in format \"example@example.org\" or \"Annie Example <annie@example.com>\"", required = true)
// String getSender();
//
// @ApiModelProperty(value = "Subject of the email", required = true)
// String getSubject();
//
// @ApiModelProperty(value = "If a recipient uses HTML to view their they will see this template", required = true)
// String getHtmlTemplate();
//
// @ApiModelProperty(value = "If a recipient uses TXT to view their they will see this template", required = true)
// String getTextTemplate();
//
// @ApiModelProperty(value = "Variables to pass to both templates with string keys, and any JSON Number, String, Array, Object as the value ", required = true)
// Map<String, Object> getVariables();
//
// @ApiModelProperty(value = "Array of recipients in an array of strings in format \"example@example.org\" or \"Annie Example <annie@example.com>\"", required = true)
// Collection<String> getRecipients();
// }
//
// Path: src/main/java/uk/gov/homeoffice/emailapi/templatedemailfactory/TemplatedEmailFactory.java
// public interface TemplatedEmailFactory {
// Email build(TemplatedEmail templatedEmail)
// throws EmailException, TemplatePopulatorParsingException, TemplatePopulatorIOException,
// InternetAddressParsingException;
// }
//
// Path: src/main/java/uk/gov/homeoffice/emailapi/templatedemailfactory/addressparsing/InternetAddressParsingException.java
// public class InternetAddressParsingException extends Exception {
// public InternetAddressParsingException(final Throwable cause) {
// super(cause);
// }
// }
//
// Path: src/main/java/uk/gov/homeoffice/emailapi/templatedemailfactory/templating/TemplatePopulatorIOException.java
// public class TemplatePopulatorIOException extends Exception {
// public TemplatePopulatorIOException(final Throwable cause) {
// super(cause);
// }
// }
//
// Path: src/main/java/uk/gov/homeoffice/emailapi/templatedemailfactory/templating/TemplatePopulatorParsingException.java
// public class TemplatePopulatorParsingException extends Exception {
// public TemplatePopulatorParsingException(Throwable cause) {
// super(cause);
// }
//
// public TemplatePopulatorParsingException(String message) {
// super(message);
// }
// }
| import org.apache.commons.mail.Email;
import org.apache.commons.mail.EmailException;
import org.junit.Test;
import uk.gov.homeoffice.emailapi.entities.TemplatedEmail;
import uk.gov.homeoffice.emailapi.templatedemailfactory.TemplatedEmailFactory;
import uk.gov.homeoffice.emailapi.templatedemailfactory.addressparsing.InternetAddressParsingException;
import uk.gov.homeoffice.emailapi.templatedemailfactory.templating.TemplatePopulatorIOException;
import uk.gov.homeoffice.emailapi.templatedemailfactory.templating.TemplatePopulatorParsingException;
import static org.mockito.Mockito.*; | package uk.gov.homeoffice.emailapi.service;
public class TemplatedEmailSenderImplTest {
@Test
public void itGetsATemplatedEmailAndSendsIt()
throws TemplatePopulatorParsingException, InternetAddressParsingException, | // Path: src/main/java/uk/gov/homeoffice/emailapi/entities/TemplatedEmail.java
// @ApiModel(description = "Enough information to populate and send and email based on a template")
// @JsonDeserialize(as = TemplatedEmailImpl.class)
// @JsonSerialize(as = TemplatedEmailImpl.class)
// public interface TemplatedEmail {
// @ApiModelProperty(value = "Sender of the email in format \"example@example.org\" or \"Annie Example <annie@example.com>\"", required = true)
// String getSender();
//
// @ApiModelProperty(value = "Subject of the email", required = true)
// String getSubject();
//
// @ApiModelProperty(value = "If a recipient uses HTML to view their they will see this template", required = true)
// String getHtmlTemplate();
//
// @ApiModelProperty(value = "If a recipient uses TXT to view their they will see this template", required = true)
// String getTextTemplate();
//
// @ApiModelProperty(value = "Variables to pass to both templates with string keys, and any JSON Number, String, Array, Object as the value ", required = true)
// Map<String, Object> getVariables();
//
// @ApiModelProperty(value = "Array of recipients in an array of strings in format \"example@example.org\" or \"Annie Example <annie@example.com>\"", required = true)
// Collection<String> getRecipients();
// }
//
// Path: src/main/java/uk/gov/homeoffice/emailapi/templatedemailfactory/TemplatedEmailFactory.java
// public interface TemplatedEmailFactory {
// Email build(TemplatedEmail templatedEmail)
// throws EmailException, TemplatePopulatorParsingException, TemplatePopulatorIOException,
// InternetAddressParsingException;
// }
//
// Path: src/main/java/uk/gov/homeoffice/emailapi/templatedemailfactory/addressparsing/InternetAddressParsingException.java
// public class InternetAddressParsingException extends Exception {
// public InternetAddressParsingException(final Throwable cause) {
// super(cause);
// }
// }
//
// Path: src/main/java/uk/gov/homeoffice/emailapi/templatedemailfactory/templating/TemplatePopulatorIOException.java
// public class TemplatePopulatorIOException extends Exception {
// public TemplatePopulatorIOException(final Throwable cause) {
// super(cause);
// }
// }
//
// Path: src/main/java/uk/gov/homeoffice/emailapi/templatedemailfactory/templating/TemplatePopulatorParsingException.java
// public class TemplatePopulatorParsingException extends Exception {
// public TemplatePopulatorParsingException(Throwable cause) {
// super(cause);
// }
//
// public TemplatePopulatorParsingException(String message) {
// super(message);
// }
// }
// Path: src/test/java/uk/gov/homeoffice/emailapi/service/TemplatedEmailSenderImplTest.java
import org.apache.commons.mail.Email;
import org.apache.commons.mail.EmailException;
import org.junit.Test;
import uk.gov.homeoffice.emailapi.entities.TemplatedEmail;
import uk.gov.homeoffice.emailapi.templatedemailfactory.TemplatedEmailFactory;
import uk.gov.homeoffice.emailapi.templatedemailfactory.addressparsing.InternetAddressParsingException;
import uk.gov.homeoffice.emailapi.templatedemailfactory.templating.TemplatePopulatorIOException;
import uk.gov.homeoffice.emailapi.templatedemailfactory.templating.TemplatePopulatorParsingException;
import static org.mockito.Mockito.*;
package uk.gov.homeoffice.emailapi.service;
public class TemplatedEmailSenderImplTest {
@Test
public void itGetsATemplatedEmailAndSendsIt()
throws TemplatePopulatorParsingException, InternetAddressParsingException, | TemplatePopulatorIOException, EmailException { |
UKHomeOffice/email-api | src/test/java/uk/gov/homeoffice/emailapi/service/TemplatedEmailSenderImplTest.java | // Path: src/main/java/uk/gov/homeoffice/emailapi/entities/TemplatedEmail.java
// @ApiModel(description = "Enough information to populate and send and email based on a template")
// @JsonDeserialize(as = TemplatedEmailImpl.class)
// @JsonSerialize(as = TemplatedEmailImpl.class)
// public interface TemplatedEmail {
// @ApiModelProperty(value = "Sender of the email in format \"example@example.org\" or \"Annie Example <annie@example.com>\"", required = true)
// String getSender();
//
// @ApiModelProperty(value = "Subject of the email", required = true)
// String getSubject();
//
// @ApiModelProperty(value = "If a recipient uses HTML to view their they will see this template", required = true)
// String getHtmlTemplate();
//
// @ApiModelProperty(value = "If a recipient uses TXT to view their they will see this template", required = true)
// String getTextTemplate();
//
// @ApiModelProperty(value = "Variables to pass to both templates with string keys, and any JSON Number, String, Array, Object as the value ", required = true)
// Map<String, Object> getVariables();
//
// @ApiModelProperty(value = "Array of recipients in an array of strings in format \"example@example.org\" or \"Annie Example <annie@example.com>\"", required = true)
// Collection<String> getRecipients();
// }
//
// Path: src/main/java/uk/gov/homeoffice/emailapi/templatedemailfactory/TemplatedEmailFactory.java
// public interface TemplatedEmailFactory {
// Email build(TemplatedEmail templatedEmail)
// throws EmailException, TemplatePopulatorParsingException, TemplatePopulatorIOException,
// InternetAddressParsingException;
// }
//
// Path: src/main/java/uk/gov/homeoffice/emailapi/templatedemailfactory/addressparsing/InternetAddressParsingException.java
// public class InternetAddressParsingException extends Exception {
// public InternetAddressParsingException(final Throwable cause) {
// super(cause);
// }
// }
//
// Path: src/main/java/uk/gov/homeoffice/emailapi/templatedemailfactory/templating/TemplatePopulatorIOException.java
// public class TemplatePopulatorIOException extends Exception {
// public TemplatePopulatorIOException(final Throwable cause) {
// super(cause);
// }
// }
//
// Path: src/main/java/uk/gov/homeoffice/emailapi/templatedemailfactory/templating/TemplatePopulatorParsingException.java
// public class TemplatePopulatorParsingException extends Exception {
// public TemplatePopulatorParsingException(Throwable cause) {
// super(cause);
// }
//
// public TemplatePopulatorParsingException(String message) {
// super(message);
// }
// }
| import org.apache.commons.mail.Email;
import org.apache.commons.mail.EmailException;
import org.junit.Test;
import uk.gov.homeoffice.emailapi.entities.TemplatedEmail;
import uk.gov.homeoffice.emailapi.templatedemailfactory.TemplatedEmailFactory;
import uk.gov.homeoffice.emailapi.templatedemailfactory.addressparsing.InternetAddressParsingException;
import uk.gov.homeoffice.emailapi.templatedemailfactory.templating.TemplatePopulatorIOException;
import uk.gov.homeoffice.emailapi.templatedemailfactory.templating.TemplatePopulatorParsingException;
import static org.mockito.Mockito.*; | package uk.gov.homeoffice.emailapi.service;
public class TemplatedEmailSenderImplTest {
@Test
public void itGetsATemplatedEmailAndSendsIt()
throws TemplatePopulatorParsingException, InternetAddressParsingException,
TemplatePopulatorIOException, EmailException { | // Path: src/main/java/uk/gov/homeoffice/emailapi/entities/TemplatedEmail.java
// @ApiModel(description = "Enough information to populate and send and email based on a template")
// @JsonDeserialize(as = TemplatedEmailImpl.class)
// @JsonSerialize(as = TemplatedEmailImpl.class)
// public interface TemplatedEmail {
// @ApiModelProperty(value = "Sender of the email in format \"example@example.org\" or \"Annie Example <annie@example.com>\"", required = true)
// String getSender();
//
// @ApiModelProperty(value = "Subject of the email", required = true)
// String getSubject();
//
// @ApiModelProperty(value = "If a recipient uses HTML to view their they will see this template", required = true)
// String getHtmlTemplate();
//
// @ApiModelProperty(value = "If a recipient uses TXT to view their they will see this template", required = true)
// String getTextTemplate();
//
// @ApiModelProperty(value = "Variables to pass to both templates with string keys, and any JSON Number, String, Array, Object as the value ", required = true)
// Map<String, Object> getVariables();
//
// @ApiModelProperty(value = "Array of recipients in an array of strings in format \"example@example.org\" or \"Annie Example <annie@example.com>\"", required = true)
// Collection<String> getRecipients();
// }
//
// Path: src/main/java/uk/gov/homeoffice/emailapi/templatedemailfactory/TemplatedEmailFactory.java
// public interface TemplatedEmailFactory {
// Email build(TemplatedEmail templatedEmail)
// throws EmailException, TemplatePopulatorParsingException, TemplatePopulatorIOException,
// InternetAddressParsingException;
// }
//
// Path: src/main/java/uk/gov/homeoffice/emailapi/templatedemailfactory/addressparsing/InternetAddressParsingException.java
// public class InternetAddressParsingException extends Exception {
// public InternetAddressParsingException(final Throwable cause) {
// super(cause);
// }
// }
//
// Path: src/main/java/uk/gov/homeoffice/emailapi/templatedemailfactory/templating/TemplatePopulatorIOException.java
// public class TemplatePopulatorIOException extends Exception {
// public TemplatePopulatorIOException(final Throwable cause) {
// super(cause);
// }
// }
//
// Path: src/main/java/uk/gov/homeoffice/emailapi/templatedemailfactory/templating/TemplatePopulatorParsingException.java
// public class TemplatePopulatorParsingException extends Exception {
// public TemplatePopulatorParsingException(Throwable cause) {
// super(cause);
// }
//
// public TemplatePopulatorParsingException(String message) {
// super(message);
// }
// }
// Path: src/test/java/uk/gov/homeoffice/emailapi/service/TemplatedEmailSenderImplTest.java
import org.apache.commons.mail.Email;
import org.apache.commons.mail.EmailException;
import org.junit.Test;
import uk.gov.homeoffice.emailapi.entities.TemplatedEmail;
import uk.gov.homeoffice.emailapi.templatedemailfactory.TemplatedEmailFactory;
import uk.gov.homeoffice.emailapi.templatedemailfactory.addressparsing.InternetAddressParsingException;
import uk.gov.homeoffice.emailapi.templatedemailfactory.templating.TemplatePopulatorIOException;
import uk.gov.homeoffice.emailapi.templatedemailfactory.templating.TemplatePopulatorParsingException;
import static org.mockito.Mockito.*;
package uk.gov.homeoffice.emailapi.service;
public class TemplatedEmailSenderImplTest {
@Test
public void itGetsATemplatedEmailAndSendsIt()
throws TemplatePopulatorParsingException, InternetAddressParsingException,
TemplatePopulatorIOException, EmailException { | final TemplatedEmail mockTemplatedEmail = mock(TemplatedEmail.class); |
UKHomeOffice/email-api | src/test/java/uk/gov/homeoffice/emailapi/service/TemplatedEmailSenderImplTest.java | // Path: src/main/java/uk/gov/homeoffice/emailapi/entities/TemplatedEmail.java
// @ApiModel(description = "Enough information to populate and send and email based on a template")
// @JsonDeserialize(as = TemplatedEmailImpl.class)
// @JsonSerialize(as = TemplatedEmailImpl.class)
// public interface TemplatedEmail {
// @ApiModelProperty(value = "Sender of the email in format \"example@example.org\" or \"Annie Example <annie@example.com>\"", required = true)
// String getSender();
//
// @ApiModelProperty(value = "Subject of the email", required = true)
// String getSubject();
//
// @ApiModelProperty(value = "If a recipient uses HTML to view their they will see this template", required = true)
// String getHtmlTemplate();
//
// @ApiModelProperty(value = "If a recipient uses TXT to view their they will see this template", required = true)
// String getTextTemplate();
//
// @ApiModelProperty(value = "Variables to pass to both templates with string keys, and any JSON Number, String, Array, Object as the value ", required = true)
// Map<String, Object> getVariables();
//
// @ApiModelProperty(value = "Array of recipients in an array of strings in format \"example@example.org\" or \"Annie Example <annie@example.com>\"", required = true)
// Collection<String> getRecipients();
// }
//
// Path: src/main/java/uk/gov/homeoffice/emailapi/templatedemailfactory/TemplatedEmailFactory.java
// public interface TemplatedEmailFactory {
// Email build(TemplatedEmail templatedEmail)
// throws EmailException, TemplatePopulatorParsingException, TemplatePopulatorIOException,
// InternetAddressParsingException;
// }
//
// Path: src/main/java/uk/gov/homeoffice/emailapi/templatedemailfactory/addressparsing/InternetAddressParsingException.java
// public class InternetAddressParsingException extends Exception {
// public InternetAddressParsingException(final Throwable cause) {
// super(cause);
// }
// }
//
// Path: src/main/java/uk/gov/homeoffice/emailapi/templatedemailfactory/templating/TemplatePopulatorIOException.java
// public class TemplatePopulatorIOException extends Exception {
// public TemplatePopulatorIOException(final Throwable cause) {
// super(cause);
// }
// }
//
// Path: src/main/java/uk/gov/homeoffice/emailapi/templatedemailfactory/templating/TemplatePopulatorParsingException.java
// public class TemplatePopulatorParsingException extends Exception {
// public TemplatePopulatorParsingException(Throwable cause) {
// super(cause);
// }
//
// public TemplatePopulatorParsingException(String message) {
// super(message);
// }
// }
| import org.apache.commons.mail.Email;
import org.apache.commons.mail.EmailException;
import org.junit.Test;
import uk.gov.homeoffice.emailapi.entities.TemplatedEmail;
import uk.gov.homeoffice.emailapi.templatedemailfactory.TemplatedEmailFactory;
import uk.gov.homeoffice.emailapi.templatedemailfactory.addressparsing.InternetAddressParsingException;
import uk.gov.homeoffice.emailapi.templatedemailfactory.templating.TemplatePopulatorIOException;
import uk.gov.homeoffice.emailapi.templatedemailfactory.templating.TemplatePopulatorParsingException;
import static org.mockito.Mockito.*; | package uk.gov.homeoffice.emailapi.service;
public class TemplatedEmailSenderImplTest {
@Test
public void itGetsATemplatedEmailAndSendsIt()
throws TemplatePopulatorParsingException, InternetAddressParsingException,
TemplatePopulatorIOException, EmailException {
final TemplatedEmail mockTemplatedEmail = mock(TemplatedEmail.class);
final Email mockEmail = mock(Email.class); | // Path: src/main/java/uk/gov/homeoffice/emailapi/entities/TemplatedEmail.java
// @ApiModel(description = "Enough information to populate and send and email based on a template")
// @JsonDeserialize(as = TemplatedEmailImpl.class)
// @JsonSerialize(as = TemplatedEmailImpl.class)
// public interface TemplatedEmail {
// @ApiModelProperty(value = "Sender of the email in format \"example@example.org\" or \"Annie Example <annie@example.com>\"", required = true)
// String getSender();
//
// @ApiModelProperty(value = "Subject of the email", required = true)
// String getSubject();
//
// @ApiModelProperty(value = "If a recipient uses HTML to view their they will see this template", required = true)
// String getHtmlTemplate();
//
// @ApiModelProperty(value = "If a recipient uses TXT to view their they will see this template", required = true)
// String getTextTemplate();
//
// @ApiModelProperty(value = "Variables to pass to both templates with string keys, and any JSON Number, String, Array, Object as the value ", required = true)
// Map<String, Object> getVariables();
//
// @ApiModelProperty(value = "Array of recipients in an array of strings in format \"example@example.org\" or \"Annie Example <annie@example.com>\"", required = true)
// Collection<String> getRecipients();
// }
//
// Path: src/main/java/uk/gov/homeoffice/emailapi/templatedemailfactory/TemplatedEmailFactory.java
// public interface TemplatedEmailFactory {
// Email build(TemplatedEmail templatedEmail)
// throws EmailException, TemplatePopulatorParsingException, TemplatePopulatorIOException,
// InternetAddressParsingException;
// }
//
// Path: src/main/java/uk/gov/homeoffice/emailapi/templatedemailfactory/addressparsing/InternetAddressParsingException.java
// public class InternetAddressParsingException extends Exception {
// public InternetAddressParsingException(final Throwable cause) {
// super(cause);
// }
// }
//
// Path: src/main/java/uk/gov/homeoffice/emailapi/templatedemailfactory/templating/TemplatePopulatorIOException.java
// public class TemplatePopulatorIOException extends Exception {
// public TemplatePopulatorIOException(final Throwable cause) {
// super(cause);
// }
// }
//
// Path: src/main/java/uk/gov/homeoffice/emailapi/templatedemailfactory/templating/TemplatePopulatorParsingException.java
// public class TemplatePopulatorParsingException extends Exception {
// public TemplatePopulatorParsingException(Throwable cause) {
// super(cause);
// }
//
// public TemplatePopulatorParsingException(String message) {
// super(message);
// }
// }
// Path: src/test/java/uk/gov/homeoffice/emailapi/service/TemplatedEmailSenderImplTest.java
import org.apache.commons.mail.Email;
import org.apache.commons.mail.EmailException;
import org.junit.Test;
import uk.gov.homeoffice.emailapi.entities.TemplatedEmail;
import uk.gov.homeoffice.emailapi.templatedemailfactory.TemplatedEmailFactory;
import uk.gov.homeoffice.emailapi.templatedemailfactory.addressparsing.InternetAddressParsingException;
import uk.gov.homeoffice.emailapi.templatedemailfactory.templating.TemplatePopulatorIOException;
import uk.gov.homeoffice.emailapi.templatedemailfactory.templating.TemplatePopulatorParsingException;
import static org.mockito.Mockito.*;
package uk.gov.homeoffice.emailapi.service;
public class TemplatedEmailSenderImplTest {
@Test
public void itGetsATemplatedEmailAndSendsIt()
throws TemplatePopulatorParsingException, InternetAddressParsingException,
TemplatePopulatorIOException, EmailException {
final TemplatedEmail mockTemplatedEmail = mock(TemplatedEmail.class);
final Email mockEmail = mock(Email.class); | final TemplatedEmailFactory mockFactory = mock(TemplatedEmailFactory.class); |
UKHomeOffice/email-api | src/main/java/uk/gov/homeoffice/emailapi/resources/TemplatePopulatorIOExceptionMapper.java | // Path: src/main/java/uk/gov/homeoffice/emailapi/entities/EmailApiStatus.java
// public enum EmailApiStatus implements StatusType {
// InvalidEmail(422, "Invalid recipient email"),
// TemplateUnreadable(422, "Template does not exist"),
// TemplateInvalid(422, "Template Invalid"),
// SendingEmailFailed(Status.INTERNAL_SERVER_ERROR.getStatusCode(),
// "Failed sending email to SMTP server.");
//
// private final Status.Family family;
//
// private final String reason;
//
// private final int code;
//
// EmailApiStatus(final int statusCode, final String reasonPhrase) {
// this.code = statusCode;
// this.reason = reasonPhrase;
// this.family = Status.Family.familyOf(statusCode);
// }
//
// @JsonValue
// public Map<String, List<String>> toEntity() {
//
// final Map<String, List<String>> map = new HashMap<>();
// List<String> errors = new ArrayList<>();
// errors.add(reason);
// map.put("errors", errors);
//
// return map;
// }
//
// @Override
// public int getStatusCode() {
// return code;
// }
//
// @Override
// public Status.Family getFamily() {
// return family;
// }
//
// @Override
// public String getReasonPhrase() {
// return reason;
// }
// }
//
// Path: src/main/java/uk/gov/homeoffice/emailapi/templatedemailfactory/templating/TemplatePopulatorIOException.java
// public class TemplatePopulatorIOException extends Exception {
// public TemplatePopulatorIOException(final Throwable cause) {
// super(cause);
// }
// }
| import org.slf4j.LoggerFactory;
import uk.gov.homeoffice.emailapi.entities.EmailApiStatus;
import uk.gov.homeoffice.emailapi.templatedemailfactory.templating.TemplatePopulatorIOException;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import javax.ws.rs.ext.ExceptionMapper;
import javax.ws.rs.ext.Provider; | package uk.gov.homeoffice.emailapi.resources;
@Provider
public class TemplatePopulatorIOExceptionMapper | // Path: src/main/java/uk/gov/homeoffice/emailapi/entities/EmailApiStatus.java
// public enum EmailApiStatus implements StatusType {
// InvalidEmail(422, "Invalid recipient email"),
// TemplateUnreadable(422, "Template does not exist"),
// TemplateInvalid(422, "Template Invalid"),
// SendingEmailFailed(Status.INTERNAL_SERVER_ERROR.getStatusCode(),
// "Failed sending email to SMTP server.");
//
// private final Status.Family family;
//
// private final String reason;
//
// private final int code;
//
// EmailApiStatus(final int statusCode, final String reasonPhrase) {
// this.code = statusCode;
// this.reason = reasonPhrase;
// this.family = Status.Family.familyOf(statusCode);
// }
//
// @JsonValue
// public Map<String, List<String>> toEntity() {
//
// final Map<String, List<String>> map = new HashMap<>();
// List<String> errors = new ArrayList<>();
// errors.add(reason);
// map.put("errors", errors);
//
// return map;
// }
//
// @Override
// public int getStatusCode() {
// return code;
// }
//
// @Override
// public Status.Family getFamily() {
// return family;
// }
//
// @Override
// public String getReasonPhrase() {
// return reason;
// }
// }
//
// Path: src/main/java/uk/gov/homeoffice/emailapi/templatedemailfactory/templating/TemplatePopulatorIOException.java
// public class TemplatePopulatorIOException extends Exception {
// public TemplatePopulatorIOException(final Throwable cause) {
// super(cause);
// }
// }
// Path: src/main/java/uk/gov/homeoffice/emailapi/resources/TemplatePopulatorIOExceptionMapper.java
import org.slf4j.LoggerFactory;
import uk.gov.homeoffice.emailapi.entities.EmailApiStatus;
import uk.gov.homeoffice.emailapi.templatedemailfactory.templating.TemplatePopulatorIOException;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import javax.ws.rs.ext.ExceptionMapper;
import javax.ws.rs.ext.Provider;
package uk.gov.homeoffice.emailapi.resources;
@Provider
public class TemplatePopulatorIOExceptionMapper | implements ExceptionMapper<TemplatePopulatorIOException> { |
UKHomeOffice/email-api | src/main/java/uk/gov/homeoffice/emailapi/resources/TemplatePopulatorIOExceptionMapper.java | // Path: src/main/java/uk/gov/homeoffice/emailapi/entities/EmailApiStatus.java
// public enum EmailApiStatus implements StatusType {
// InvalidEmail(422, "Invalid recipient email"),
// TemplateUnreadable(422, "Template does not exist"),
// TemplateInvalid(422, "Template Invalid"),
// SendingEmailFailed(Status.INTERNAL_SERVER_ERROR.getStatusCode(),
// "Failed sending email to SMTP server.");
//
// private final Status.Family family;
//
// private final String reason;
//
// private final int code;
//
// EmailApiStatus(final int statusCode, final String reasonPhrase) {
// this.code = statusCode;
// this.reason = reasonPhrase;
// this.family = Status.Family.familyOf(statusCode);
// }
//
// @JsonValue
// public Map<String, List<String>> toEntity() {
//
// final Map<String, List<String>> map = new HashMap<>();
// List<String> errors = new ArrayList<>();
// errors.add(reason);
// map.put("errors", errors);
//
// return map;
// }
//
// @Override
// public int getStatusCode() {
// return code;
// }
//
// @Override
// public Status.Family getFamily() {
// return family;
// }
//
// @Override
// public String getReasonPhrase() {
// return reason;
// }
// }
//
// Path: src/main/java/uk/gov/homeoffice/emailapi/templatedemailfactory/templating/TemplatePopulatorIOException.java
// public class TemplatePopulatorIOException extends Exception {
// public TemplatePopulatorIOException(final Throwable cause) {
// super(cause);
// }
// }
| import org.slf4j.LoggerFactory;
import uk.gov.homeoffice.emailapi.entities.EmailApiStatus;
import uk.gov.homeoffice.emailapi.templatedemailfactory.templating.TemplatePopulatorIOException;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import javax.ws.rs.ext.ExceptionMapper;
import javax.ws.rs.ext.Provider; | package uk.gov.homeoffice.emailapi.resources;
@Provider
public class TemplatePopulatorIOExceptionMapper
implements ExceptionMapper<TemplatePopulatorIOException> {
private static final org.slf4j.Logger LOGGER =
LoggerFactory.getLogger(TemplatePopulatorIOException.class);
@Override
public Response toResponse(TemplatePopulatorIOException exception) {
LOGGER.warn("Attempting to load non-existent template", exception);
| // Path: src/main/java/uk/gov/homeoffice/emailapi/entities/EmailApiStatus.java
// public enum EmailApiStatus implements StatusType {
// InvalidEmail(422, "Invalid recipient email"),
// TemplateUnreadable(422, "Template does not exist"),
// TemplateInvalid(422, "Template Invalid"),
// SendingEmailFailed(Status.INTERNAL_SERVER_ERROR.getStatusCode(),
// "Failed sending email to SMTP server.");
//
// private final Status.Family family;
//
// private final String reason;
//
// private final int code;
//
// EmailApiStatus(final int statusCode, final String reasonPhrase) {
// this.code = statusCode;
// this.reason = reasonPhrase;
// this.family = Status.Family.familyOf(statusCode);
// }
//
// @JsonValue
// public Map<String, List<String>> toEntity() {
//
// final Map<String, List<String>> map = new HashMap<>();
// List<String> errors = new ArrayList<>();
// errors.add(reason);
// map.put("errors", errors);
//
// return map;
// }
//
// @Override
// public int getStatusCode() {
// return code;
// }
//
// @Override
// public Status.Family getFamily() {
// return family;
// }
//
// @Override
// public String getReasonPhrase() {
// return reason;
// }
// }
//
// Path: src/main/java/uk/gov/homeoffice/emailapi/templatedemailfactory/templating/TemplatePopulatorIOException.java
// public class TemplatePopulatorIOException extends Exception {
// public TemplatePopulatorIOException(final Throwable cause) {
// super(cause);
// }
// }
// Path: src/main/java/uk/gov/homeoffice/emailapi/resources/TemplatePopulatorIOExceptionMapper.java
import org.slf4j.LoggerFactory;
import uk.gov.homeoffice.emailapi.entities.EmailApiStatus;
import uk.gov.homeoffice.emailapi.templatedemailfactory.templating.TemplatePopulatorIOException;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import javax.ws.rs.ext.ExceptionMapper;
import javax.ws.rs.ext.Provider;
package uk.gov.homeoffice.emailapi.resources;
@Provider
public class TemplatePopulatorIOExceptionMapper
implements ExceptionMapper<TemplatePopulatorIOException> {
private static final org.slf4j.Logger LOGGER =
LoggerFactory.getLogger(TemplatePopulatorIOException.class);
@Override
public Response toResponse(TemplatePopulatorIOException exception) {
LOGGER.warn("Attempting to load non-existent template", exception);
| return Response.status(EmailApiStatus.TemplateUnreadable) |
UKHomeOffice/email-api | src/main/java/uk/gov/homeoffice/emailapi/resources/EmailExceptionMapper.java | // Path: src/main/java/uk/gov/homeoffice/emailapi/entities/EmailApiStatus.java
// public enum EmailApiStatus implements StatusType {
// InvalidEmail(422, "Invalid recipient email"),
// TemplateUnreadable(422, "Template does not exist"),
// TemplateInvalid(422, "Template Invalid"),
// SendingEmailFailed(Status.INTERNAL_SERVER_ERROR.getStatusCode(),
// "Failed sending email to SMTP server.");
//
// private final Status.Family family;
//
// private final String reason;
//
// private final int code;
//
// EmailApiStatus(final int statusCode, final String reasonPhrase) {
// this.code = statusCode;
// this.reason = reasonPhrase;
// this.family = Status.Family.familyOf(statusCode);
// }
//
// @JsonValue
// public Map<String, List<String>> toEntity() {
//
// final Map<String, List<String>> map = new HashMap<>();
// List<String> errors = new ArrayList<>();
// errors.add(reason);
// map.put("errors", errors);
//
// return map;
// }
//
// @Override
// public int getStatusCode() {
// return code;
// }
//
// @Override
// public Status.Family getFamily() {
// return family;
// }
//
// @Override
// public String getReasonPhrase() {
// return reason;
// }
// }
| import org.apache.commons.mail.EmailException;
import org.slf4j.LoggerFactory;
import uk.gov.homeoffice.emailapi.entities.EmailApiStatus;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import javax.ws.rs.ext.ExceptionMapper;
import javax.ws.rs.ext.Provider; | package uk.gov.homeoffice.emailapi.resources;
@Provider
public class EmailExceptionMapper implements ExceptionMapper<EmailException> {
private static final org.slf4j.Logger LOGGER =
LoggerFactory.getLogger(EmailExceptionMapper.class);
@Override
public Response toResponse(EmailException exception) {
LOGGER.error("Failed to connect to SMTP server", exception);
| // Path: src/main/java/uk/gov/homeoffice/emailapi/entities/EmailApiStatus.java
// public enum EmailApiStatus implements StatusType {
// InvalidEmail(422, "Invalid recipient email"),
// TemplateUnreadable(422, "Template does not exist"),
// TemplateInvalid(422, "Template Invalid"),
// SendingEmailFailed(Status.INTERNAL_SERVER_ERROR.getStatusCode(),
// "Failed sending email to SMTP server.");
//
// private final Status.Family family;
//
// private final String reason;
//
// private final int code;
//
// EmailApiStatus(final int statusCode, final String reasonPhrase) {
// this.code = statusCode;
// this.reason = reasonPhrase;
// this.family = Status.Family.familyOf(statusCode);
// }
//
// @JsonValue
// public Map<String, List<String>> toEntity() {
//
// final Map<String, List<String>> map = new HashMap<>();
// List<String> errors = new ArrayList<>();
// errors.add(reason);
// map.put("errors", errors);
//
// return map;
// }
//
// @Override
// public int getStatusCode() {
// return code;
// }
//
// @Override
// public Status.Family getFamily() {
// return family;
// }
//
// @Override
// public String getReasonPhrase() {
// return reason;
// }
// }
// Path: src/main/java/uk/gov/homeoffice/emailapi/resources/EmailExceptionMapper.java
import org.apache.commons.mail.EmailException;
import org.slf4j.LoggerFactory;
import uk.gov.homeoffice.emailapi.entities.EmailApiStatus;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import javax.ws.rs.ext.ExceptionMapper;
import javax.ws.rs.ext.Provider;
package uk.gov.homeoffice.emailapi.resources;
@Provider
public class EmailExceptionMapper implements ExceptionMapper<EmailException> {
private static final org.slf4j.Logger LOGGER =
LoggerFactory.getLogger(EmailExceptionMapper.class);
@Override
public Response toResponse(EmailException exception) {
LOGGER.error("Failed to connect to SMTP server", exception);
| return Response.status(EmailApiStatus.SendingEmailFailed) |
UKHomeOffice/email-api | src/main/java/uk/gov/homeoffice/emailapi/resources/InternetAddressParsingExceptionMapper.java | // Path: src/main/java/uk/gov/homeoffice/emailapi/entities/EmailApiStatus.java
// public enum EmailApiStatus implements StatusType {
// InvalidEmail(422, "Invalid recipient email"),
// TemplateUnreadable(422, "Template does not exist"),
// TemplateInvalid(422, "Template Invalid"),
// SendingEmailFailed(Status.INTERNAL_SERVER_ERROR.getStatusCode(),
// "Failed sending email to SMTP server.");
//
// private final Status.Family family;
//
// private final String reason;
//
// private final int code;
//
// EmailApiStatus(final int statusCode, final String reasonPhrase) {
// this.code = statusCode;
// this.reason = reasonPhrase;
// this.family = Status.Family.familyOf(statusCode);
// }
//
// @JsonValue
// public Map<String, List<String>> toEntity() {
//
// final Map<String, List<String>> map = new HashMap<>();
// List<String> errors = new ArrayList<>();
// errors.add(reason);
// map.put("errors", errors);
//
// return map;
// }
//
// @Override
// public int getStatusCode() {
// return code;
// }
//
// @Override
// public Status.Family getFamily() {
// return family;
// }
//
// @Override
// public String getReasonPhrase() {
// return reason;
// }
// }
//
// Path: src/main/java/uk/gov/homeoffice/emailapi/templatedemailfactory/addressparsing/InternetAddressParsingException.java
// public class InternetAddressParsingException extends Exception {
// public InternetAddressParsingException(final Throwable cause) {
// super(cause);
// }
// }
| import org.slf4j.LoggerFactory;
import uk.gov.homeoffice.emailapi.entities.EmailApiStatus;
import uk.gov.homeoffice.emailapi.templatedemailfactory.addressparsing.InternetAddressParsingException;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import javax.ws.rs.ext.ExceptionMapper;
import javax.ws.rs.ext.Provider; | package uk.gov.homeoffice.emailapi.resources;
@Provider
public class InternetAddressParsingExceptionMapper | // Path: src/main/java/uk/gov/homeoffice/emailapi/entities/EmailApiStatus.java
// public enum EmailApiStatus implements StatusType {
// InvalidEmail(422, "Invalid recipient email"),
// TemplateUnreadable(422, "Template does not exist"),
// TemplateInvalid(422, "Template Invalid"),
// SendingEmailFailed(Status.INTERNAL_SERVER_ERROR.getStatusCode(),
// "Failed sending email to SMTP server.");
//
// private final Status.Family family;
//
// private final String reason;
//
// private final int code;
//
// EmailApiStatus(final int statusCode, final String reasonPhrase) {
// this.code = statusCode;
// this.reason = reasonPhrase;
// this.family = Status.Family.familyOf(statusCode);
// }
//
// @JsonValue
// public Map<String, List<String>> toEntity() {
//
// final Map<String, List<String>> map = new HashMap<>();
// List<String> errors = new ArrayList<>();
// errors.add(reason);
// map.put("errors", errors);
//
// return map;
// }
//
// @Override
// public int getStatusCode() {
// return code;
// }
//
// @Override
// public Status.Family getFamily() {
// return family;
// }
//
// @Override
// public String getReasonPhrase() {
// return reason;
// }
// }
//
// Path: src/main/java/uk/gov/homeoffice/emailapi/templatedemailfactory/addressparsing/InternetAddressParsingException.java
// public class InternetAddressParsingException extends Exception {
// public InternetAddressParsingException(final Throwable cause) {
// super(cause);
// }
// }
// Path: src/main/java/uk/gov/homeoffice/emailapi/resources/InternetAddressParsingExceptionMapper.java
import org.slf4j.LoggerFactory;
import uk.gov.homeoffice.emailapi.entities.EmailApiStatus;
import uk.gov.homeoffice.emailapi.templatedemailfactory.addressparsing.InternetAddressParsingException;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import javax.ws.rs.ext.ExceptionMapper;
import javax.ws.rs.ext.Provider;
package uk.gov.homeoffice.emailapi.resources;
@Provider
public class InternetAddressParsingExceptionMapper | implements ExceptionMapper<InternetAddressParsingException> { |
UKHomeOffice/email-api | src/main/java/uk/gov/homeoffice/emailapi/resources/InternetAddressParsingExceptionMapper.java | // Path: src/main/java/uk/gov/homeoffice/emailapi/entities/EmailApiStatus.java
// public enum EmailApiStatus implements StatusType {
// InvalidEmail(422, "Invalid recipient email"),
// TemplateUnreadable(422, "Template does not exist"),
// TemplateInvalid(422, "Template Invalid"),
// SendingEmailFailed(Status.INTERNAL_SERVER_ERROR.getStatusCode(),
// "Failed sending email to SMTP server.");
//
// private final Status.Family family;
//
// private final String reason;
//
// private final int code;
//
// EmailApiStatus(final int statusCode, final String reasonPhrase) {
// this.code = statusCode;
// this.reason = reasonPhrase;
// this.family = Status.Family.familyOf(statusCode);
// }
//
// @JsonValue
// public Map<String, List<String>> toEntity() {
//
// final Map<String, List<String>> map = new HashMap<>();
// List<String> errors = new ArrayList<>();
// errors.add(reason);
// map.put("errors", errors);
//
// return map;
// }
//
// @Override
// public int getStatusCode() {
// return code;
// }
//
// @Override
// public Status.Family getFamily() {
// return family;
// }
//
// @Override
// public String getReasonPhrase() {
// return reason;
// }
// }
//
// Path: src/main/java/uk/gov/homeoffice/emailapi/templatedemailfactory/addressparsing/InternetAddressParsingException.java
// public class InternetAddressParsingException extends Exception {
// public InternetAddressParsingException(final Throwable cause) {
// super(cause);
// }
// }
| import org.slf4j.LoggerFactory;
import uk.gov.homeoffice.emailapi.entities.EmailApiStatus;
import uk.gov.homeoffice.emailapi.templatedemailfactory.addressparsing.InternetAddressParsingException;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import javax.ws.rs.ext.ExceptionMapper;
import javax.ws.rs.ext.Provider; | package uk.gov.homeoffice.emailapi.resources;
@Provider
public class InternetAddressParsingExceptionMapper
implements ExceptionMapper<InternetAddressParsingException> {
private static final org.slf4j.Logger LOGGER =
LoggerFactory.getLogger(InternetAddressParsingExceptionMapper.class);
@Override
public Response toResponse(InternetAddressParsingException exception) {
LOGGER.warn("Invalid recipient email passed to API", exception);
| // Path: src/main/java/uk/gov/homeoffice/emailapi/entities/EmailApiStatus.java
// public enum EmailApiStatus implements StatusType {
// InvalidEmail(422, "Invalid recipient email"),
// TemplateUnreadable(422, "Template does not exist"),
// TemplateInvalid(422, "Template Invalid"),
// SendingEmailFailed(Status.INTERNAL_SERVER_ERROR.getStatusCode(),
// "Failed sending email to SMTP server.");
//
// private final Status.Family family;
//
// private final String reason;
//
// private final int code;
//
// EmailApiStatus(final int statusCode, final String reasonPhrase) {
// this.code = statusCode;
// this.reason = reasonPhrase;
// this.family = Status.Family.familyOf(statusCode);
// }
//
// @JsonValue
// public Map<String, List<String>> toEntity() {
//
// final Map<String, List<String>> map = new HashMap<>();
// List<String> errors = new ArrayList<>();
// errors.add(reason);
// map.put("errors", errors);
//
// return map;
// }
//
// @Override
// public int getStatusCode() {
// return code;
// }
//
// @Override
// public Status.Family getFamily() {
// return family;
// }
//
// @Override
// public String getReasonPhrase() {
// return reason;
// }
// }
//
// Path: src/main/java/uk/gov/homeoffice/emailapi/templatedemailfactory/addressparsing/InternetAddressParsingException.java
// public class InternetAddressParsingException extends Exception {
// public InternetAddressParsingException(final Throwable cause) {
// super(cause);
// }
// }
// Path: src/main/java/uk/gov/homeoffice/emailapi/resources/InternetAddressParsingExceptionMapper.java
import org.slf4j.LoggerFactory;
import uk.gov.homeoffice.emailapi.entities.EmailApiStatus;
import uk.gov.homeoffice.emailapi.templatedemailfactory.addressparsing.InternetAddressParsingException;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import javax.ws.rs.ext.ExceptionMapper;
import javax.ws.rs.ext.Provider;
package uk.gov.homeoffice.emailapi.resources;
@Provider
public class InternetAddressParsingExceptionMapper
implements ExceptionMapper<InternetAddressParsingException> {
private static final org.slf4j.Logger LOGGER =
LoggerFactory.getLogger(InternetAddressParsingExceptionMapper.class);
@Override
public Response toResponse(InternetAddressParsingException exception) {
LOGGER.warn("Invalid recipient email passed to API", exception);
| return Response.status(EmailApiStatus.InvalidEmail).encoding(MediaType.APPLICATION_JSON) |
UKHomeOffice/email-api | src/main/java/uk/gov/homeoffice/emailapi/service/TemplatedEmailSender.java | // Path: src/main/java/uk/gov/homeoffice/emailapi/entities/TemplatedEmail.java
// @ApiModel(description = "Enough information to populate and send and email based on a template")
// @JsonDeserialize(as = TemplatedEmailImpl.class)
// @JsonSerialize(as = TemplatedEmailImpl.class)
// public interface TemplatedEmail {
// @ApiModelProperty(value = "Sender of the email in format \"example@example.org\" or \"Annie Example <annie@example.com>\"", required = true)
// String getSender();
//
// @ApiModelProperty(value = "Subject of the email", required = true)
// String getSubject();
//
// @ApiModelProperty(value = "If a recipient uses HTML to view their they will see this template", required = true)
// String getHtmlTemplate();
//
// @ApiModelProperty(value = "If a recipient uses TXT to view their they will see this template", required = true)
// String getTextTemplate();
//
// @ApiModelProperty(value = "Variables to pass to both templates with string keys, and any JSON Number, String, Array, Object as the value ", required = true)
// Map<String, Object> getVariables();
//
// @ApiModelProperty(value = "Array of recipients in an array of strings in format \"example@example.org\" or \"Annie Example <annie@example.com>\"", required = true)
// Collection<String> getRecipients();
// }
//
// Path: src/main/java/uk/gov/homeoffice/emailapi/templatedemailfactory/addressparsing/InternetAddressParsingException.java
// public class InternetAddressParsingException extends Exception {
// public InternetAddressParsingException(final Throwable cause) {
// super(cause);
// }
// }
//
// Path: src/main/java/uk/gov/homeoffice/emailapi/templatedemailfactory/templating/TemplatePopulatorIOException.java
// public class TemplatePopulatorIOException extends Exception {
// public TemplatePopulatorIOException(final Throwable cause) {
// super(cause);
// }
// }
//
// Path: src/main/java/uk/gov/homeoffice/emailapi/templatedemailfactory/templating/TemplatePopulatorParsingException.java
// public class TemplatePopulatorParsingException extends Exception {
// public TemplatePopulatorParsingException(Throwable cause) {
// super(cause);
// }
//
// public TemplatePopulatorParsingException(String message) {
// super(message);
// }
// }
| import org.apache.commons.mail.EmailException;
import uk.gov.homeoffice.emailapi.entities.TemplatedEmail;
import uk.gov.homeoffice.emailapi.templatedemailfactory.addressparsing.InternetAddressParsingException;
import uk.gov.homeoffice.emailapi.templatedemailfactory.templating.TemplatePopulatorIOException;
import uk.gov.homeoffice.emailapi.templatedemailfactory.templating.TemplatePopulatorParsingException; | package uk.gov.homeoffice.emailapi.service;
public interface TemplatedEmailSender {
void sendEmail(TemplatedEmail templatedEmail) | // Path: src/main/java/uk/gov/homeoffice/emailapi/entities/TemplatedEmail.java
// @ApiModel(description = "Enough information to populate and send and email based on a template")
// @JsonDeserialize(as = TemplatedEmailImpl.class)
// @JsonSerialize(as = TemplatedEmailImpl.class)
// public interface TemplatedEmail {
// @ApiModelProperty(value = "Sender of the email in format \"example@example.org\" or \"Annie Example <annie@example.com>\"", required = true)
// String getSender();
//
// @ApiModelProperty(value = "Subject of the email", required = true)
// String getSubject();
//
// @ApiModelProperty(value = "If a recipient uses HTML to view their they will see this template", required = true)
// String getHtmlTemplate();
//
// @ApiModelProperty(value = "If a recipient uses TXT to view their they will see this template", required = true)
// String getTextTemplate();
//
// @ApiModelProperty(value = "Variables to pass to both templates with string keys, and any JSON Number, String, Array, Object as the value ", required = true)
// Map<String, Object> getVariables();
//
// @ApiModelProperty(value = "Array of recipients in an array of strings in format \"example@example.org\" or \"Annie Example <annie@example.com>\"", required = true)
// Collection<String> getRecipients();
// }
//
// Path: src/main/java/uk/gov/homeoffice/emailapi/templatedemailfactory/addressparsing/InternetAddressParsingException.java
// public class InternetAddressParsingException extends Exception {
// public InternetAddressParsingException(final Throwable cause) {
// super(cause);
// }
// }
//
// Path: src/main/java/uk/gov/homeoffice/emailapi/templatedemailfactory/templating/TemplatePopulatorIOException.java
// public class TemplatePopulatorIOException extends Exception {
// public TemplatePopulatorIOException(final Throwable cause) {
// super(cause);
// }
// }
//
// Path: src/main/java/uk/gov/homeoffice/emailapi/templatedemailfactory/templating/TemplatePopulatorParsingException.java
// public class TemplatePopulatorParsingException extends Exception {
// public TemplatePopulatorParsingException(Throwable cause) {
// super(cause);
// }
//
// public TemplatePopulatorParsingException(String message) {
// super(message);
// }
// }
// Path: src/main/java/uk/gov/homeoffice/emailapi/service/TemplatedEmailSender.java
import org.apache.commons.mail.EmailException;
import uk.gov.homeoffice.emailapi.entities.TemplatedEmail;
import uk.gov.homeoffice.emailapi.templatedemailfactory.addressparsing.InternetAddressParsingException;
import uk.gov.homeoffice.emailapi.templatedemailfactory.templating.TemplatePopulatorIOException;
import uk.gov.homeoffice.emailapi.templatedemailfactory.templating.TemplatePopulatorParsingException;
package uk.gov.homeoffice.emailapi.service;
public interface TemplatedEmailSender {
void sendEmail(TemplatedEmail templatedEmail) | throws EmailException, TemplatePopulatorParsingException, TemplatePopulatorIOException, |
UKHomeOffice/email-api | src/main/java/uk/gov/homeoffice/emailapi/service/TemplatedEmailSender.java | // Path: src/main/java/uk/gov/homeoffice/emailapi/entities/TemplatedEmail.java
// @ApiModel(description = "Enough information to populate and send and email based on a template")
// @JsonDeserialize(as = TemplatedEmailImpl.class)
// @JsonSerialize(as = TemplatedEmailImpl.class)
// public interface TemplatedEmail {
// @ApiModelProperty(value = "Sender of the email in format \"example@example.org\" or \"Annie Example <annie@example.com>\"", required = true)
// String getSender();
//
// @ApiModelProperty(value = "Subject of the email", required = true)
// String getSubject();
//
// @ApiModelProperty(value = "If a recipient uses HTML to view their they will see this template", required = true)
// String getHtmlTemplate();
//
// @ApiModelProperty(value = "If a recipient uses TXT to view their they will see this template", required = true)
// String getTextTemplate();
//
// @ApiModelProperty(value = "Variables to pass to both templates with string keys, and any JSON Number, String, Array, Object as the value ", required = true)
// Map<String, Object> getVariables();
//
// @ApiModelProperty(value = "Array of recipients in an array of strings in format \"example@example.org\" or \"Annie Example <annie@example.com>\"", required = true)
// Collection<String> getRecipients();
// }
//
// Path: src/main/java/uk/gov/homeoffice/emailapi/templatedemailfactory/addressparsing/InternetAddressParsingException.java
// public class InternetAddressParsingException extends Exception {
// public InternetAddressParsingException(final Throwable cause) {
// super(cause);
// }
// }
//
// Path: src/main/java/uk/gov/homeoffice/emailapi/templatedemailfactory/templating/TemplatePopulatorIOException.java
// public class TemplatePopulatorIOException extends Exception {
// public TemplatePopulatorIOException(final Throwable cause) {
// super(cause);
// }
// }
//
// Path: src/main/java/uk/gov/homeoffice/emailapi/templatedemailfactory/templating/TemplatePopulatorParsingException.java
// public class TemplatePopulatorParsingException extends Exception {
// public TemplatePopulatorParsingException(Throwable cause) {
// super(cause);
// }
//
// public TemplatePopulatorParsingException(String message) {
// super(message);
// }
// }
| import org.apache.commons.mail.EmailException;
import uk.gov.homeoffice.emailapi.entities.TemplatedEmail;
import uk.gov.homeoffice.emailapi.templatedemailfactory.addressparsing.InternetAddressParsingException;
import uk.gov.homeoffice.emailapi.templatedemailfactory.templating.TemplatePopulatorIOException;
import uk.gov.homeoffice.emailapi.templatedemailfactory.templating.TemplatePopulatorParsingException; | package uk.gov.homeoffice.emailapi.service;
public interface TemplatedEmailSender {
void sendEmail(TemplatedEmail templatedEmail) | // Path: src/main/java/uk/gov/homeoffice/emailapi/entities/TemplatedEmail.java
// @ApiModel(description = "Enough information to populate and send and email based on a template")
// @JsonDeserialize(as = TemplatedEmailImpl.class)
// @JsonSerialize(as = TemplatedEmailImpl.class)
// public interface TemplatedEmail {
// @ApiModelProperty(value = "Sender of the email in format \"example@example.org\" or \"Annie Example <annie@example.com>\"", required = true)
// String getSender();
//
// @ApiModelProperty(value = "Subject of the email", required = true)
// String getSubject();
//
// @ApiModelProperty(value = "If a recipient uses HTML to view their they will see this template", required = true)
// String getHtmlTemplate();
//
// @ApiModelProperty(value = "If a recipient uses TXT to view their they will see this template", required = true)
// String getTextTemplate();
//
// @ApiModelProperty(value = "Variables to pass to both templates with string keys, and any JSON Number, String, Array, Object as the value ", required = true)
// Map<String, Object> getVariables();
//
// @ApiModelProperty(value = "Array of recipients in an array of strings in format \"example@example.org\" or \"Annie Example <annie@example.com>\"", required = true)
// Collection<String> getRecipients();
// }
//
// Path: src/main/java/uk/gov/homeoffice/emailapi/templatedemailfactory/addressparsing/InternetAddressParsingException.java
// public class InternetAddressParsingException extends Exception {
// public InternetAddressParsingException(final Throwable cause) {
// super(cause);
// }
// }
//
// Path: src/main/java/uk/gov/homeoffice/emailapi/templatedemailfactory/templating/TemplatePopulatorIOException.java
// public class TemplatePopulatorIOException extends Exception {
// public TemplatePopulatorIOException(final Throwable cause) {
// super(cause);
// }
// }
//
// Path: src/main/java/uk/gov/homeoffice/emailapi/templatedemailfactory/templating/TemplatePopulatorParsingException.java
// public class TemplatePopulatorParsingException extends Exception {
// public TemplatePopulatorParsingException(Throwable cause) {
// super(cause);
// }
//
// public TemplatePopulatorParsingException(String message) {
// super(message);
// }
// }
// Path: src/main/java/uk/gov/homeoffice/emailapi/service/TemplatedEmailSender.java
import org.apache.commons.mail.EmailException;
import uk.gov.homeoffice.emailapi.entities.TemplatedEmail;
import uk.gov.homeoffice.emailapi.templatedemailfactory.addressparsing.InternetAddressParsingException;
import uk.gov.homeoffice.emailapi.templatedemailfactory.templating.TemplatePopulatorIOException;
import uk.gov.homeoffice.emailapi.templatedemailfactory.templating.TemplatePopulatorParsingException;
package uk.gov.homeoffice.emailapi.service;
public interface TemplatedEmailSender {
void sendEmail(TemplatedEmail templatedEmail) | throws EmailException, TemplatePopulatorParsingException, TemplatePopulatorIOException, |
UKHomeOffice/email-api | src/main/java/uk/gov/homeoffice/emailapi/service/TemplatedEmailSender.java | // Path: src/main/java/uk/gov/homeoffice/emailapi/entities/TemplatedEmail.java
// @ApiModel(description = "Enough information to populate and send and email based on a template")
// @JsonDeserialize(as = TemplatedEmailImpl.class)
// @JsonSerialize(as = TemplatedEmailImpl.class)
// public interface TemplatedEmail {
// @ApiModelProperty(value = "Sender of the email in format \"example@example.org\" or \"Annie Example <annie@example.com>\"", required = true)
// String getSender();
//
// @ApiModelProperty(value = "Subject of the email", required = true)
// String getSubject();
//
// @ApiModelProperty(value = "If a recipient uses HTML to view their they will see this template", required = true)
// String getHtmlTemplate();
//
// @ApiModelProperty(value = "If a recipient uses TXT to view their they will see this template", required = true)
// String getTextTemplate();
//
// @ApiModelProperty(value = "Variables to pass to both templates with string keys, and any JSON Number, String, Array, Object as the value ", required = true)
// Map<String, Object> getVariables();
//
// @ApiModelProperty(value = "Array of recipients in an array of strings in format \"example@example.org\" or \"Annie Example <annie@example.com>\"", required = true)
// Collection<String> getRecipients();
// }
//
// Path: src/main/java/uk/gov/homeoffice/emailapi/templatedemailfactory/addressparsing/InternetAddressParsingException.java
// public class InternetAddressParsingException extends Exception {
// public InternetAddressParsingException(final Throwable cause) {
// super(cause);
// }
// }
//
// Path: src/main/java/uk/gov/homeoffice/emailapi/templatedemailfactory/templating/TemplatePopulatorIOException.java
// public class TemplatePopulatorIOException extends Exception {
// public TemplatePopulatorIOException(final Throwable cause) {
// super(cause);
// }
// }
//
// Path: src/main/java/uk/gov/homeoffice/emailapi/templatedemailfactory/templating/TemplatePopulatorParsingException.java
// public class TemplatePopulatorParsingException extends Exception {
// public TemplatePopulatorParsingException(Throwable cause) {
// super(cause);
// }
//
// public TemplatePopulatorParsingException(String message) {
// super(message);
// }
// }
| import org.apache.commons.mail.EmailException;
import uk.gov.homeoffice.emailapi.entities.TemplatedEmail;
import uk.gov.homeoffice.emailapi.templatedemailfactory.addressparsing.InternetAddressParsingException;
import uk.gov.homeoffice.emailapi.templatedemailfactory.templating.TemplatePopulatorIOException;
import uk.gov.homeoffice.emailapi.templatedemailfactory.templating.TemplatePopulatorParsingException; | package uk.gov.homeoffice.emailapi.service;
public interface TemplatedEmailSender {
void sendEmail(TemplatedEmail templatedEmail)
throws EmailException, TemplatePopulatorParsingException, TemplatePopulatorIOException, | // Path: src/main/java/uk/gov/homeoffice/emailapi/entities/TemplatedEmail.java
// @ApiModel(description = "Enough information to populate and send and email based on a template")
// @JsonDeserialize(as = TemplatedEmailImpl.class)
// @JsonSerialize(as = TemplatedEmailImpl.class)
// public interface TemplatedEmail {
// @ApiModelProperty(value = "Sender of the email in format \"example@example.org\" or \"Annie Example <annie@example.com>\"", required = true)
// String getSender();
//
// @ApiModelProperty(value = "Subject of the email", required = true)
// String getSubject();
//
// @ApiModelProperty(value = "If a recipient uses HTML to view their they will see this template", required = true)
// String getHtmlTemplate();
//
// @ApiModelProperty(value = "If a recipient uses TXT to view their they will see this template", required = true)
// String getTextTemplate();
//
// @ApiModelProperty(value = "Variables to pass to both templates with string keys, and any JSON Number, String, Array, Object as the value ", required = true)
// Map<String, Object> getVariables();
//
// @ApiModelProperty(value = "Array of recipients in an array of strings in format \"example@example.org\" or \"Annie Example <annie@example.com>\"", required = true)
// Collection<String> getRecipients();
// }
//
// Path: src/main/java/uk/gov/homeoffice/emailapi/templatedemailfactory/addressparsing/InternetAddressParsingException.java
// public class InternetAddressParsingException extends Exception {
// public InternetAddressParsingException(final Throwable cause) {
// super(cause);
// }
// }
//
// Path: src/main/java/uk/gov/homeoffice/emailapi/templatedemailfactory/templating/TemplatePopulatorIOException.java
// public class TemplatePopulatorIOException extends Exception {
// public TemplatePopulatorIOException(final Throwable cause) {
// super(cause);
// }
// }
//
// Path: src/main/java/uk/gov/homeoffice/emailapi/templatedemailfactory/templating/TemplatePopulatorParsingException.java
// public class TemplatePopulatorParsingException extends Exception {
// public TemplatePopulatorParsingException(Throwable cause) {
// super(cause);
// }
//
// public TemplatePopulatorParsingException(String message) {
// super(message);
// }
// }
// Path: src/main/java/uk/gov/homeoffice/emailapi/service/TemplatedEmailSender.java
import org.apache.commons.mail.EmailException;
import uk.gov.homeoffice.emailapi.entities.TemplatedEmail;
import uk.gov.homeoffice.emailapi.templatedemailfactory.addressparsing.InternetAddressParsingException;
import uk.gov.homeoffice.emailapi.templatedemailfactory.templating.TemplatePopulatorIOException;
import uk.gov.homeoffice.emailapi.templatedemailfactory.templating.TemplatePopulatorParsingException;
package uk.gov.homeoffice.emailapi.service;
public interface TemplatedEmailSender {
void sendEmail(TemplatedEmail templatedEmail)
throws EmailException, TemplatePopulatorParsingException, TemplatePopulatorIOException, | InternetAddressParsingException; |
hutou-workhouse/miscroServiceHello | springCloudHystrixFeign/src/main/java/me/helllp/demo/springCloudHystrixFeign/web/HelloController.java | // Path: springCloudHystrixFeign/src/main/java/me/helllp/demo/springCloudHystrixFeign/service/HystrixFeignService.java
// @FeignClient(value="EUREKACLIENT", fallback = HystrixFeignServiceFallback.class)
// public interface HystrixFeignService {
// @RequestMapping(value = "/hello",method = RequestMethod.GET)
// String sayHiUseFeign(@RequestParam(value = "name") String name);
// }
| import me.helllp.demo.springCloudHystrixFeign.service.HystrixFeignService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
| package me.helllp.demo.springCloudHystrixFeign.web;
@RestController
public class HelloController {
@Autowired
| // Path: springCloudHystrixFeign/src/main/java/me/helllp/demo/springCloudHystrixFeign/service/HystrixFeignService.java
// @FeignClient(value="EUREKACLIENT", fallback = HystrixFeignServiceFallback.class)
// public interface HystrixFeignService {
// @RequestMapping(value = "/hello",method = RequestMethod.GET)
// String sayHiUseFeign(@RequestParam(value = "name") String name);
// }
// Path: springCloudHystrixFeign/src/main/java/me/helllp/demo/springCloudHystrixFeign/web/HelloController.java
import me.helllp.demo.springCloudHystrixFeign.service.HystrixFeignService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
package me.helllp.demo.springCloudHystrixFeign.web;
@RestController
public class HelloController {
@Autowired
| HystrixFeignService helloService;
|
hutou-workhouse/miscroServiceHello | springbootDemo2/src/main/java/me/helllp/demo/springbootDemo2/Config.java | // Path: springbootDemo2/src/main/java/me/helllp/demo/test/MyCondition.java
// public class MyCondition implements Condition{
// /**
// * 如果是windows系统,返回true;否则返回false
// */
// public boolean matches(ConditionContext context, AnnotatedTypeMetadata metadata){
// return context.getEnvironment().getProperty("os.name").contains("Windows");
// }
// }
| import me.helllp.demo.test.MyCondition;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Conditional;
import org.springframework.context.annotation.Configuration;
| package me.helllp.demo.springbootDemo2;
@Configuration
public class Config
{
/**
* 如果MyCondition中match返回ture则可以注入Bean;否则不能注入
*
* @return
*/
@Bean
| // Path: springbootDemo2/src/main/java/me/helllp/demo/test/MyCondition.java
// public class MyCondition implements Condition{
// /**
// * 如果是windows系统,返回true;否则返回false
// */
// public boolean matches(ConditionContext context, AnnotatedTypeMetadata metadata){
// return context.getEnvironment().getProperty("os.name").contains("Windows");
// }
// }
// Path: springbootDemo2/src/main/java/me/helllp/demo/springbootDemo2/Config.java
import me.helllp.demo.test.MyCondition;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Conditional;
import org.springframework.context.annotation.Configuration;
package me.helllp.demo.springbootDemo2;
@Configuration
public class Config
{
/**
* 如果MyCondition中match返回ture则可以注入Bean;否则不能注入
*
* @return
*/
@Bean
| @Conditional(MyCondition.class)
|
hutou-workhouse/miscroServiceHello | eurekaCustomer/src/main/java/me/helllp/demo/eurekaCustomer/web/HelloController.java | // Path: eurekaCustomer/src/main/java/me/helllp/demo/eurekaCustomer/service/FeignService.java
// @FeignClient(value="EUREKACLIENT", configuration=FeignConfiguration.class)
// public interface FeignService {
// @RequestMapping(value = "/hello",method = RequestMethod.GET)
// String sayHiUseFeign(@RequestParam(value = "name") String name);
// }
//
// Path: eurekaCustomer/src/main/java/me/helllp/demo/eurekaCustomer/service/HelloService.java
// @Service
// public class HelloService {
// private static final String SERVICE_NAME = "EUREKACLIENT";
//
// @Autowired
// RestTemplate restTemplate;
//
// @Autowired
// private LoadBalancerClient loadBalancerClient;
//
// public String helloService(String name) {
// ServiceInstance serviceInstance = this.loadBalancerClient.choose(SERVICE_NAME);
// System.out.println("服务主机:" + serviceInstance.getHost());
// System.out.println("服务端口:" + serviceInstance.getPort());
//
// // 通过服务名来访问
// return restTemplate.getForObject("http://" + SERVICE_NAME + "/hello?name="+name,String.class);
// }
//
// }
| import me.helllp.demo.eurekaCustomer.service.FeignService;
import me.helllp.demo.eurekaCustomer.service.HelloService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
| package me.helllp.demo.eurekaCustomer.web;
@RestController
public class HelloController {
@Autowired
| // Path: eurekaCustomer/src/main/java/me/helllp/demo/eurekaCustomer/service/FeignService.java
// @FeignClient(value="EUREKACLIENT", configuration=FeignConfiguration.class)
// public interface FeignService {
// @RequestMapping(value = "/hello",method = RequestMethod.GET)
// String sayHiUseFeign(@RequestParam(value = "name") String name);
// }
//
// Path: eurekaCustomer/src/main/java/me/helllp/demo/eurekaCustomer/service/HelloService.java
// @Service
// public class HelloService {
// private static final String SERVICE_NAME = "EUREKACLIENT";
//
// @Autowired
// RestTemplate restTemplate;
//
// @Autowired
// private LoadBalancerClient loadBalancerClient;
//
// public String helloService(String name) {
// ServiceInstance serviceInstance = this.loadBalancerClient.choose(SERVICE_NAME);
// System.out.println("服务主机:" + serviceInstance.getHost());
// System.out.println("服务端口:" + serviceInstance.getPort());
//
// // 通过服务名来访问
// return restTemplate.getForObject("http://" + SERVICE_NAME + "/hello?name="+name,String.class);
// }
//
// }
// Path: eurekaCustomer/src/main/java/me/helllp/demo/eurekaCustomer/web/HelloController.java
import me.helllp.demo.eurekaCustomer.service.FeignService;
import me.helllp.demo.eurekaCustomer.service.HelloService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
package me.helllp.demo.eurekaCustomer.web;
@RestController
public class HelloController {
@Autowired
| HelloService helloService;
|
hutou-workhouse/miscroServiceHello | eurekaCustomer/src/main/java/me/helllp/demo/eurekaCustomer/web/HelloController.java | // Path: eurekaCustomer/src/main/java/me/helllp/demo/eurekaCustomer/service/FeignService.java
// @FeignClient(value="EUREKACLIENT", configuration=FeignConfiguration.class)
// public interface FeignService {
// @RequestMapping(value = "/hello",method = RequestMethod.GET)
// String sayHiUseFeign(@RequestParam(value = "name") String name);
// }
//
// Path: eurekaCustomer/src/main/java/me/helllp/demo/eurekaCustomer/service/HelloService.java
// @Service
// public class HelloService {
// private static final String SERVICE_NAME = "EUREKACLIENT";
//
// @Autowired
// RestTemplate restTemplate;
//
// @Autowired
// private LoadBalancerClient loadBalancerClient;
//
// public String helloService(String name) {
// ServiceInstance serviceInstance = this.loadBalancerClient.choose(SERVICE_NAME);
// System.out.println("服务主机:" + serviceInstance.getHost());
// System.out.println("服务端口:" + serviceInstance.getPort());
//
// // 通过服务名来访问
// return restTemplate.getForObject("http://" + SERVICE_NAME + "/hello?name="+name,String.class);
// }
//
// }
| import me.helllp.demo.eurekaCustomer.service.FeignService;
import me.helllp.demo.eurekaCustomer.service.HelloService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
| package me.helllp.demo.eurekaCustomer.web;
@RestController
public class HelloController {
@Autowired
HelloService helloService;
@Autowired
| // Path: eurekaCustomer/src/main/java/me/helllp/demo/eurekaCustomer/service/FeignService.java
// @FeignClient(value="EUREKACLIENT", configuration=FeignConfiguration.class)
// public interface FeignService {
// @RequestMapping(value = "/hello",method = RequestMethod.GET)
// String sayHiUseFeign(@RequestParam(value = "name") String name);
// }
//
// Path: eurekaCustomer/src/main/java/me/helllp/demo/eurekaCustomer/service/HelloService.java
// @Service
// public class HelloService {
// private static final String SERVICE_NAME = "EUREKACLIENT";
//
// @Autowired
// RestTemplate restTemplate;
//
// @Autowired
// private LoadBalancerClient loadBalancerClient;
//
// public String helloService(String name) {
// ServiceInstance serviceInstance = this.loadBalancerClient.choose(SERVICE_NAME);
// System.out.println("服务主机:" + serviceInstance.getHost());
// System.out.println("服务端口:" + serviceInstance.getPort());
//
// // 通过服务名来访问
// return restTemplate.getForObject("http://" + SERVICE_NAME + "/hello?name="+name,String.class);
// }
//
// }
// Path: eurekaCustomer/src/main/java/me/helllp/demo/eurekaCustomer/web/HelloController.java
import me.helllp.demo.eurekaCustomer.service.FeignService;
import me.helllp.demo.eurekaCustomer.service.HelloService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
package me.helllp.demo.eurekaCustomer.web;
@RestController
public class HelloController {
@Autowired
HelloService helloService;
@Autowired
| FeignService feignService;
|
hutou-workhouse/miscroServiceHello | springCloudHystrixRibbon/src/main/java/me/helllp/demo/springCloudHystrixRibbon/web/HelloController.java | // Path: springCloudHystrixRibbon/src/main/java/me/helllp/demo/springCloudHystrixRibbon/service/HystrixRibbonService.java
// @Service
// public class HystrixRibbonService {
// private static final String SERVICE_NAME = "EUREKACLIENT";
//
// @Autowired
// RestTemplate restTemplate;
//
// @Autowired
// private LoadBalancerClient loadBalancerClient;
//
// @HystrixCommand(fallbackMethod = "helloServiceFallBack")
// public String helloService(String name) {
// ServiceInstance serviceInstance = this.loadBalancerClient.choose(SERVICE_NAME);
// System.out.println("服务主机:" + serviceInstance.getHost());
// System.out.println("服务端口:" + serviceInstance.getPort());
//
// // 通过服务名来访问
// return restTemplate.getForObject("http://" + SERVICE_NAME + "/hello?name="+name,String.class);
// }
//
// @SuppressWarnings("unused")
// private String helloServiceFallBack(String name) {
// return "这个是失败的信息!";
// }
// }
| import me.helllp.demo.springCloudHystrixRibbon.service.HystrixRibbonService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
| package me.helllp.demo.springCloudHystrixRibbon.web;
@RestController
public class HelloController {
@Autowired
| // Path: springCloudHystrixRibbon/src/main/java/me/helllp/demo/springCloudHystrixRibbon/service/HystrixRibbonService.java
// @Service
// public class HystrixRibbonService {
// private static final String SERVICE_NAME = "EUREKACLIENT";
//
// @Autowired
// RestTemplate restTemplate;
//
// @Autowired
// private LoadBalancerClient loadBalancerClient;
//
// @HystrixCommand(fallbackMethod = "helloServiceFallBack")
// public String helloService(String name) {
// ServiceInstance serviceInstance = this.loadBalancerClient.choose(SERVICE_NAME);
// System.out.println("服务主机:" + serviceInstance.getHost());
// System.out.println("服务端口:" + serviceInstance.getPort());
//
// // 通过服务名来访问
// return restTemplate.getForObject("http://" + SERVICE_NAME + "/hello?name="+name,String.class);
// }
//
// @SuppressWarnings("unused")
// private String helloServiceFallBack(String name) {
// return "这个是失败的信息!";
// }
// }
// Path: springCloudHystrixRibbon/src/main/java/me/helllp/demo/springCloudHystrixRibbon/web/HelloController.java
import me.helllp.demo.springCloudHystrixRibbon.service.HystrixRibbonService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
package me.helllp.demo.springCloudHystrixRibbon.web;
@RestController
public class HelloController {
@Autowired
| HystrixRibbonService helloService;
|
freme-project/freme-ner | src/main/java/org/elinker/core/rest/FremeNerManageDatasets.java | // Path: src/main/java/eu/freme/common/persistence/model/DatasetMetadata.java
// @Entity
// public class DatasetMetadata extends OwnedResource{
//
// public DatasetMetadata(){super(null);}
//
// public DatasetMetadata(String name){
// super();
// this.name = name;
// totalEntities = 0;
// }
//
// @JsonIgnore
// public String getIdentifier(){
// return getName();
// }
//
// public static String getIdentifierName(){return "name";}
//
// private String name;
//
// private long totalEntities;
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public long getTotalEntities() {
// return totalEntities;
// }
//
// public void setTotalEntities(long totalEntities) {
// this.totalEntities = totalEntities;
// }
//
// }
//
// Path: src/main/java/org/elinker/core/api/java/Config.java
// @Component
// public class Config {
// //@Autowired
// //private DatasetMetadataDAO datasetMetadataDAO;
//
// // @Autowired
// // private DatasetMetadataDAO datasetMetadataDAO;
// //>>>>>>> refs/remotes/origin/configuration-optional-#108
//
// @Value("${freme.ner.sparqlEndpoint:}")
// String sparqlEndpoint = "";
//
// @Value("${freme.ner.solrURI:}")
// String solrURI = "";
//
// @Value("${freme.ner.languages}")
// String languages = "";
//
// @Value("${freme.ner.modelsLocation}")
// String modelsLocation = "";
//
// @Value("${freme.ner.domainsFile:}")
// String domainsFile = "";
//
// private boolean sparqlEndointEnabled;
// private boolean solrURIEnabled;
// private boolean domainsFileEnabled;
//
// public void setSparqlEndpoint(String sparqlEndpoint) { this.sparqlEndpoint = sparqlEndpoint; }
//
// public void setSolrURI(String solrURI) {
// this.solrURI = solrURI;
// }
//
// public void setLanguages(String languages) {
// this.languages = languages;
// }
//
// public void setModelsLocation(String modelsLocation) {
// this.modelsLocation = modelsLocation;
// }
//
// public void setDomainsFile(String domainsFile) {
// this.domainsFile = domainsFile;
// }
//
// private org.elinker.core.api.scala.Config scalaConfig = null;
//
// public org.elinker.core.api.scala.Config getScalaConfig() {
// return scalaConfig;
// }
//
// @PostConstruct
// public void init(){
// String[] languages = this.languages.split(",");
// this.scalaConfig = new org.elinker.core.api.scala.Config(
// languages,
// modelsLocation,
// sparqlEndpoint,
// solrURI,
// domainsFile
// );
//
// if(!this.sparqlEndpoint.isEmpty()){
// this.sparqlEndointEnabled = true;
// }
// if(!this.solrURI.isEmpty()){
// this.solrURIEnabled = true;
// }
// if(!this.domainsFile.isEmpty()){
// this.domainsFileEnabled = true;
// }
// }
//
// public boolean isSparqlEndointEnabled() {
// return sparqlEndointEnabled;
// }
//
// public boolean isSolrURIEnabled() {
// return solrURIEnabled;
// }
//
// public boolean isDomainsFileEnabled() {
// return domainsFileEnabled;
// }
//
// }
| import com.google.common.base.Strings;
import eu.freme.common.conversion.rdf.JenaRDFConversionService;
import eu.freme.common.conversion.rdf.RDFConstants;
import eu.freme.common.exception.BadRequestException;
import eu.freme.common.rest.OwnedResourceManagingController;
import eu.freme.common.persistence.model.DatasetMetadata;
import eu.freme.common.rest.RestHelper;
import org.apache.commons.collections.MapUtils;
import org.apache.log4j.Logger;
import org.elinker.core.api.java.Config;
import org.elinker.core.api.scala.FremeNer;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.PostConstruct;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;
import static eu.freme.common.conversion.rdf.RDFConstants.SERIALIZATION_FORMATS; | package org.elinker.core.rest;
/**
* Created by Arne Binder (arne.b.binder@gmail.com) on 08.04.2016.
*/
@RestController
@RequestMapping("/e-entity/freme-ner/datasets") | // Path: src/main/java/eu/freme/common/persistence/model/DatasetMetadata.java
// @Entity
// public class DatasetMetadata extends OwnedResource{
//
// public DatasetMetadata(){super(null);}
//
// public DatasetMetadata(String name){
// super();
// this.name = name;
// totalEntities = 0;
// }
//
// @JsonIgnore
// public String getIdentifier(){
// return getName();
// }
//
// public static String getIdentifierName(){return "name";}
//
// private String name;
//
// private long totalEntities;
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public long getTotalEntities() {
// return totalEntities;
// }
//
// public void setTotalEntities(long totalEntities) {
// this.totalEntities = totalEntities;
// }
//
// }
//
// Path: src/main/java/org/elinker/core/api/java/Config.java
// @Component
// public class Config {
// //@Autowired
// //private DatasetMetadataDAO datasetMetadataDAO;
//
// // @Autowired
// // private DatasetMetadataDAO datasetMetadataDAO;
// //>>>>>>> refs/remotes/origin/configuration-optional-#108
//
// @Value("${freme.ner.sparqlEndpoint:}")
// String sparqlEndpoint = "";
//
// @Value("${freme.ner.solrURI:}")
// String solrURI = "";
//
// @Value("${freme.ner.languages}")
// String languages = "";
//
// @Value("${freme.ner.modelsLocation}")
// String modelsLocation = "";
//
// @Value("${freme.ner.domainsFile:}")
// String domainsFile = "";
//
// private boolean sparqlEndointEnabled;
// private boolean solrURIEnabled;
// private boolean domainsFileEnabled;
//
// public void setSparqlEndpoint(String sparqlEndpoint) { this.sparqlEndpoint = sparqlEndpoint; }
//
// public void setSolrURI(String solrURI) {
// this.solrURI = solrURI;
// }
//
// public void setLanguages(String languages) {
// this.languages = languages;
// }
//
// public void setModelsLocation(String modelsLocation) {
// this.modelsLocation = modelsLocation;
// }
//
// public void setDomainsFile(String domainsFile) {
// this.domainsFile = domainsFile;
// }
//
// private org.elinker.core.api.scala.Config scalaConfig = null;
//
// public org.elinker.core.api.scala.Config getScalaConfig() {
// return scalaConfig;
// }
//
// @PostConstruct
// public void init(){
// String[] languages = this.languages.split(",");
// this.scalaConfig = new org.elinker.core.api.scala.Config(
// languages,
// modelsLocation,
// sparqlEndpoint,
// solrURI,
// domainsFile
// );
//
// if(!this.sparqlEndpoint.isEmpty()){
// this.sparqlEndointEnabled = true;
// }
// if(!this.solrURI.isEmpty()){
// this.solrURIEnabled = true;
// }
// if(!this.domainsFile.isEmpty()){
// this.domainsFileEnabled = true;
// }
// }
//
// public boolean isSparqlEndointEnabled() {
// return sparqlEndointEnabled;
// }
//
// public boolean isSolrURIEnabled() {
// return solrURIEnabled;
// }
//
// public boolean isDomainsFileEnabled() {
// return domainsFileEnabled;
// }
//
// }
// Path: src/main/java/org/elinker/core/rest/FremeNerManageDatasets.java
import com.google.common.base.Strings;
import eu.freme.common.conversion.rdf.JenaRDFConversionService;
import eu.freme.common.conversion.rdf.RDFConstants;
import eu.freme.common.exception.BadRequestException;
import eu.freme.common.rest.OwnedResourceManagingController;
import eu.freme.common.persistence.model.DatasetMetadata;
import eu.freme.common.rest.RestHelper;
import org.apache.commons.collections.MapUtils;
import org.apache.log4j.Logger;
import org.elinker.core.api.java.Config;
import org.elinker.core.api.scala.FremeNer;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.PostConstruct;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;
import static eu.freme.common.conversion.rdf.RDFConstants.SERIALIZATION_FORMATS;
package org.elinker.core.rest;
/**
* Created by Arne Binder (arne.b.binder@gmail.com) on 08.04.2016.
*/
@RestController
@RequestMapping("/e-entity/freme-ner/datasets") | public class FremeNerManageDatasets extends OwnedResourceManagingController<DatasetMetadata>{ |
freme-project/freme-ner | src/main/java/org/elinker/core/rest/FremeNerManageDatasets.java | // Path: src/main/java/eu/freme/common/persistence/model/DatasetMetadata.java
// @Entity
// public class DatasetMetadata extends OwnedResource{
//
// public DatasetMetadata(){super(null);}
//
// public DatasetMetadata(String name){
// super();
// this.name = name;
// totalEntities = 0;
// }
//
// @JsonIgnore
// public String getIdentifier(){
// return getName();
// }
//
// public static String getIdentifierName(){return "name";}
//
// private String name;
//
// private long totalEntities;
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public long getTotalEntities() {
// return totalEntities;
// }
//
// public void setTotalEntities(long totalEntities) {
// this.totalEntities = totalEntities;
// }
//
// }
//
// Path: src/main/java/org/elinker/core/api/java/Config.java
// @Component
// public class Config {
// //@Autowired
// //private DatasetMetadataDAO datasetMetadataDAO;
//
// // @Autowired
// // private DatasetMetadataDAO datasetMetadataDAO;
// //>>>>>>> refs/remotes/origin/configuration-optional-#108
//
// @Value("${freme.ner.sparqlEndpoint:}")
// String sparqlEndpoint = "";
//
// @Value("${freme.ner.solrURI:}")
// String solrURI = "";
//
// @Value("${freme.ner.languages}")
// String languages = "";
//
// @Value("${freme.ner.modelsLocation}")
// String modelsLocation = "";
//
// @Value("${freme.ner.domainsFile:}")
// String domainsFile = "";
//
// private boolean sparqlEndointEnabled;
// private boolean solrURIEnabled;
// private boolean domainsFileEnabled;
//
// public void setSparqlEndpoint(String sparqlEndpoint) { this.sparqlEndpoint = sparqlEndpoint; }
//
// public void setSolrURI(String solrURI) {
// this.solrURI = solrURI;
// }
//
// public void setLanguages(String languages) {
// this.languages = languages;
// }
//
// public void setModelsLocation(String modelsLocation) {
// this.modelsLocation = modelsLocation;
// }
//
// public void setDomainsFile(String domainsFile) {
// this.domainsFile = domainsFile;
// }
//
// private org.elinker.core.api.scala.Config scalaConfig = null;
//
// public org.elinker.core.api.scala.Config getScalaConfig() {
// return scalaConfig;
// }
//
// @PostConstruct
// public void init(){
// String[] languages = this.languages.split(",");
// this.scalaConfig = new org.elinker.core.api.scala.Config(
// languages,
// modelsLocation,
// sparqlEndpoint,
// solrURI,
// domainsFile
// );
//
// if(!this.sparqlEndpoint.isEmpty()){
// this.sparqlEndointEnabled = true;
// }
// if(!this.solrURI.isEmpty()){
// this.solrURIEnabled = true;
// }
// if(!this.domainsFile.isEmpty()){
// this.domainsFileEnabled = true;
// }
// }
//
// public boolean isSparqlEndointEnabled() {
// return sparqlEndointEnabled;
// }
//
// public boolean isSolrURIEnabled() {
// return solrURIEnabled;
// }
//
// public boolean isDomainsFileEnabled() {
// return domainsFileEnabled;
// }
//
// }
| import com.google.common.base.Strings;
import eu.freme.common.conversion.rdf.JenaRDFConversionService;
import eu.freme.common.conversion.rdf.RDFConstants;
import eu.freme.common.exception.BadRequestException;
import eu.freme.common.rest.OwnedResourceManagingController;
import eu.freme.common.persistence.model.DatasetMetadata;
import eu.freme.common.rest.RestHelper;
import org.apache.commons.collections.MapUtils;
import org.apache.log4j.Logger;
import org.elinker.core.api.java.Config;
import org.elinker.core.api.scala.FremeNer;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.PostConstruct;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;
import static eu.freme.common.conversion.rdf.RDFConstants.SERIALIZATION_FORMATS; | package org.elinker.core.rest;
/**
* Created by Arne Binder (arne.b.binder@gmail.com) on 08.04.2016.
*/
@RestController
@RequestMapping("/e-entity/freme-ner/datasets")
public class FremeNerManageDatasets extends OwnedResourceManagingController<DatasetMetadata>{
@Value("${freme.ner.languages}")
String languages = "";
Set<String> SUPPORTED_LANGUAGES;
Logger logger = Logger.getLogger(FremeNerManageDatasets.class);
@Autowired | // Path: src/main/java/eu/freme/common/persistence/model/DatasetMetadata.java
// @Entity
// public class DatasetMetadata extends OwnedResource{
//
// public DatasetMetadata(){super(null);}
//
// public DatasetMetadata(String name){
// super();
// this.name = name;
// totalEntities = 0;
// }
//
// @JsonIgnore
// public String getIdentifier(){
// return getName();
// }
//
// public static String getIdentifierName(){return "name";}
//
// private String name;
//
// private long totalEntities;
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public long getTotalEntities() {
// return totalEntities;
// }
//
// public void setTotalEntities(long totalEntities) {
// this.totalEntities = totalEntities;
// }
//
// }
//
// Path: src/main/java/org/elinker/core/api/java/Config.java
// @Component
// public class Config {
// //@Autowired
// //private DatasetMetadataDAO datasetMetadataDAO;
//
// // @Autowired
// // private DatasetMetadataDAO datasetMetadataDAO;
// //>>>>>>> refs/remotes/origin/configuration-optional-#108
//
// @Value("${freme.ner.sparqlEndpoint:}")
// String sparqlEndpoint = "";
//
// @Value("${freme.ner.solrURI:}")
// String solrURI = "";
//
// @Value("${freme.ner.languages}")
// String languages = "";
//
// @Value("${freme.ner.modelsLocation}")
// String modelsLocation = "";
//
// @Value("${freme.ner.domainsFile:}")
// String domainsFile = "";
//
// private boolean sparqlEndointEnabled;
// private boolean solrURIEnabled;
// private boolean domainsFileEnabled;
//
// public void setSparqlEndpoint(String sparqlEndpoint) { this.sparqlEndpoint = sparqlEndpoint; }
//
// public void setSolrURI(String solrURI) {
// this.solrURI = solrURI;
// }
//
// public void setLanguages(String languages) {
// this.languages = languages;
// }
//
// public void setModelsLocation(String modelsLocation) {
// this.modelsLocation = modelsLocation;
// }
//
// public void setDomainsFile(String domainsFile) {
// this.domainsFile = domainsFile;
// }
//
// private org.elinker.core.api.scala.Config scalaConfig = null;
//
// public org.elinker.core.api.scala.Config getScalaConfig() {
// return scalaConfig;
// }
//
// @PostConstruct
// public void init(){
// String[] languages = this.languages.split(",");
// this.scalaConfig = new org.elinker.core.api.scala.Config(
// languages,
// modelsLocation,
// sparqlEndpoint,
// solrURI,
// domainsFile
// );
//
// if(!this.sparqlEndpoint.isEmpty()){
// this.sparqlEndointEnabled = true;
// }
// if(!this.solrURI.isEmpty()){
// this.solrURIEnabled = true;
// }
// if(!this.domainsFile.isEmpty()){
// this.domainsFileEnabled = true;
// }
// }
//
// public boolean isSparqlEndointEnabled() {
// return sparqlEndointEnabled;
// }
//
// public boolean isSolrURIEnabled() {
// return solrURIEnabled;
// }
//
// public boolean isDomainsFileEnabled() {
// return domainsFileEnabled;
// }
//
// }
// Path: src/main/java/org/elinker/core/rest/FremeNerManageDatasets.java
import com.google.common.base.Strings;
import eu.freme.common.conversion.rdf.JenaRDFConversionService;
import eu.freme.common.conversion.rdf.RDFConstants;
import eu.freme.common.exception.BadRequestException;
import eu.freme.common.rest.OwnedResourceManagingController;
import eu.freme.common.persistence.model.DatasetMetadata;
import eu.freme.common.rest.RestHelper;
import org.apache.commons.collections.MapUtils;
import org.apache.log4j.Logger;
import org.elinker.core.api.java.Config;
import org.elinker.core.api.scala.FremeNer;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.PostConstruct;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;
import static eu.freme.common.conversion.rdf.RDFConstants.SERIALIZATION_FORMATS;
package org.elinker.core.rest;
/**
* Created by Arne Binder (arne.b.binder@gmail.com) on 08.04.2016.
*/
@RestController
@RequestMapping("/e-entity/freme-ner/datasets")
public class FremeNerManageDatasets extends OwnedResourceManagingController<DatasetMetadata>{
@Value("${freme.ner.languages}")
String languages = "";
Set<String> SUPPORTED_LANGUAGES;
Logger logger = Logger.getLogger(FremeNerManageDatasets.class);
@Autowired | Config fremeNerConfig; |
freme-project/freme-ner | src/main/java/org/elinker/core/api/java/FremeNer.java | // Path: src/main/java/org/elinker/core/spotter/FremeSpotter.java
// @Component
// @RequiredArgsConstructor
// public class FremeSpotter implements ApplicationListener<ContextRefreshedEvent> {
//
// @Value("${freme.ner.dictionary:}")
// private String dictionary = "";
//
// private Boolean hasBuilt = false;
//
// private Trie.TrieBuilder builder;
//
// private Trie trie;
//
// private void buildDictionary() {
//
// if (dictionary == null || dictionary.isEmpty()) {
// return;
// }
//
//
// builder = Trie.builder().removeOverlaps().caseInsensitive();
//
// try (Stream<String> stream = Files.lines(Paths.get(dictionary))) {
// stream.forEach(s -> {
// builder.addKeyword(s);
// });
// } catch (IOException e) {
// throw new InternalServerErrorException(String.format("It was not possible to read the spotter dictionary." +
// " Please check if the path is correct (%s)", dictionary));
// }
// trie = builder.build();
// }
//
// public void addKey(String key) {
//
// if (dictionary == null || dictionary.isEmpty()) {
// return;
// }
//
// try {
// builder.addKeyword(key);
// trie = builder.build();
// Files.write(Paths.get(dictionary), key.concat(System.lineSeparator()).getBytes(UTF_8), APPEND);
// } catch (IOException e) {
// throw new InternalServerErrorException("It was not possible to add a key into the spotter dictionary.");
// }
//
// }
//
// public Collection<Emit> parseText(String text) {
// if (trie != null) {
// return trie.parseText(text);
// }
// return new ArrayList<>();
// }
//
// @Override
// public void onApplicationEvent(ContextRefreshedEvent contextRefreshedEvent) {
// if (!hasBuilt) {
// buildDictionary();
// }
//
// }
//
// }
| import org.elinker.core.spotter.FremeSpotter;
import org.springframework.beans.factory.annotation.Autowired;
import eu.freme.common.exception.BadRequestException;
import javax.annotation.PostConstruct;
import org.springframework.transaction.annotation.Transactional; | package org.elinker.core.api.java;
/**
* FremeNER Java API for performing spotting, linking and dataset management.
* This class is essentially a wrapper around the Scala API.
*
* @author Nilesh Chakraborty <nilesh@nileshc.com>
*/
public class FremeNer {
private org.elinker.core.api.scala.FremeNer fremeNer = null;
@Autowired
Config config;
@Autowired | // Path: src/main/java/org/elinker/core/spotter/FremeSpotter.java
// @Component
// @RequiredArgsConstructor
// public class FremeSpotter implements ApplicationListener<ContextRefreshedEvent> {
//
// @Value("${freme.ner.dictionary:}")
// private String dictionary = "";
//
// private Boolean hasBuilt = false;
//
// private Trie.TrieBuilder builder;
//
// private Trie trie;
//
// private void buildDictionary() {
//
// if (dictionary == null || dictionary.isEmpty()) {
// return;
// }
//
//
// builder = Trie.builder().removeOverlaps().caseInsensitive();
//
// try (Stream<String> stream = Files.lines(Paths.get(dictionary))) {
// stream.forEach(s -> {
// builder.addKeyword(s);
// });
// } catch (IOException e) {
// throw new InternalServerErrorException(String.format("It was not possible to read the spotter dictionary." +
// " Please check if the path is correct (%s)", dictionary));
// }
// trie = builder.build();
// }
//
// public void addKey(String key) {
//
// if (dictionary == null || dictionary.isEmpty()) {
// return;
// }
//
// try {
// builder.addKeyword(key);
// trie = builder.build();
// Files.write(Paths.get(dictionary), key.concat(System.lineSeparator()).getBytes(UTF_8), APPEND);
// } catch (IOException e) {
// throw new InternalServerErrorException("It was not possible to add a key into the spotter dictionary.");
// }
//
// }
//
// public Collection<Emit> parseText(String text) {
// if (trie != null) {
// return trie.parseText(text);
// }
// return new ArrayList<>();
// }
//
// @Override
// public void onApplicationEvent(ContextRefreshedEvent contextRefreshedEvent) {
// if (!hasBuilt) {
// buildDictionary();
// }
//
// }
//
// }
// Path: src/main/java/org/elinker/core/api/java/FremeNer.java
import org.elinker.core.spotter.FremeSpotter;
import org.springframework.beans.factory.annotation.Autowired;
import eu.freme.common.exception.BadRequestException;
import javax.annotation.PostConstruct;
import org.springframework.transaction.annotation.Transactional;
package org.elinker.core.api.java;
/**
* FremeNER Java API for performing spotting, linking and dataset management.
* This class is essentially a wrapper around the Scala API.
*
* @author Nilesh Chakraborty <nilesh@nileshc.com>
*/
public class FremeNer {
private org.elinker.core.api.scala.FremeNer fremeNer = null;
@Autowired
Config config;
@Autowired | private FremeSpotter spotter; |
freme-project/freme-ner | src/main/java/eu/freme/common/persistence/dao/DatasetMetadataDAO.java | // Path: src/main/java/eu/freme/common/persistence/model/DatasetMetadata.java
// @Entity
// public class DatasetMetadata extends OwnedResource{
//
// public DatasetMetadata(){super(null);}
//
// public DatasetMetadata(String name){
// super();
// this.name = name;
// totalEntities = 0;
// }
//
// @JsonIgnore
// public String getIdentifier(){
// return getName();
// }
//
// public static String getIdentifierName(){return "name";}
//
// private String name;
//
// private long totalEntities;
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public long getTotalEntities() {
// return totalEntities;
// }
//
// public void setTotalEntities(long totalEntities) {
// this.totalEntities = totalEntities;
// }
//
// }
//
// Path: src/main/java/eu/freme/common/persistence/repository/DatasetMetadataRepository.java
// public interface DatasetMetadataRepository extends OwnedResourceRepository<DatasetMetadata> {
// DatasetMetadata findOneByName(String name);
// }
| import eu.freme.common.persistence.model.DatasetMetadata;
import eu.freme.common.persistence.repository.DatasetMetadataRepository;
import org.springframework.stereotype.Component; | /**
* Copyright (C) 2015 Agro-Know, Deutsches Forschungszentrum für Künstliche Intelligenz, iMinds,
* Institut für Angewandte Informatik e. V. an der Universität Leipzig,
* Istituto Superiore Mario Boella, Tilde, Vistatec, WRIPL (http://freme-project.eu)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package eu.freme.common.persistence.dao;
/**
* Created by Arne Binder (arne.b.binder@gmail.com) on 01.10.2015.
*/
@Component
public class DatasetMetadataDAO extends OwnedResourceDAO<DatasetMetadata> {
@Override
public String tableName() {
return DatasetMetadata.class.getSimpleName();
}
@Override
public DatasetMetadata findOneByIdentifierUnsecured(String identifier){ | // Path: src/main/java/eu/freme/common/persistence/model/DatasetMetadata.java
// @Entity
// public class DatasetMetadata extends OwnedResource{
//
// public DatasetMetadata(){super(null);}
//
// public DatasetMetadata(String name){
// super();
// this.name = name;
// totalEntities = 0;
// }
//
// @JsonIgnore
// public String getIdentifier(){
// return getName();
// }
//
// public static String getIdentifierName(){return "name";}
//
// private String name;
//
// private long totalEntities;
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public long getTotalEntities() {
// return totalEntities;
// }
//
// public void setTotalEntities(long totalEntities) {
// this.totalEntities = totalEntities;
// }
//
// }
//
// Path: src/main/java/eu/freme/common/persistence/repository/DatasetMetadataRepository.java
// public interface DatasetMetadataRepository extends OwnedResourceRepository<DatasetMetadata> {
// DatasetMetadata findOneByName(String name);
// }
// Path: src/main/java/eu/freme/common/persistence/dao/DatasetMetadataDAO.java
import eu.freme.common.persistence.model.DatasetMetadata;
import eu.freme.common.persistence.repository.DatasetMetadataRepository;
import org.springframework.stereotype.Component;
/**
* Copyright (C) 2015 Agro-Know, Deutsches Forschungszentrum für Künstliche Intelligenz, iMinds,
* Institut für Angewandte Informatik e. V. an der Universität Leipzig,
* Istituto Superiore Mario Boella, Tilde, Vistatec, WRIPL (http://freme-project.eu)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package eu.freme.common.persistence.dao;
/**
* Created by Arne Binder (arne.b.binder@gmail.com) on 01.10.2015.
*/
@Component
public class DatasetMetadataDAO extends OwnedResourceDAO<DatasetMetadata> {
@Override
public String tableName() {
return DatasetMetadata.class.getSimpleName();
}
@Override
public DatasetMetadata findOneByIdentifierUnsecured(String identifier){ | return ((DatasetMetadataRepository)repository).findOneByName(identifier); |
zendesk/belvedere | belvedere-core/src/main/java/zendesk/belvedere/Storage.java | // Path: belvedere-core/src/main/java/zendesk/belvedere/MediaResult.java
// public static final long UNKNOWN_VALUE = -1L;
| import android.content.ContentResolver;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
import android.database.Cursor;
import android.net.Uri;
import android.os.Build;
import android.provider.MediaStore;
import android.text.TextUtils;
import android.util.Log;
import android.webkit.MimeTypeMap;
import java.io.File;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
import java.util.Locale;
import static zendesk.belvedere.MediaResult.UNKNOWN_VALUE; | */
private static String getFileNameFromUri(Context context, Uri uri) {
final String schema = uri.getScheme();
String path = "";
if (ContentResolver.SCHEME_CONTENT.equals(schema)) {
final String[] projection = {MediaStore.MediaColumns.DISPLAY_NAME};
final ContentResolver contentResolver = context.getContentResolver();
final Cursor cursor = contentResolver.query(uri, projection, null, null, null);
if (cursor != null) {
try {
if (cursor.moveToFirst()) {
path = cursor.getString(0);
}
} finally {
cursor.close();
}
}
} else if (ContentResolver.SCHEME_FILE.equals(schema)) {
path = uri.getLastPathSegment();
}
return path;
}
static MediaResult getMediaResultForUri(Context context, Uri uri) {
final String schema = uri.getScheme(); | // Path: belvedere-core/src/main/java/zendesk/belvedere/MediaResult.java
// public static final long UNKNOWN_VALUE = -1L;
// Path: belvedere-core/src/main/java/zendesk/belvedere/Storage.java
import android.content.ContentResolver;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
import android.database.Cursor;
import android.net.Uri;
import android.os.Build;
import android.provider.MediaStore;
import android.text.TextUtils;
import android.util.Log;
import android.webkit.MimeTypeMap;
import java.io.File;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
import java.util.Locale;
import static zendesk.belvedere.MediaResult.UNKNOWN_VALUE;
*/
private static String getFileNameFromUri(Context context, Uri uri) {
final String schema = uri.getScheme();
String path = "";
if (ContentResolver.SCHEME_CONTENT.equals(schema)) {
final String[] projection = {MediaStore.MediaColumns.DISPLAY_NAME};
final ContentResolver contentResolver = context.getContentResolver();
final Cursor cursor = contentResolver.query(uri, projection, null, null, null);
if (cursor != null) {
try {
if (cursor.moveToFirst()) {
path = cursor.getString(0);
}
} finally {
cursor.close();
}
}
} else if (ContentResolver.SCHEME_FILE.equals(schema)) {
path = uri.getLastPathSegment();
}
return path;
}
static MediaResult getMediaResultForUri(Context context, Uri uri) {
final String schema = uri.getScheme(); | long size = UNKNOWN_VALUE; |
mikedouglas/MiniJava | src/java/minijava/ast/VarDecl.java | // Path: src/java/minijava/visitor/Visitor.java
// public interface Visitor<R> {
//
// //Lists
// public <T extends AST> R visit(NodeList<T> ns);
//
// //Declarations
// public R visit(Program n);
// public R visit(MainClass n);
// public R visit(ClassDecl n);
// public R visit(VarDecl n);
// public R visit(MethodDecl n);
//
// //Types
// public R visit(IntArrayType n);
// public R visit(BooleanType n);
// public R visit(IntegerType n);
// public R visit(ObjectType n);
//
// //Statements
// public R visit(Block n);
// public R visit(If n);
// public R visit(While n);
// public R visit(Print n);
// public R visit(Assign n);
// public R visit(ArrayAssign n);
//
// //Expressions
// public R visit(And n);
// public R visit(LessThan n);
// public R visit(Plus n);
// public R visit(Minus n);
// public R visit(Times n);
// public R visit(ArrayLookup n);
// public R visit(ArrayLength n);
// public R visit(Call n);
// public R visit(IntegerLiteral n);
// public R visit(BooleanLiteral n);
// public R visit(IdentifierExp n);
// public R visit(This n);
// public R visit(NewArray n);
// public R visit(NewObject n);
// public R visit(Not not);
//
// }
| import minijava.visitor.Visitor; | package minijava.ast;
public class VarDecl extends AST {
public static enum Kind {
FIELD, LOCAL, FORMAL
}
public final Kind kind;
public final Type type;
public final String name;
public VarDecl(Kind kind, Type type, String name) {
super();
this.kind = kind;
this.type = type;
this.name = name;
}
@Override | // Path: src/java/minijava/visitor/Visitor.java
// public interface Visitor<R> {
//
// //Lists
// public <T extends AST> R visit(NodeList<T> ns);
//
// //Declarations
// public R visit(Program n);
// public R visit(MainClass n);
// public R visit(ClassDecl n);
// public R visit(VarDecl n);
// public R visit(MethodDecl n);
//
// //Types
// public R visit(IntArrayType n);
// public R visit(BooleanType n);
// public R visit(IntegerType n);
// public R visit(ObjectType n);
//
// //Statements
// public R visit(Block n);
// public R visit(If n);
// public R visit(While n);
// public R visit(Print n);
// public R visit(Assign n);
// public R visit(ArrayAssign n);
//
// //Expressions
// public R visit(And n);
// public R visit(LessThan n);
// public R visit(Plus n);
// public R visit(Minus n);
// public R visit(Times n);
// public R visit(ArrayLookup n);
// public R visit(ArrayLength n);
// public R visit(Call n);
// public R visit(IntegerLiteral n);
// public R visit(BooleanLiteral n);
// public R visit(IdentifierExp n);
// public R visit(This n);
// public R visit(NewArray n);
// public R visit(NewObject n);
// public R visit(Not not);
//
// }
// Path: src/java/minijava/ast/VarDecl.java
import minijava.visitor.Visitor;
package minijava.ast;
public class VarDecl extends AST {
public static enum Kind {
FIELD, LOCAL, FORMAL
}
public final Kind kind;
public final Type type;
public final String name;
public VarDecl(Kind kind, Type type, String name) {
super();
this.kind = kind;
this.type = type;
this.name = name;
}
@Override | public <R> R accept(Visitor<R> v) { |
mikedouglas/MiniJava | src/java/minijava/typechecker/ErrorReport.java | // Path: src/java/minijava/ast/Call.java
// public class Call extends Expression {
//
// public final Expression receiver;
// public final String name;
// public final NodeList<Expression> rands;
//
// public Call(Expression receiver, String name, NodeList<Expression> rands) {
// super();
// this.receiver = receiver;
// this.name = name;
// this.rands = rands;
// }
//
// @Override
// public <R> R accept(Visitor<R> v) {
// return v.visit(this);
// }
//
// }
//
// Path: src/java/minijava/ast/Expression.java
// public abstract class Expression extends AST {
//
// /**
// * The type of an expression is set by the type checking phase.
// */
// public Type type;
//
// public Type getType() {
// Assert.assertNotNull("Was this AST typechecked?", type);
// return type;
// }
//
// public void setType(Type theType) {
// //Assert.assertNull(type);
// //As our visitor is written, we expect the types of some nodes to be set multiple times.
// //as long as there is no conflict in these type settings, there is no problem, and the assertion has been
// //modified to reflect that.
// assert(type==null || type.equals(theType));
// type = theType;
// }
//
// }
//
// Path: src/java/minijava/ast/ObjectType.java
// public class ObjectType extends Type {
//
// public final String name;
//
// public ObjectType(String name) {
// super();
// this.name = name;
// }
//
// @Override
// public <R> R accept(Visitor<R> v) {
// return v.visit(this);
// }
//
// @Override
// public boolean equals(Object other) {
// if (this.getClass()==other.getClass()) {
// return this.name.equals(((ObjectType)other).name);
// }
// return false;
// }
// }
//
// Path: src/java/minijava/ast/Type.java
// public abstract class Type extends AST {
//
// @Override
// public abstract boolean equals(Object other);
//
// }
| import minijava.ast.Call;
import minijava.ast.Expression;
import minijava.ast.ObjectType;
import minijava.ast.Type; | package minijava.typechecker;
/**
* A centralised interface to record errors.
*
* @author kdvolder
*/
public class ErrorReport {
private ErrorMessage firstError = null;
public ErrorReport() {}
/**
* Add an error to the ErrorReport.
* <p>
* In this implementation the msg is simply printed to System.out. Also, the first message
* is saved, so it can be verified by unit tests.
*/
void report(ErrorMessage msg) {
if (firstError==null)
firstError = msg;
System.out.println(msg);
}
/**
* To allow processing all of the input (so that as many errors as possible can be
* reported) and raising an error only in the end
* this method is provided. You should call this method when you are done reporting
* errors.
* <p>
* This method will raise an Exception if the error report contains some errors,
* otherwise the method will return normally.
* <p>
* @throws TypeCheckerException
*/
public void close() throws TypeCheckerException {
if (firstError!=null)
throw new TypeCheckerException(firstError);
}
public void duplicateDefinition(String name) {
report(ErrorMessage.duplicateDefinition(name));
}
public void undefinedId(String name) {
report(ErrorMessage.undefinedId(name));
}
| // Path: src/java/minijava/ast/Call.java
// public class Call extends Expression {
//
// public final Expression receiver;
// public final String name;
// public final NodeList<Expression> rands;
//
// public Call(Expression receiver, String name, NodeList<Expression> rands) {
// super();
// this.receiver = receiver;
// this.name = name;
// this.rands = rands;
// }
//
// @Override
// public <R> R accept(Visitor<R> v) {
// return v.visit(this);
// }
//
// }
//
// Path: src/java/minijava/ast/Expression.java
// public abstract class Expression extends AST {
//
// /**
// * The type of an expression is set by the type checking phase.
// */
// public Type type;
//
// public Type getType() {
// Assert.assertNotNull("Was this AST typechecked?", type);
// return type;
// }
//
// public void setType(Type theType) {
// //Assert.assertNull(type);
// //As our visitor is written, we expect the types of some nodes to be set multiple times.
// //as long as there is no conflict in these type settings, there is no problem, and the assertion has been
// //modified to reflect that.
// assert(type==null || type.equals(theType));
// type = theType;
// }
//
// }
//
// Path: src/java/minijava/ast/ObjectType.java
// public class ObjectType extends Type {
//
// public final String name;
//
// public ObjectType(String name) {
// super();
// this.name = name;
// }
//
// @Override
// public <R> R accept(Visitor<R> v) {
// return v.visit(this);
// }
//
// @Override
// public boolean equals(Object other) {
// if (this.getClass()==other.getClass()) {
// return this.name.equals(((ObjectType)other).name);
// }
// return false;
// }
// }
//
// Path: src/java/minijava/ast/Type.java
// public abstract class Type extends AST {
//
// @Override
// public abstract boolean equals(Object other);
//
// }
// Path: src/java/minijava/typechecker/ErrorReport.java
import minijava.ast.Call;
import minijava.ast.Expression;
import minijava.ast.ObjectType;
import minijava.ast.Type;
package minijava.typechecker;
/**
* A centralised interface to record errors.
*
* @author kdvolder
*/
public class ErrorReport {
private ErrorMessage firstError = null;
public ErrorReport() {}
/**
* Add an error to the ErrorReport.
* <p>
* In this implementation the msg is simply printed to System.out. Also, the first message
* is saved, so it can be verified by unit tests.
*/
void report(ErrorMessage msg) {
if (firstError==null)
firstError = msg;
System.out.println(msg);
}
/**
* To allow processing all of the input (so that as many errors as possible can be
* reported) and raising an error only in the end
* this method is provided. You should call this method when you are done reporting
* errors.
* <p>
* This method will raise an Exception if the error report contains some errors,
* otherwise the method will return normally.
* <p>
* @throws TypeCheckerException
*/
public void close() throws TypeCheckerException {
if (firstError!=null)
throw new TypeCheckerException(firstError);
}
public void duplicateDefinition(String name) {
report(ErrorMessage.duplicateDefinition(name));
}
public void undefinedId(String name) {
report(ErrorMessage.undefinedId(name));
}
| public void typeError(Expression exp, Type expected, Type actual) { |
mikedouglas/MiniJava | src/java/minijava/typechecker/ErrorReport.java | // Path: src/java/minijava/ast/Call.java
// public class Call extends Expression {
//
// public final Expression receiver;
// public final String name;
// public final NodeList<Expression> rands;
//
// public Call(Expression receiver, String name, NodeList<Expression> rands) {
// super();
// this.receiver = receiver;
// this.name = name;
// this.rands = rands;
// }
//
// @Override
// public <R> R accept(Visitor<R> v) {
// return v.visit(this);
// }
//
// }
//
// Path: src/java/minijava/ast/Expression.java
// public abstract class Expression extends AST {
//
// /**
// * The type of an expression is set by the type checking phase.
// */
// public Type type;
//
// public Type getType() {
// Assert.assertNotNull("Was this AST typechecked?", type);
// return type;
// }
//
// public void setType(Type theType) {
// //Assert.assertNull(type);
// //As our visitor is written, we expect the types of some nodes to be set multiple times.
// //as long as there is no conflict in these type settings, there is no problem, and the assertion has been
// //modified to reflect that.
// assert(type==null || type.equals(theType));
// type = theType;
// }
//
// }
//
// Path: src/java/minijava/ast/ObjectType.java
// public class ObjectType extends Type {
//
// public final String name;
//
// public ObjectType(String name) {
// super();
// this.name = name;
// }
//
// @Override
// public <R> R accept(Visitor<R> v) {
// return v.visit(this);
// }
//
// @Override
// public boolean equals(Object other) {
// if (this.getClass()==other.getClass()) {
// return this.name.equals(((ObjectType)other).name);
// }
// return false;
// }
// }
//
// Path: src/java/minijava/ast/Type.java
// public abstract class Type extends AST {
//
// @Override
// public abstract boolean equals(Object other);
//
// }
| import minijava.ast.Call;
import minijava.ast.Expression;
import minijava.ast.ObjectType;
import minijava.ast.Type; | package minijava.typechecker;
/**
* A centralised interface to record errors.
*
* @author kdvolder
*/
public class ErrorReport {
private ErrorMessage firstError = null;
public ErrorReport() {}
/**
* Add an error to the ErrorReport.
* <p>
* In this implementation the msg is simply printed to System.out. Also, the first message
* is saved, so it can be verified by unit tests.
*/
void report(ErrorMessage msg) {
if (firstError==null)
firstError = msg;
System.out.println(msg);
}
/**
* To allow processing all of the input (so that as many errors as possible can be
* reported) and raising an error only in the end
* this method is provided. You should call this method when you are done reporting
* errors.
* <p>
* This method will raise an Exception if the error report contains some errors,
* otherwise the method will return normally.
* <p>
* @throws TypeCheckerException
*/
public void close() throws TypeCheckerException {
if (firstError!=null)
throw new TypeCheckerException(firstError);
}
public void duplicateDefinition(String name) {
report(ErrorMessage.duplicateDefinition(name));
}
public void undefinedId(String name) {
report(ErrorMessage.undefinedId(name));
}
| // Path: src/java/minijava/ast/Call.java
// public class Call extends Expression {
//
// public final Expression receiver;
// public final String name;
// public final NodeList<Expression> rands;
//
// public Call(Expression receiver, String name, NodeList<Expression> rands) {
// super();
// this.receiver = receiver;
// this.name = name;
// this.rands = rands;
// }
//
// @Override
// public <R> R accept(Visitor<R> v) {
// return v.visit(this);
// }
//
// }
//
// Path: src/java/minijava/ast/Expression.java
// public abstract class Expression extends AST {
//
// /**
// * The type of an expression is set by the type checking phase.
// */
// public Type type;
//
// public Type getType() {
// Assert.assertNotNull("Was this AST typechecked?", type);
// return type;
// }
//
// public void setType(Type theType) {
// //Assert.assertNull(type);
// //As our visitor is written, we expect the types of some nodes to be set multiple times.
// //as long as there is no conflict in these type settings, there is no problem, and the assertion has been
// //modified to reflect that.
// assert(type==null || type.equals(theType));
// type = theType;
// }
//
// }
//
// Path: src/java/minijava/ast/ObjectType.java
// public class ObjectType extends Type {
//
// public final String name;
//
// public ObjectType(String name) {
// super();
// this.name = name;
// }
//
// @Override
// public <R> R accept(Visitor<R> v) {
// return v.visit(this);
// }
//
// @Override
// public boolean equals(Object other) {
// if (this.getClass()==other.getClass()) {
// return this.name.equals(((ObjectType)other).name);
// }
// return false;
// }
// }
//
// Path: src/java/minijava/ast/Type.java
// public abstract class Type extends AST {
//
// @Override
// public abstract boolean equals(Object other);
//
// }
// Path: src/java/minijava/typechecker/ErrorReport.java
import minijava.ast.Call;
import minijava.ast.Expression;
import minijava.ast.ObjectType;
import minijava.ast.Type;
package minijava.typechecker;
/**
* A centralised interface to record errors.
*
* @author kdvolder
*/
public class ErrorReport {
private ErrorMessage firstError = null;
public ErrorReport() {}
/**
* Add an error to the ErrorReport.
* <p>
* In this implementation the msg is simply printed to System.out. Also, the first message
* is saved, so it can be verified by unit tests.
*/
void report(ErrorMessage msg) {
if (firstError==null)
firstError = msg;
System.out.println(msg);
}
/**
* To allow processing all of the input (so that as many errors as possible can be
* reported) and raising an error only in the end
* this method is provided. You should call this method when you are done reporting
* errors.
* <p>
* This method will raise an Exception if the error report contains some errors,
* otherwise the method will return normally.
* <p>
* @throws TypeCheckerException
*/
public void close() throws TypeCheckerException {
if (firstError!=null)
throw new TypeCheckerException(firstError);
}
public void duplicateDefinition(String name) {
report(ErrorMessage.duplicateDefinition(name));
}
public void undefinedId(String name) {
report(ErrorMessage.undefinedId(name));
}
| public void typeError(Expression exp, Type expected, Type actual) { |
mikedouglas/MiniJava | src/java/minijava/typechecker/ErrorReport.java | // Path: src/java/minijava/ast/Call.java
// public class Call extends Expression {
//
// public final Expression receiver;
// public final String name;
// public final NodeList<Expression> rands;
//
// public Call(Expression receiver, String name, NodeList<Expression> rands) {
// super();
// this.receiver = receiver;
// this.name = name;
// this.rands = rands;
// }
//
// @Override
// public <R> R accept(Visitor<R> v) {
// return v.visit(this);
// }
//
// }
//
// Path: src/java/minijava/ast/Expression.java
// public abstract class Expression extends AST {
//
// /**
// * The type of an expression is set by the type checking phase.
// */
// public Type type;
//
// public Type getType() {
// Assert.assertNotNull("Was this AST typechecked?", type);
// return type;
// }
//
// public void setType(Type theType) {
// //Assert.assertNull(type);
// //As our visitor is written, we expect the types of some nodes to be set multiple times.
// //as long as there is no conflict in these type settings, there is no problem, and the assertion has been
// //modified to reflect that.
// assert(type==null || type.equals(theType));
// type = theType;
// }
//
// }
//
// Path: src/java/minijava/ast/ObjectType.java
// public class ObjectType extends Type {
//
// public final String name;
//
// public ObjectType(String name) {
// super();
// this.name = name;
// }
//
// @Override
// public <R> R accept(Visitor<R> v) {
// return v.visit(this);
// }
//
// @Override
// public boolean equals(Object other) {
// if (this.getClass()==other.getClass()) {
// return this.name.equals(((ObjectType)other).name);
// }
// return false;
// }
// }
//
// Path: src/java/minijava/ast/Type.java
// public abstract class Type extends AST {
//
// @Override
// public abstract boolean equals(Object other);
//
// }
| import minijava.ast.Call;
import minijava.ast.Expression;
import minijava.ast.ObjectType;
import minijava.ast.Type; | package minijava.typechecker;
/**
* A centralised interface to record errors.
*
* @author kdvolder
*/
public class ErrorReport {
private ErrorMessage firstError = null;
public ErrorReport() {}
/**
* Add an error to the ErrorReport.
* <p>
* In this implementation the msg is simply printed to System.out. Also, the first message
* is saved, so it can be verified by unit tests.
*/
void report(ErrorMessage msg) {
if (firstError==null)
firstError = msg;
System.out.println(msg);
}
/**
* To allow processing all of the input (so that as many errors as possible can be
* reported) and raising an error only in the end
* this method is provided. You should call this method when you are done reporting
* errors.
* <p>
* This method will raise an Exception if the error report contains some errors,
* otherwise the method will return normally.
* <p>
* @throws TypeCheckerException
*/
public void close() throws TypeCheckerException {
if (firstError!=null)
throw new TypeCheckerException(firstError);
}
public void duplicateDefinition(String name) {
report(ErrorMessage.duplicateDefinition(name));
}
public void undefinedId(String name) {
report(ErrorMessage.undefinedId(name));
}
public void typeError(Expression exp, Type expected, Type actual) {
report(ErrorMessage.typeError(exp,expected,actual));
}
public void typeErrorExpectObjectType(Expression exp, Type actual) {
report(ErrorMessage.typeErrorExpectObject(exp,actual));
}
| // Path: src/java/minijava/ast/Call.java
// public class Call extends Expression {
//
// public final Expression receiver;
// public final String name;
// public final NodeList<Expression> rands;
//
// public Call(Expression receiver, String name, NodeList<Expression> rands) {
// super();
// this.receiver = receiver;
// this.name = name;
// this.rands = rands;
// }
//
// @Override
// public <R> R accept(Visitor<R> v) {
// return v.visit(this);
// }
//
// }
//
// Path: src/java/minijava/ast/Expression.java
// public abstract class Expression extends AST {
//
// /**
// * The type of an expression is set by the type checking phase.
// */
// public Type type;
//
// public Type getType() {
// Assert.assertNotNull("Was this AST typechecked?", type);
// return type;
// }
//
// public void setType(Type theType) {
// //Assert.assertNull(type);
// //As our visitor is written, we expect the types of some nodes to be set multiple times.
// //as long as there is no conflict in these type settings, there is no problem, and the assertion has been
// //modified to reflect that.
// assert(type==null || type.equals(theType));
// type = theType;
// }
//
// }
//
// Path: src/java/minijava/ast/ObjectType.java
// public class ObjectType extends Type {
//
// public final String name;
//
// public ObjectType(String name) {
// super();
// this.name = name;
// }
//
// @Override
// public <R> R accept(Visitor<R> v) {
// return v.visit(this);
// }
//
// @Override
// public boolean equals(Object other) {
// if (this.getClass()==other.getClass()) {
// return this.name.equals(((ObjectType)other).name);
// }
// return false;
// }
// }
//
// Path: src/java/minijava/ast/Type.java
// public abstract class Type extends AST {
//
// @Override
// public abstract boolean equals(Object other);
//
// }
// Path: src/java/minijava/typechecker/ErrorReport.java
import minijava.ast.Call;
import minijava.ast.Expression;
import minijava.ast.ObjectType;
import minijava.ast.Type;
package minijava.typechecker;
/**
* A centralised interface to record errors.
*
* @author kdvolder
*/
public class ErrorReport {
private ErrorMessage firstError = null;
public ErrorReport() {}
/**
* Add an error to the ErrorReport.
* <p>
* In this implementation the msg is simply printed to System.out. Also, the first message
* is saved, so it can be verified by unit tests.
*/
void report(ErrorMessage msg) {
if (firstError==null)
firstError = msg;
System.out.println(msg);
}
/**
* To allow processing all of the input (so that as many errors as possible can be
* reported) and raising an error only in the end
* this method is provided. You should call this method when you are done reporting
* errors.
* <p>
* This method will raise an Exception if the error report contains some errors,
* otherwise the method will return normally.
* <p>
* @throws TypeCheckerException
*/
public void close() throws TypeCheckerException {
if (firstError!=null)
throw new TypeCheckerException(firstError);
}
public void duplicateDefinition(String name) {
report(ErrorMessage.duplicateDefinition(name));
}
public void undefinedId(String name) {
report(ErrorMessage.undefinedId(name));
}
public void typeError(Expression exp, Type expected, Type actual) {
report(ErrorMessage.typeError(exp,expected,actual));
}
public void typeErrorExpectObjectType(Expression exp, Type actual) {
report(ErrorMessage.typeErrorExpectObject(exp,actual));
}
| public void wrongNumberOfArguments(Call call, int expected) { |
mikedouglas/MiniJava | src/java/minijava/typechecker/ErrorReport.java | // Path: src/java/minijava/ast/Call.java
// public class Call extends Expression {
//
// public final Expression receiver;
// public final String name;
// public final NodeList<Expression> rands;
//
// public Call(Expression receiver, String name, NodeList<Expression> rands) {
// super();
// this.receiver = receiver;
// this.name = name;
// this.rands = rands;
// }
//
// @Override
// public <R> R accept(Visitor<R> v) {
// return v.visit(this);
// }
//
// }
//
// Path: src/java/minijava/ast/Expression.java
// public abstract class Expression extends AST {
//
// /**
// * The type of an expression is set by the type checking phase.
// */
// public Type type;
//
// public Type getType() {
// Assert.assertNotNull("Was this AST typechecked?", type);
// return type;
// }
//
// public void setType(Type theType) {
// //Assert.assertNull(type);
// //As our visitor is written, we expect the types of some nodes to be set multiple times.
// //as long as there is no conflict in these type settings, there is no problem, and the assertion has been
// //modified to reflect that.
// assert(type==null || type.equals(theType));
// type = theType;
// }
//
// }
//
// Path: src/java/minijava/ast/ObjectType.java
// public class ObjectType extends Type {
//
// public final String name;
//
// public ObjectType(String name) {
// super();
// this.name = name;
// }
//
// @Override
// public <R> R accept(Visitor<R> v) {
// return v.visit(this);
// }
//
// @Override
// public boolean equals(Object other) {
// if (this.getClass()==other.getClass()) {
// return this.name.equals(((ObjectType)other).name);
// }
// return false;
// }
// }
//
// Path: src/java/minijava/ast/Type.java
// public abstract class Type extends AST {
//
// @Override
// public abstract boolean equals(Object other);
//
// }
| import minijava.ast.Call;
import minijava.ast.Expression;
import minijava.ast.ObjectType;
import minijava.ast.Type; | package minijava.typechecker;
/**
* A centralised interface to record errors.
*
* @author kdvolder
*/
public class ErrorReport {
private ErrorMessage firstError = null;
public ErrorReport() {}
/**
* Add an error to the ErrorReport.
* <p>
* In this implementation the msg is simply printed to System.out. Also, the first message
* is saved, so it can be verified by unit tests.
*/
void report(ErrorMessage msg) {
if (firstError==null)
firstError = msg;
System.out.println(msg);
}
/**
* To allow processing all of the input (so that as many errors as possible can be
* reported) and raising an error only in the end
* this method is provided. You should call this method when you are done reporting
* errors.
* <p>
* This method will raise an Exception if the error report contains some errors,
* otherwise the method will return normally.
* <p>
* @throws TypeCheckerException
*/
public void close() throws TypeCheckerException {
if (firstError!=null)
throw new TypeCheckerException(firstError);
}
public void duplicateDefinition(String name) {
report(ErrorMessage.duplicateDefinition(name));
}
public void undefinedId(String name) {
report(ErrorMessage.undefinedId(name));
}
public void typeError(Expression exp, Type expected, Type actual) {
report(ErrorMessage.typeError(exp,expected,actual));
}
public void typeErrorExpectObjectType(Expression exp, Type actual) {
report(ErrorMessage.typeErrorExpectObject(exp,actual));
}
public void wrongNumberOfArguments(Call call, int expected) {
report(ErrorMessage.wrongNumberOfArguments(call, expected));
}
| // Path: src/java/minijava/ast/Call.java
// public class Call extends Expression {
//
// public final Expression receiver;
// public final String name;
// public final NodeList<Expression> rands;
//
// public Call(Expression receiver, String name, NodeList<Expression> rands) {
// super();
// this.receiver = receiver;
// this.name = name;
// this.rands = rands;
// }
//
// @Override
// public <R> R accept(Visitor<R> v) {
// return v.visit(this);
// }
//
// }
//
// Path: src/java/minijava/ast/Expression.java
// public abstract class Expression extends AST {
//
// /**
// * The type of an expression is set by the type checking phase.
// */
// public Type type;
//
// public Type getType() {
// Assert.assertNotNull("Was this AST typechecked?", type);
// return type;
// }
//
// public void setType(Type theType) {
// //Assert.assertNull(type);
// //As our visitor is written, we expect the types of some nodes to be set multiple times.
// //as long as there is no conflict in these type settings, there is no problem, and the assertion has been
// //modified to reflect that.
// assert(type==null || type.equals(theType));
// type = theType;
// }
//
// }
//
// Path: src/java/minijava/ast/ObjectType.java
// public class ObjectType extends Type {
//
// public final String name;
//
// public ObjectType(String name) {
// super();
// this.name = name;
// }
//
// @Override
// public <R> R accept(Visitor<R> v) {
// return v.visit(this);
// }
//
// @Override
// public boolean equals(Object other) {
// if (this.getClass()==other.getClass()) {
// return this.name.equals(((ObjectType)other).name);
// }
// return false;
// }
// }
//
// Path: src/java/minijava/ast/Type.java
// public abstract class Type extends AST {
//
// @Override
// public abstract boolean equals(Object other);
//
// }
// Path: src/java/minijava/typechecker/ErrorReport.java
import minijava.ast.Call;
import minijava.ast.Expression;
import minijava.ast.ObjectType;
import minijava.ast.Type;
package minijava.typechecker;
/**
* A centralised interface to record errors.
*
* @author kdvolder
*/
public class ErrorReport {
private ErrorMessage firstError = null;
public ErrorReport() {}
/**
* Add an error to the ErrorReport.
* <p>
* In this implementation the msg is simply printed to System.out. Also, the first message
* is saved, so it can be verified by unit tests.
*/
void report(ErrorMessage msg) {
if (firstError==null)
firstError = msg;
System.out.println(msg);
}
/**
* To allow processing all of the input (so that as many errors as possible can be
* reported) and raising an error only in the end
* this method is provided. You should call this method when you are done reporting
* errors.
* <p>
* This method will raise an Exception if the error report contains some errors,
* otherwise the method will return normally.
* <p>
* @throws TypeCheckerException
*/
public void close() throws TypeCheckerException {
if (firstError!=null)
throw new TypeCheckerException(firstError);
}
public void duplicateDefinition(String name) {
report(ErrorMessage.duplicateDefinition(name));
}
public void undefinedId(String name) {
report(ErrorMessage.undefinedId(name));
}
public void typeError(Expression exp, Type expected, Type actual) {
report(ErrorMessage.typeError(exp,expected,actual));
}
public void typeErrorExpectObjectType(Expression exp, Type actual) {
report(ErrorMessage.typeErrorExpectObject(exp,actual));
}
public void wrongNumberOfArguments(Call call, int expected) {
report(ErrorMessage.wrongNumberOfArguments(call, expected));
}
| public void fieldOverriding(ObjectType cls, String fieldName) { |
mikedouglas/MiniJava | src/java/minijava/typechecker/implementation/MethodEntry.java | // Path: src/java/minijava/ast/Type.java
// public abstract class Type extends AST {
//
// @Override
// public abstract boolean equals(Object other);
//
// }
//
// Path: src/java/minijava/util/ImpTable.java
// public class ImpTable<V> extends DefaultIndentable
// implements Iterable<Entry<String, V>>, Lookup<V>
// {
//
// public static class DuplicateException extends Exception {
//
// private static final long serialVersionUID = 8650830167061316305L;
//
// public DuplicateException(String arg0) {
// super(arg0);
// }
//
// }
//
// private Map<String, V> map = new HashMap<String, V>();
//
// @Override
// public Iterator<Entry<String,V>> iterator() {
// return map.entrySet().iterator();
// }
//
// /**
// * Insert an entry into the table. This modifies the table.
// * Duplicate entries (i.e. with the same id are not supported).
// * When a duplicate id is being entered a DuplicatException is
// * thrown.
// * <p>
// * Note: the name "put" different from the name "insert" in the
// * FunTable is deliberate. This will make sure you get compile
// * errors when you try to change code using imperative puts
// * to use functional inserts instead.
// */
// public void put(String id, V value) throws DuplicateException {
// Assert.assertNotNull(value);
// Assert.assertNotNull(id);
// V existing = map.get(id);
// if (existing!=null) throw new DuplicateException("Duplicate entry: "+id);
// map.put(id, value);
// }
//
// /**
// * Find an entry in the table. If no entry is found, null is returned.
// */
// public V lookup(String id) {
// return map.get(id);
// }
//
// @Override
// public void dump(IndentingWriter out) {
// out.println("Table {");
// out.indent();
// for (Entry<String, V> entry : this) {
// out.print(entry.getKey()+" = ");
// out.println(entry.getValue());
// }
// out.outdent();
// out.print("}");
// }
//
// public boolean isEmpty() {
// return size()==0;
// }
//
// @Override
// public int size() {
// return map.size();
// }
//
// }
//
// Path: src/java/minijava/util/Indentable.java
// public interface Indentable {
//
// void dump(IndentingWriter out);
//
// }
//
// Path: src/java/minijava/util/IndentingWriter.java
// public class IndentingWriter {
//
// /**
// * Current level of indentation.
// */
// private int indentation = 0;
//
// /**
// * This flag is true until we have printed something on a line.
// * We use this to postpone printing of indentation spaces until something is
// * actually printed on a line. This allows indentation level to be changed
// * even after a newline has already been printed.
// * => flag replaced by col field that keeps track of the current column
// */
// private boolean startOfLine = true;
//
// /**
// * Where to send the actual output to.
// */
// private PrintWriter out;
//
// private int col = 0;
//
// public IndentingWriter(PrintWriter out) {
// this.out = out;
// }
//
// public IndentingWriter(Writer out) {
// this(new PrintWriter(out));
// }
//
// public IndentingWriter(OutputStream out) {
// this(new OutputStreamWriter(out));
// }
//
// public IndentingWriter(File out) throws IOException {
// this(new BufferedWriter(new FileWriter(out)));
// }
//
// /**
// * Close the wrapped PrintWriter.
// */
// public void close() {
// out.close();
// }
//
// public void print(String string) {
// if (startOfLine) {
// startOfLine = false;
// for (int i = 0; i < indentation; i++) {
// print(" ");
// }
// }
// out.print(string);
// col += string.length();
// }
// public void println() {
// out.println();
// startOfLine = true;
// col = 0;
// }
//
// /**
// * Write an object to this IndentableWriter. If the object implements
// * Indentable, then that implementation will be used. Otherwise we fall back
// * on the object's toString method.
// */
// public void print(Object obj) {
// if (obj instanceof Indentable) {
// Indentable iObj = (Indentable) obj;
// iObj.dump(this);
// }
// else {
// this.print(""+obj);
// }
// }
//
// public void println(Object obj) {
// print(obj);
// println();
// }
//
// public void indent() {
// indentation++;
// }
// public void outdent() {
// indentation--;
// }
//
// public void tabTo(int toCol) {
// while (col<toCol)
// print(" ");
// }
//
// }
| import java.util.ArrayList;
import java.util.List;
import java.util.Map.Entry;
import minijava.ast.Type;
import minijava.util.ImpTable;
import minijava.util.Indentable;
import minijava.util.IndentingWriter; | package minijava.typechecker.implementation;
public class MethodEntry implements Indentable {
ClassEntry parent;
public ClassEntry getParent() {
return parent;
} | // Path: src/java/minijava/ast/Type.java
// public abstract class Type extends AST {
//
// @Override
// public abstract boolean equals(Object other);
//
// }
//
// Path: src/java/minijava/util/ImpTable.java
// public class ImpTable<V> extends DefaultIndentable
// implements Iterable<Entry<String, V>>, Lookup<V>
// {
//
// public static class DuplicateException extends Exception {
//
// private static final long serialVersionUID = 8650830167061316305L;
//
// public DuplicateException(String arg0) {
// super(arg0);
// }
//
// }
//
// private Map<String, V> map = new HashMap<String, V>();
//
// @Override
// public Iterator<Entry<String,V>> iterator() {
// return map.entrySet().iterator();
// }
//
// /**
// * Insert an entry into the table. This modifies the table.
// * Duplicate entries (i.e. with the same id are not supported).
// * When a duplicate id is being entered a DuplicatException is
// * thrown.
// * <p>
// * Note: the name "put" different from the name "insert" in the
// * FunTable is deliberate. This will make sure you get compile
// * errors when you try to change code using imperative puts
// * to use functional inserts instead.
// */
// public void put(String id, V value) throws DuplicateException {
// Assert.assertNotNull(value);
// Assert.assertNotNull(id);
// V existing = map.get(id);
// if (existing!=null) throw new DuplicateException("Duplicate entry: "+id);
// map.put(id, value);
// }
//
// /**
// * Find an entry in the table. If no entry is found, null is returned.
// */
// public V lookup(String id) {
// return map.get(id);
// }
//
// @Override
// public void dump(IndentingWriter out) {
// out.println("Table {");
// out.indent();
// for (Entry<String, V> entry : this) {
// out.print(entry.getKey()+" = ");
// out.println(entry.getValue());
// }
// out.outdent();
// out.print("}");
// }
//
// public boolean isEmpty() {
// return size()==0;
// }
//
// @Override
// public int size() {
// return map.size();
// }
//
// }
//
// Path: src/java/minijava/util/Indentable.java
// public interface Indentable {
//
// void dump(IndentingWriter out);
//
// }
//
// Path: src/java/minijava/util/IndentingWriter.java
// public class IndentingWriter {
//
// /**
// * Current level of indentation.
// */
// private int indentation = 0;
//
// /**
// * This flag is true until we have printed something on a line.
// * We use this to postpone printing of indentation spaces until something is
// * actually printed on a line. This allows indentation level to be changed
// * even after a newline has already been printed.
// * => flag replaced by col field that keeps track of the current column
// */
// private boolean startOfLine = true;
//
// /**
// * Where to send the actual output to.
// */
// private PrintWriter out;
//
// private int col = 0;
//
// public IndentingWriter(PrintWriter out) {
// this.out = out;
// }
//
// public IndentingWriter(Writer out) {
// this(new PrintWriter(out));
// }
//
// public IndentingWriter(OutputStream out) {
// this(new OutputStreamWriter(out));
// }
//
// public IndentingWriter(File out) throws IOException {
// this(new BufferedWriter(new FileWriter(out)));
// }
//
// /**
// * Close the wrapped PrintWriter.
// */
// public void close() {
// out.close();
// }
//
// public void print(String string) {
// if (startOfLine) {
// startOfLine = false;
// for (int i = 0; i < indentation; i++) {
// print(" ");
// }
// }
// out.print(string);
// col += string.length();
// }
// public void println() {
// out.println();
// startOfLine = true;
// col = 0;
// }
//
// /**
// * Write an object to this IndentableWriter. If the object implements
// * Indentable, then that implementation will be used. Otherwise we fall back
// * on the object's toString method.
// */
// public void print(Object obj) {
// if (obj instanceof Indentable) {
// Indentable iObj = (Indentable) obj;
// iObj.dump(this);
// }
// else {
// this.print(""+obj);
// }
// }
//
// public void println(Object obj) {
// print(obj);
// println();
// }
//
// public void indent() {
// indentation++;
// }
// public void outdent() {
// indentation--;
// }
//
// public void tabTo(int toCol) {
// while (col<toCol)
// print(" ");
// }
//
// }
// Path: src/java/minijava/typechecker/implementation/MethodEntry.java
import java.util.ArrayList;
import java.util.List;
import java.util.Map.Entry;
import minijava.ast.Type;
import minijava.util.ImpTable;
import minijava.util.Indentable;
import minijava.util.IndentingWriter;
package minijava.typechecker.implementation;
public class MethodEntry implements Indentable {
ClassEntry parent;
public ClassEntry getParent() {
return parent;
} | List<Type> paramTypes = new ArrayList<Type>(); |
mikedouglas/MiniJava | src/java/minijava/typechecker/implementation/MethodEntry.java | // Path: src/java/minijava/ast/Type.java
// public abstract class Type extends AST {
//
// @Override
// public abstract boolean equals(Object other);
//
// }
//
// Path: src/java/minijava/util/ImpTable.java
// public class ImpTable<V> extends DefaultIndentable
// implements Iterable<Entry<String, V>>, Lookup<V>
// {
//
// public static class DuplicateException extends Exception {
//
// private static final long serialVersionUID = 8650830167061316305L;
//
// public DuplicateException(String arg0) {
// super(arg0);
// }
//
// }
//
// private Map<String, V> map = new HashMap<String, V>();
//
// @Override
// public Iterator<Entry<String,V>> iterator() {
// return map.entrySet().iterator();
// }
//
// /**
// * Insert an entry into the table. This modifies the table.
// * Duplicate entries (i.e. with the same id are not supported).
// * When a duplicate id is being entered a DuplicatException is
// * thrown.
// * <p>
// * Note: the name "put" different from the name "insert" in the
// * FunTable is deliberate. This will make sure you get compile
// * errors when you try to change code using imperative puts
// * to use functional inserts instead.
// */
// public void put(String id, V value) throws DuplicateException {
// Assert.assertNotNull(value);
// Assert.assertNotNull(id);
// V existing = map.get(id);
// if (existing!=null) throw new DuplicateException("Duplicate entry: "+id);
// map.put(id, value);
// }
//
// /**
// * Find an entry in the table. If no entry is found, null is returned.
// */
// public V lookup(String id) {
// return map.get(id);
// }
//
// @Override
// public void dump(IndentingWriter out) {
// out.println("Table {");
// out.indent();
// for (Entry<String, V> entry : this) {
// out.print(entry.getKey()+" = ");
// out.println(entry.getValue());
// }
// out.outdent();
// out.print("}");
// }
//
// public boolean isEmpty() {
// return size()==0;
// }
//
// @Override
// public int size() {
// return map.size();
// }
//
// }
//
// Path: src/java/minijava/util/Indentable.java
// public interface Indentable {
//
// void dump(IndentingWriter out);
//
// }
//
// Path: src/java/minijava/util/IndentingWriter.java
// public class IndentingWriter {
//
// /**
// * Current level of indentation.
// */
// private int indentation = 0;
//
// /**
// * This flag is true until we have printed something on a line.
// * We use this to postpone printing of indentation spaces until something is
// * actually printed on a line. This allows indentation level to be changed
// * even after a newline has already been printed.
// * => flag replaced by col field that keeps track of the current column
// */
// private boolean startOfLine = true;
//
// /**
// * Where to send the actual output to.
// */
// private PrintWriter out;
//
// private int col = 0;
//
// public IndentingWriter(PrintWriter out) {
// this.out = out;
// }
//
// public IndentingWriter(Writer out) {
// this(new PrintWriter(out));
// }
//
// public IndentingWriter(OutputStream out) {
// this(new OutputStreamWriter(out));
// }
//
// public IndentingWriter(File out) throws IOException {
// this(new BufferedWriter(new FileWriter(out)));
// }
//
// /**
// * Close the wrapped PrintWriter.
// */
// public void close() {
// out.close();
// }
//
// public void print(String string) {
// if (startOfLine) {
// startOfLine = false;
// for (int i = 0; i < indentation; i++) {
// print(" ");
// }
// }
// out.print(string);
// col += string.length();
// }
// public void println() {
// out.println();
// startOfLine = true;
// col = 0;
// }
//
// /**
// * Write an object to this IndentableWriter. If the object implements
// * Indentable, then that implementation will be used. Otherwise we fall back
// * on the object's toString method.
// */
// public void print(Object obj) {
// if (obj instanceof Indentable) {
// Indentable iObj = (Indentable) obj;
// iObj.dump(this);
// }
// else {
// this.print(""+obj);
// }
// }
//
// public void println(Object obj) {
// print(obj);
// println();
// }
//
// public void indent() {
// indentation++;
// }
// public void outdent() {
// indentation--;
// }
//
// public void tabTo(int toCol) {
// while (col<toCol)
// print(" ");
// }
//
// }
| import java.util.ArrayList;
import java.util.List;
import java.util.Map.Entry;
import minijava.ast.Type;
import minijava.util.ImpTable;
import minijava.util.Indentable;
import minijava.util.IndentingWriter; | package minijava.typechecker.implementation;
public class MethodEntry implements Indentable {
ClassEntry parent;
public ClassEntry getParent() {
return parent;
}
List<Type> paramTypes = new ArrayList<Type>(); | // Path: src/java/minijava/ast/Type.java
// public abstract class Type extends AST {
//
// @Override
// public abstract boolean equals(Object other);
//
// }
//
// Path: src/java/minijava/util/ImpTable.java
// public class ImpTable<V> extends DefaultIndentable
// implements Iterable<Entry<String, V>>, Lookup<V>
// {
//
// public static class DuplicateException extends Exception {
//
// private static final long serialVersionUID = 8650830167061316305L;
//
// public DuplicateException(String arg0) {
// super(arg0);
// }
//
// }
//
// private Map<String, V> map = new HashMap<String, V>();
//
// @Override
// public Iterator<Entry<String,V>> iterator() {
// return map.entrySet().iterator();
// }
//
// /**
// * Insert an entry into the table. This modifies the table.
// * Duplicate entries (i.e. with the same id are not supported).
// * When a duplicate id is being entered a DuplicatException is
// * thrown.
// * <p>
// * Note: the name "put" different from the name "insert" in the
// * FunTable is deliberate. This will make sure you get compile
// * errors when you try to change code using imperative puts
// * to use functional inserts instead.
// */
// public void put(String id, V value) throws DuplicateException {
// Assert.assertNotNull(value);
// Assert.assertNotNull(id);
// V existing = map.get(id);
// if (existing!=null) throw new DuplicateException("Duplicate entry: "+id);
// map.put(id, value);
// }
//
// /**
// * Find an entry in the table. If no entry is found, null is returned.
// */
// public V lookup(String id) {
// return map.get(id);
// }
//
// @Override
// public void dump(IndentingWriter out) {
// out.println("Table {");
// out.indent();
// for (Entry<String, V> entry : this) {
// out.print(entry.getKey()+" = ");
// out.println(entry.getValue());
// }
// out.outdent();
// out.print("}");
// }
//
// public boolean isEmpty() {
// return size()==0;
// }
//
// @Override
// public int size() {
// return map.size();
// }
//
// }
//
// Path: src/java/minijava/util/Indentable.java
// public interface Indentable {
//
// void dump(IndentingWriter out);
//
// }
//
// Path: src/java/minijava/util/IndentingWriter.java
// public class IndentingWriter {
//
// /**
// * Current level of indentation.
// */
// private int indentation = 0;
//
// /**
// * This flag is true until we have printed something on a line.
// * We use this to postpone printing of indentation spaces until something is
// * actually printed on a line. This allows indentation level to be changed
// * even after a newline has already been printed.
// * => flag replaced by col field that keeps track of the current column
// */
// private boolean startOfLine = true;
//
// /**
// * Where to send the actual output to.
// */
// private PrintWriter out;
//
// private int col = 0;
//
// public IndentingWriter(PrintWriter out) {
// this.out = out;
// }
//
// public IndentingWriter(Writer out) {
// this(new PrintWriter(out));
// }
//
// public IndentingWriter(OutputStream out) {
// this(new OutputStreamWriter(out));
// }
//
// public IndentingWriter(File out) throws IOException {
// this(new BufferedWriter(new FileWriter(out)));
// }
//
// /**
// * Close the wrapped PrintWriter.
// */
// public void close() {
// out.close();
// }
//
// public void print(String string) {
// if (startOfLine) {
// startOfLine = false;
// for (int i = 0; i < indentation; i++) {
// print(" ");
// }
// }
// out.print(string);
// col += string.length();
// }
// public void println() {
// out.println();
// startOfLine = true;
// col = 0;
// }
//
// /**
// * Write an object to this IndentableWriter. If the object implements
// * Indentable, then that implementation will be used. Otherwise we fall back
// * on the object's toString method.
// */
// public void print(Object obj) {
// if (obj instanceof Indentable) {
// Indentable iObj = (Indentable) obj;
// iObj.dump(this);
// }
// else {
// this.print(""+obj);
// }
// }
//
// public void println(Object obj) {
// print(obj);
// println();
// }
//
// public void indent() {
// indentation++;
// }
// public void outdent() {
// indentation--;
// }
//
// public void tabTo(int toCol) {
// while (col<toCol)
// print(" ");
// }
//
// }
// Path: src/java/minijava/typechecker/implementation/MethodEntry.java
import java.util.ArrayList;
import java.util.List;
import java.util.Map.Entry;
import minijava.ast.Type;
import minijava.util.ImpTable;
import minijava.util.Indentable;
import minijava.util.IndentingWriter;
package minijava.typechecker.implementation;
public class MethodEntry implements Indentable {
ClassEntry parent;
public ClassEntry getParent() {
return parent;
}
List<Type> paramTypes = new ArrayList<Type>(); | ImpTable<Type> variables; |
mikedouglas/MiniJava | src/java/minijava/ast/Minus.java | // Path: src/java/minijava/visitor/Visitor.java
// public interface Visitor<R> {
//
// //Lists
// public <T extends AST> R visit(NodeList<T> ns);
//
// //Declarations
// public R visit(Program n);
// public R visit(MainClass n);
// public R visit(ClassDecl n);
// public R visit(VarDecl n);
// public R visit(MethodDecl n);
//
// //Types
// public R visit(IntArrayType n);
// public R visit(BooleanType n);
// public R visit(IntegerType n);
// public R visit(ObjectType n);
//
// //Statements
// public R visit(Block n);
// public R visit(If n);
// public R visit(While n);
// public R visit(Print n);
// public R visit(Assign n);
// public R visit(ArrayAssign n);
//
// //Expressions
// public R visit(And n);
// public R visit(LessThan n);
// public R visit(Plus n);
// public R visit(Minus n);
// public R visit(Times n);
// public R visit(ArrayLookup n);
// public R visit(ArrayLength n);
// public R visit(Call n);
// public R visit(IntegerLiteral n);
// public R visit(BooleanLiteral n);
// public R visit(IdentifierExp n);
// public R visit(This n);
// public R visit(NewArray n);
// public R visit(NewObject n);
// public R visit(Not not);
//
// }
| import minijava.visitor.Visitor; | package minijava.ast;
public class Minus extends Expression {
public final Expression e1;
public final Expression e2;
public Minus(Expression e1, Expression e2) {
super();
super.setType(IntegerType.instance);
this.e1 = e1;
this.e2 = e2;
}
@Override | // Path: src/java/minijava/visitor/Visitor.java
// public interface Visitor<R> {
//
// //Lists
// public <T extends AST> R visit(NodeList<T> ns);
//
// //Declarations
// public R visit(Program n);
// public R visit(MainClass n);
// public R visit(ClassDecl n);
// public R visit(VarDecl n);
// public R visit(MethodDecl n);
//
// //Types
// public R visit(IntArrayType n);
// public R visit(BooleanType n);
// public R visit(IntegerType n);
// public R visit(ObjectType n);
//
// //Statements
// public R visit(Block n);
// public R visit(If n);
// public R visit(While n);
// public R visit(Print n);
// public R visit(Assign n);
// public R visit(ArrayAssign n);
//
// //Expressions
// public R visit(And n);
// public R visit(LessThan n);
// public R visit(Plus n);
// public R visit(Minus n);
// public R visit(Times n);
// public R visit(ArrayLookup n);
// public R visit(ArrayLength n);
// public R visit(Call n);
// public R visit(IntegerLiteral n);
// public R visit(BooleanLiteral n);
// public R visit(IdentifierExp n);
// public R visit(This n);
// public R visit(NewArray n);
// public R visit(NewObject n);
// public R visit(Not not);
//
// }
// Path: src/java/minijava/ast/Minus.java
import minijava.visitor.Visitor;
package minijava.ast;
public class Minus extends Expression {
public final Expression e1;
public final Expression e2;
public Minus(Expression e1, Expression e2) {
super();
super.setType(IntegerType.instance);
this.e1 = e1;
this.e2 = e2;
}
@Override | public <R> R accept(Visitor<R> v) { |
mikedouglas/MiniJava | src/java/minijava/test/parser/Test3Parse.java | // Path: src/java/minijava/parser/MiniJavaParser.java
// public class MiniJavaParser {
//
// /**
// * Read input from a File and parse it into an AST representation.
// */
// public static Program parse(File file) throws IOException, ParseException {
// FileReader input = new FileReader(file);
// try {
// return parse(input);
// }
// finally { //No matter what happens, always close the file!
// input.close();
// }
// }
//
// /**
// * Read input from a java.io.Reader and parse it into an AST. It is the
// * caller's responsibility to close the Reader.
// */
// private static Program parse(Reader input) throws ParseException {
// JCCMiniJavaParser parser = new JCCMiniJavaParser(input);
// return parser.Program();
// }
//
// /**
// * Read input directly from a String and parse it into an AST.
// */
// public static Program parse(String inputText) throws ParseException {
// return parse(new StringReader(inputText));
// }
//
// /**
// * Normally we don't need to parse just expressions by themselves. But this
// * is a convenience method, used by the unit tests for creating error messages.
// * @throws ParseException
// */
// public static Expression parseExp(String exp) throws ParseException {
// JCCMiniJavaParser parser = new JCCMiniJavaParser(new StringReader(exp));
// return parser.Expression();
// }
// /**
// * Pretty print an AST node and return the result as a String.
// */
// public static String unparse(AST node) {
// return node.toString();
// // This assumes that toString on AST nodes is appropriately implemented.
// // If you decided to generate/implement your own AST classes rather than use
// // the ones we provided for you, you may need to implement this unparse method
// // differently.
// }
//
// }
//
// Path: src/java/minijava/test/SampleCode.java
// public class SampleCode {
//
// /**
// * Points to a directory containing sample java code to parse.
// */
// public final static File sample_dir = new File("resources/sample");
//
// /**
// * Filter for selecting Java files only.
// */
// private static final FilenameFilter javaFileFilter = new FilenameFilter() {
// @Override
// public boolean accept(File dir, String name) {
// return name.endsWith(".java");
// }
// };
//
// /**
// * @return An array of sample MiniJava files.
// */
// public static File[] sampleFiles() {
// File[] files = sample_dir.listFiles(javaFileFilter);
// // Should sort the array to ensure that we produce the files in the same order
// // independent of the order in which the OS produces them.
// Arrays.sort(files);
// return files;
// }
//
// }
| import java.io.File;
import minijava.parser.MiniJavaParser;
import minijava.test.SampleCode;
import org.junit.Test; | package minijava.test.parser;
/**
* The tests in this class correspond more or less to the work in Chapter 3.
* <p>
* These tests try to call your parser to parse MiniJava programs, but they do
* not check the AST produced by the parser. As such you should be able to get
* these tests to pass without inserting any semantic actions into your
* parser specification file.
* <p>
* The tests in this file are written in an order that can be followed if
* you want to develop your parser incrementally, staring with the tests at the
* top of the file, and working your way down.
*
* @author kdvolder
*/
public class Test3Parse {
/**
* All testing is supposed to go through calling this method to one of the
* accept methods, to see whether some input is accepted by the parser. The subclass
* Test4Parse refines these tests by overriding this accept method to also verify the
* parse tree structure.
*/
protected void accept(String input) throws Exception { | // Path: src/java/minijava/parser/MiniJavaParser.java
// public class MiniJavaParser {
//
// /**
// * Read input from a File and parse it into an AST representation.
// */
// public static Program parse(File file) throws IOException, ParseException {
// FileReader input = new FileReader(file);
// try {
// return parse(input);
// }
// finally { //No matter what happens, always close the file!
// input.close();
// }
// }
//
// /**
// * Read input from a java.io.Reader and parse it into an AST. It is the
// * caller's responsibility to close the Reader.
// */
// private static Program parse(Reader input) throws ParseException {
// JCCMiniJavaParser parser = new JCCMiniJavaParser(input);
// return parser.Program();
// }
//
// /**
// * Read input directly from a String and parse it into an AST.
// */
// public static Program parse(String inputText) throws ParseException {
// return parse(new StringReader(inputText));
// }
//
// /**
// * Normally we don't need to parse just expressions by themselves. But this
// * is a convenience method, used by the unit tests for creating error messages.
// * @throws ParseException
// */
// public static Expression parseExp(String exp) throws ParseException {
// JCCMiniJavaParser parser = new JCCMiniJavaParser(new StringReader(exp));
// return parser.Expression();
// }
// /**
// * Pretty print an AST node and return the result as a String.
// */
// public static String unparse(AST node) {
// return node.toString();
// // This assumes that toString on AST nodes is appropriately implemented.
// // If you decided to generate/implement your own AST classes rather than use
// // the ones we provided for you, you may need to implement this unparse method
// // differently.
// }
//
// }
//
// Path: src/java/minijava/test/SampleCode.java
// public class SampleCode {
//
// /**
// * Points to a directory containing sample java code to parse.
// */
// public final static File sample_dir = new File("resources/sample");
//
// /**
// * Filter for selecting Java files only.
// */
// private static final FilenameFilter javaFileFilter = new FilenameFilter() {
// @Override
// public boolean accept(File dir, String name) {
// return name.endsWith(".java");
// }
// };
//
// /**
// * @return An array of sample MiniJava files.
// */
// public static File[] sampleFiles() {
// File[] files = sample_dir.listFiles(javaFileFilter);
// // Should sort the array to ensure that we produce the files in the same order
// // independent of the order in which the OS produces them.
// Arrays.sort(files);
// return files;
// }
//
// }
// Path: src/java/minijava/test/parser/Test3Parse.java
import java.io.File;
import minijava.parser.MiniJavaParser;
import minijava.test.SampleCode;
import org.junit.Test;
package minijava.test.parser;
/**
* The tests in this class correspond more or less to the work in Chapter 3.
* <p>
* These tests try to call your parser to parse MiniJava programs, but they do
* not check the AST produced by the parser. As such you should be able to get
* these tests to pass without inserting any semantic actions into your
* parser specification file.
* <p>
* The tests in this file are written in an order that can be followed if
* you want to develop your parser incrementally, staring with the tests at the
* top of the file, and working your way down.
*
* @author kdvolder
*/
public class Test3Parse {
/**
* All testing is supposed to go through calling this method to one of the
* accept methods, to see whether some input is accepted by the parser. The subclass
* Test4Parse refines these tests by overriding this accept method to also verify the
* parse tree structure.
*/
protected void accept(String input) throws Exception { | MiniJavaParser.parse(input); |
mikedouglas/MiniJava | src/java/minijava/test/parser/Test3Parse.java | // Path: src/java/minijava/parser/MiniJavaParser.java
// public class MiniJavaParser {
//
// /**
// * Read input from a File and parse it into an AST representation.
// */
// public static Program parse(File file) throws IOException, ParseException {
// FileReader input = new FileReader(file);
// try {
// return parse(input);
// }
// finally { //No matter what happens, always close the file!
// input.close();
// }
// }
//
// /**
// * Read input from a java.io.Reader and parse it into an AST. It is the
// * caller's responsibility to close the Reader.
// */
// private static Program parse(Reader input) throws ParseException {
// JCCMiniJavaParser parser = new JCCMiniJavaParser(input);
// return parser.Program();
// }
//
// /**
// * Read input directly from a String and parse it into an AST.
// */
// public static Program parse(String inputText) throws ParseException {
// return parse(new StringReader(inputText));
// }
//
// /**
// * Normally we don't need to parse just expressions by themselves. But this
// * is a convenience method, used by the unit tests for creating error messages.
// * @throws ParseException
// */
// public static Expression parseExp(String exp) throws ParseException {
// JCCMiniJavaParser parser = new JCCMiniJavaParser(new StringReader(exp));
// return parser.Expression();
// }
// /**
// * Pretty print an AST node and return the result as a String.
// */
// public static String unparse(AST node) {
// return node.toString();
// // This assumes that toString on AST nodes is appropriately implemented.
// // If you decided to generate/implement your own AST classes rather than use
// // the ones we provided for you, you may need to implement this unparse method
// // differently.
// }
//
// }
//
// Path: src/java/minijava/test/SampleCode.java
// public class SampleCode {
//
// /**
// * Points to a directory containing sample java code to parse.
// */
// public final static File sample_dir = new File("resources/sample");
//
// /**
// * Filter for selecting Java files only.
// */
// private static final FilenameFilter javaFileFilter = new FilenameFilter() {
// @Override
// public boolean accept(File dir, String name) {
// return name.endsWith(".java");
// }
// };
//
// /**
// * @return An array of sample MiniJava files.
// */
// public static File[] sampleFiles() {
// File[] files = sample_dir.listFiles(javaFileFilter);
// // Should sort the array to ensure that we produce the files in the same order
// // independent of the order in which the OS produces them.
// Arrays.sort(files);
// return files;
// }
//
// }
| import java.io.File;
import minijava.parser.MiniJavaParser;
import minijava.test.SampleCode;
import org.junit.Test; | acceptClass(
"class Point {\n" +
" int x;\n" +
" int y;\n" +
" public int getX() {\n" +
" return x;" +
" }" +
" public int getY() {\n" +
" return y;" +
" }" +
"}");
acceptClass(
"class Foo {\n" +
" public int params(int i, int[] nums, Foo foo) {\n" +
" Bar bar;\n" +
" int local;\n" +
" local = nums.length;\n" +
" if (i < local)\n" +
" local = nums[i];\n" +
" else" +
" local = 0;\n" +
" return local;" +
" }" +
"}");
}
/////////////////////////////////////////////////////////////////////////////////
// Finally, check whether the parser accepts all the book's sample code.
@Test
public void testParseSampleCode() throws Exception { | // Path: src/java/minijava/parser/MiniJavaParser.java
// public class MiniJavaParser {
//
// /**
// * Read input from a File and parse it into an AST representation.
// */
// public static Program parse(File file) throws IOException, ParseException {
// FileReader input = new FileReader(file);
// try {
// return parse(input);
// }
// finally { //No matter what happens, always close the file!
// input.close();
// }
// }
//
// /**
// * Read input from a java.io.Reader and parse it into an AST. It is the
// * caller's responsibility to close the Reader.
// */
// private static Program parse(Reader input) throws ParseException {
// JCCMiniJavaParser parser = new JCCMiniJavaParser(input);
// return parser.Program();
// }
//
// /**
// * Read input directly from a String and parse it into an AST.
// */
// public static Program parse(String inputText) throws ParseException {
// return parse(new StringReader(inputText));
// }
//
// /**
// * Normally we don't need to parse just expressions by themselves. But this
// * is a convenience method, used by the unit tests for creating error messages.
// * @throws ParseException
// */
// public static Expression parseExp(String exp) throws ParseException {
// JCCMiniJavaParser parser = new JCCMiniJavaParser(new StringReader(exp));
// return parser.Expression();
// }
// /**
// * Pretty print an AST node and return the result as a String.
// */
// public static String unparse(AST node) {
// return node.toString();
// // This assumes that toString on AST nodes is appropriately implemented.
// // If you decided to generate/implement your own AST classes rather than use
// // the ones we provided for you, you may need to implement this unparse method
// // differently.
// }
//
// }
//
// Path: src/java/minijava/test/SampleCode.java
// public class SampleCode {
//
// /**
// * Points to a directory containing sample java code to parse.
// */
// public final static File sample_dir = new File("resources/sample");
//
// /**
// * Filter for selecting Java files only.
// */
// private static final FilenameFilter javaFileFilter = new FilenameFilter() {
// @Override
// public boolean accept(File dir, String name) {
// return name.endsWith(".java");
// }
// };
//
// /**
// * @return An array of sample MiniJava files.
// */
// public static File[] sampleFiles() {
// File[] files = sample_dir.listFiles(javaFileFilter);
// // Should sort the array to ensure that we produce the files in the same order
// // independent of the order in which the OS produces them.
// Arrays.sort(files);
// return files;
// }
//
// }
// Path: src/java/minijava/test/parser/Test3Parse.java
import java.io.File;
import minijava.parser.MiniJavaParser;
import minijava.test.SampleCode;
import org.junit.Test;
acceptClass(
"class Point {\n" +
" int x;\n" +
" int y;\n" +
" public int getX() {\n" +
" return x;" +
" }" +
" public int getY() {\n" +
" return y;" +
" }" +
"}");
acceptClass(
"class Foo {\n" +
" public int params(int i, int[] nums, Foo foo) {\n" +
" Bar bar;\n" +
" int local;\n" +
" local = nums.length;\n" +
" if (i < local)\n" +
" local = nums[i];\n" +
" else" +
" local = 0;\n" +
" return local;" +
" }" +
"}");
}
/////////////////////////////////////////////////////////////////////////////////
// Finally, check whether the parser accepts all the book's sample code.
@Test
public void testParseSampleCode() throws Exception { | File[] files = SampleCode.sampleFiles(); |
mikedouglas/MiniJava | src/java/minijava/parser/MiniJavaParser.java | // Path: src/java/minijava/ast/AST.java
// public abstract class AST {
//
// public abstract <R> R accept(Visitor<R> v);
//
// @Override
// public String toString() {
// StringWriter out = new StringWriter();
// this.accept(new PrettyPrintVisitor(new PrintWriter(out)));
// return out.toString();
// }
//
// }
//
// Path: src/java/minijava/ast/Expression.java
// public abstract class Expression extends AST {
//
// /**
// * The type of an expression is set by the type checking phase.
// */
// public Type type;
//
// public Type getType() {
// Assert.assertNotNull("Was this AST typechecked?", type);
// return type;
// }
//
// public void setType(Type theType) {
// //Assert.assertNull(type);
// //As our visitor is written, we expect the types of some nodes to be set multiple times.
// //as long as there is no conflict in these type settings, there is no problem, and the assertion has been
// //modified to reflect that.
// assert(type==null || type.equals(theType));
// type = theType;
// }
//
// }
//
// Path: src/java/minijava/ast/Program.java
// public class Program extends AST {
//
// public final MainClass mainClass;
// public final NodeList<ClassDecl> classes;
//
// public Program(MainClass mainClass, NodeList<ClassDecl> otherClasses) {
// this.mainClass=mainClass;
// this.classes=otherClasses;
// }
//
// public Program(MainClass m, List<ClassDecl> cs) {
// this(m, new NodeList<ClassDecl>(cs));
// }
//
// public <R> R accept(Visitor<R> v) {
// return v.visit(this);
// }
//
// }
| import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.io.Reader;
import java.io.StringReader;
import minijava.ast.AST;
import minijava.ast.Expression;
import minijava.ast.Program;
import minijava.parser.jcc.JCCMiniJavaParser;
import minijava.parser.jcc.ParseException; | package minijava.parser;
/**
* Instead of calling methods in the JavaCC (or maybe SableCC) generated
* parser directly. We use this class as a kind of Stub class to isolate us from
* direct dependency on the generated parser.
* <p>
* In theory this means you should be able to replace the parser
* with another implementation by editing these methods, and without
* changing the main implementation for the rest of the compiler.
* <p>
* It also has the benefit of not mixing in utility methods with
* the generated code. We can put different methods for calling the parser
* (with a file, an inputstream, a String ect. in here).
* <p>
* Note: Actually, there is a dependency on the ParseException class generated
* by JavaCC. To really get "plugability" we should not have this dependency.
*
* @author kdvolder
*/
public class MiniJavaParser {
/**
* Read input from a File and parse it into an AST representation.
*/
public static Program parse(File file) throws IOException, ParseException {
FileReader input = new FileReader(file);
try {
return parse(input);
}
finally { //No matter what happens, always close the file!
input.close();
}
}
/**
* Read input from a java.io.Reader and parse it into an AST. It is the
* caller's responsibility to close the Reader.
*/
private static Program parse(Reader input) throws ParseException {
JCCMiniJavaParser parser = new JCCMiniJavaParser(input);
return parser.Program();
}
/**
* Read input directly from a String and parse it into an AST.
*/
public static Program parse(String inputText) throws ParseException {
return parse(new StringReader(inputText));
}
/**
* Normally we don't need to parse just expressions by themselves. But this
* is a convenience method, used by the unit tests for creating error messages.
* @throws ParseException
*/ | // Path: src/java/minijava/ast/AST.java
// public abstract class AST {
//
// public abstract <R> R accept(Visitor<R> v);
//
// @Override
// public String toString() {
// StringWriter out = new StringWriter();
// this.accept(new PrettyPrintVisitor(new PrintWriter(out)));
// return out.toString();
// }
//
// }
//
// Path: src/java/minijava/ast/Expression.java
// public abstract class Expression extends AST {
//
// /**
// * The type of an expression is set by the type checking phase.
// */
// public Type type;
//
// public Type getType() {
// Assert.assertNotNull("Was this AST typechecked?", type);
// return type;
// }
//
// public void setType(Type theType) {
// //Assert.assertNull(type);
// //As our visitor is written, we expect the types of some nodes to be set multiple times.
// //as long as there is no conflict in these type settings, there is no problem, and the assertion has been
// //modified to reflect that.
// assert(type==null || type.equals(theType));
// type = theType;
// }
//
// }
//
// Path: src/java/minijava/ast/Program.java
// public class Program extends AST {
//
// public final MainClass mainClass;
// public final NodeList<ClassDecl> classes;
//
// public Program(MainClass mainClass, NodeList<ClassDecl> otherClasses) {
// this.mainClass=mainClass;
// this.classes=otherClasses;
// }
//
// public Program(MainClass m, List<ClassDecl> cs) {
// this(m, new NodeList<ClassDecl>(cs));
// }
//
// public <R> R accept(Visitor<R> v) {
// return v.visit(this);
// }
//
// }
// Path: src/java/minijava/parser/MiniJavaParser.java
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.io.Reader;
import java.io.StringReader;
import minijava.ast.AST;
import minijava.ast.Expression;
import minijava.ast.Program;
import minijava.parser.jcc.JCCMiniJavaParser;
import minijava.parser.jcc.ParseException;
package minijava.parser;
/**
* Instead of calling methods in the JavaCC (or maybe SableCC) generated
* parser directly. We use this class as a kind of Stub class to isolate us from
* direct dependency on the generated parser.
* <p>
* In theory this means you should be able to replace the parser
* with another implementation by editing these methods, and without
* changing the main implementation for the rest of the compiler.
* <p>
* It also has the benefit of not mixing in utility methods with
* the generated code. We can put different methods for calling the parser
* (with a file, an inputstream, a String ect. in here).
* <p>
* Note: Actually, there is a dependency on the ParseException class generated
* by JavaCC. To really get "plugability" we should not have this dependency.
*
* @author kdvolder
*/
public class MiniJavaParser {
/**
* Read input from a File and parse it into an AST representation.
*/
public static Program parse(File file) throws IOException, ParseException {
FileReader input = new FileReader(file);
try {
return parse(input);
}
finally { //No matter what happens, always close the file!
input.close();
}
}
/**
* Read input from a java.io.Reader and parse it into an AST. It is the
* caller's responsibility to close the Reader.
*/
private static Program parse(Reader input) throws ParseException {
JCCMiniJavaParser parser = new JCCMiniJavaParser(input);
return parser.Program();
}
/**
* Read input directly from a String and parse it into an AST.
*/
public static Program parse(String inputText) throws ParseException {
return parse(new StringReader(inputText));
}
/**
* Normally we don't need to parse just expressions by themselves. But this
* is a convenience method, used by the unit tests for creating error messages.
* @throws ParseException
*/ | public static Expression parseExp(String exp) throws ParseException { |
mikedouglas/MiniJava | src/java/minijava/parser/MiniJavaParser.java | // Path: src/java/minijava/ast/AST.java
// public abstract class AST {
//
// public abstract <R> R accept(Visitor<R> v);
//
// @Override
// public String toString() {
// StringWriter out = new StringWriter();
// this.accept(new PrettyPrintVisitor(new PrintWriter(out)));
// return out.toString();
// }
//
// }
//
// Path: src/java/minijava/ast/Expression.java
// public abstract class Expression extends AST {
//
// /**
// * The type of an expression is set by the type checking phase.
// */
// public Type type;
//
// public Type getType() {
// Assert.assertNotNull("Was this AST typechecked?", type);
// return type;
// }
//
// public void setType(Type theType) {
// //Assert.assertNull(type);
// //As our visitor is written, we expect the types of some nodes to be set multiple times.
// //as long as there is no conflict in these type settings, there is no problem, and the assertion has been
// //modified to reflect that.
// assert(type==null || type.equals(theType));
// type = theType;
// }
//
// }
//
// Path: src/java/minijava/ast/Program.java
// public class Program extends AST {
//
// public final MainClass mainClass;
// public final NodeList<ClassDecl> classes;
//
// public Program(MainClass mainClass, NodeList<ClassDecl> otherClasses) {
// this.mainClass=mainClass;
// this.classes=otherClasses;
// }
//
// public Program(MainClass m, List<ClassDecl> cs) {
// this(m, new NodeList<ClassDecl>(cs));
// }
//
// public <R> R accept(Visitor<R> v) {
// return v.visit(this);
// }
//
// }
| import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.io.Reader;
import java.io.StringReader;
import minijava.ast.AST;
import minijava.ast.Expression;
import minijava.ast.Program;
import minijava.parser.jcc.JCCMiniJavaParser;
import minijava.parser.jcc.ParseException; | package minijava.parser;
/**
* Instead of calling methods in the JavaCC (or maybe SableCC) generated
* parser directly. We use this class as a kind of Stub class to isolate us from
* direct dependency on the generated parser.
* <p>
* In theory this means you should be able to replace the parser
* with another implementation by editing these methods, and without
* changing the main implementation for the rest of the compiler.
* <p>
* It also has the benefit of not mixing in utility methods with
* the generated code. We can put different methods for calling the parser
* (with a file, an inputstream, a String ect. in here).
* <p>
* Note: Actually, there is a dependency on the ParseException class generated
* by JavaCC. To really get "plugability" we should not have this dependency.
*
* @author kdvolder
*/
public class MiniJavaParser {
/**
* Read input from a File and parse it into an AST representation.
*/
public static Program parse(File file) throws IOException, ParseException {
FileReader input = new FileReader(file);
try {
return parse(input);
}
finally { //No matter what happens, always close the file!
input.close();
}
}
/**
* Read input from a java.io.Reader and parse it into an AST. It is the
* caller's responsibility to close the Reader.
*/
private static Program parse(Reader input) throws ParseException {
JCCMiniJavaParser parser = new JCCMiniJavaParser(input);
return parser.Program();
}
/**
* Read input directly from a String and parse it into an AST.
*/
public static Program parse(String inputText) throws ParseException {
return parse(new StringReader(inputText));
}
/**
* Normally we don't need to parse just expressions by themselves. But this
* is a convenience method, used by the unit tests for creating error messages.
* @throws ParseException
*/
public static Expression parseExp(String exp) throws ParseException {
JCCMiniJavaParser parser = new JCCMiniJavaParser(new StringReader(exp));
return parser.Expression();
}
/**
* Pretty print an AST node and return the result as a String.
*/ | // Path: src/java/minijava/ast/AST.java
// public abstract class AST {
//
// public abstract <R> R accept(Visitor<R> v);
//
// @Override
// public String toString() {
// StringWriter out = new StringWriter();
// this.accept(new PrettyPrintVisitor(new PrintWriter(out)));
// return out.toString();
// }
//
// }
//
// Path: src/java/minijava/ast/Expression.java
// public abstract class Expression extends AST {
//
// /**
// * The type of an expression is set by the type checking phase.
// */
// public Type type;
//
// public Type getType() {
// Assert.assertNotNull("Was this AST typechecked?", type);
// return type;
// }
//
// public void setType(Type theType) {
// //Assert.assertNull(type);
// //As our visitor is written, we expect the types of some nodes to be set multiple times.
// //as long as there is no conflict in these type settings, there is no problem, and the assertion has been
// //modified to reflect that.
// assert(type==null || type.equals(theType));
// type = theType;
// }
//
// }
//
// Path: src/java/minijava/ast/Program.java
// public class Program extends AST {
//
// public final MainClass mainClass;
// public final NodeList<ClassDecl> classes;
//
// public Program(MainClass mainClass, NodeList<ClassDecl> otherClasses) {
// this.mainClass=mainClass;
// this.classes=otherClasses;
// }
//
// public Program(MainClass m, List<ClassDecl> cs) {
// this(m, new NodeList<ClassDecl>(cs));
// }
//
// public <R> R accept(Visitor<R> v) {
// return v.visit(this);
// }
//
// }
// Path: src/java/minijava/parser/MiniJavaParser.java
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.io.Reader;
import java.io.StringReader;
import minijava.ast.AST;
import minijava.ast.Expression;
import minijava.ast.Program;
import minijava.parser.jcc.JCCMiniJavaParser;
import minijava.parser.jcc.ParseException;
package minijava.parser;
/**
* Instead of calling methods in the JavaCC (or maybe SableCC) generated
* parser directly. We use this class as a kind of Stub class to isolate us from
* direct dependency on the generated parser.
* <p>
* In theory this means you should be able to replace the parser
* with another implementation by editing these methods, and without
* changing the main implementation for the rest of the compiler.
* <p>
* It also has the benefit of not mixing in utility methods with
* the generated code. We can put different methods for calling the parser
* (with a file, an inputstream, a String ect. in here).
* <p>
* Note: Actually, there is a dependency on the ParseException class generated
* by JavaCC. To really get "plugability" we should not have this dependency.
*
* @author kdvolder
*/
public class MiniJavaParser {
/**
* Read input from a File and parse it into an AST representation.
*/
public static Program parse(File file) throws IOException, ParseException {
FileReader input = new FileReader(file);
try {
return parse(input);
}
finally { //No matter what happens, always close the file!
input.close();
}
}
/**
* Read input from a java.io.Reader and parse it into an AST. It is the
* caller's responsibility to close the Reader.
*/
private static Program parse(Reader input) throws ParseException {
JCCMiniJavaParser parser = new JCCMiniJavaParser(input);
return parser.Program();
}
/**
* Read input directly from a String and parse it into an AST.
*/
public static Program parse(String inputText) throws ParseException {
return parse(new StringReader(inputText));
}
/**
* Normally we don't need to parse just expressions by themselves. But this
* is a convenience method, used by the unit tests for creating error messages.
* @throws ParseException
*/
public static Expression parseExp(String exp) throws ParseException {
JCCMiniJavaParser parser = new JCCMiniJavaParser(new StringReader(exp));
return parser.Expression();
}
/**
* Pretty print an AST node and return the result as a String.
*/ | public static String unparse(AST node) { |
mikedouglas/MiniJava | src/java/minijava/ast/ClassDecl.java | // Path: src/java/minijava/visitor/Visitor.java
// public interface Visitor<R> {
//
// //Lists
// public <T extends AST> R visit(NodeList<T> ns);
//
// //Declarations
// public R visit(Program n);
// public R visit(MainClass n);
// public R visit(ClassDecl n);
// public R visit(VarDecl n);
// public R visit(MethodDecl n);
//
// //Types
// public R visit(IntArrayType n);
// public R visit(BooleanType n);
// public R visit(IntegerType n);
// public R visit(ObjectType n);
//
// //Statements
// public R visit(Block n);
// public R visit(If n);
// public R visit(While n);
// public R visit(Print n);
// public R visit(Assign n);
// public R visit(ArrayAssign n);
//
// //Expressions
// public R visit(And n);
// public R visit(LessThan n);
// public R visit(Plus n);
// public R visit(Minus n);
// public R visit(Times n);
// public R visit(ArrayLookup n);
// public R visit(ArrayLength n);
// public R visit(Call n);
// public R visit(IntegerLiteral n);
// public R visit(BooleanLiteral n);
// public R visit(IdentifierExp n);
// public R visit(This n);
// public R visit(NewArray n);
// public R visit(NewObject n);
// public R visit(Not not);
//
// }
| import java.util.List;
import minijava.visitor.Visitor; | package minijava.ast;
public class ClassDecl extends AST {
public final String name;
public final String superName; //May be null!
public final NodeList<VarDecl> vars;
public final NodeList<MethodDecl> methods;
public ClassDecl(String name, String superName, NodeList<VarDecl> vars,
NodeList<MethodDecl> methods) {
super();
this.name = name;
this.superName = superName;
this.vars = vars;
this.methods = methods;
}
public ClassDecl(String name, String superName, List<VarDecl> vars,
List<MethodDecl> methods) {
this(
name, superName,
new NodeList<VarDecl>(vars), new NodeList<MethodDecl>(methods)
);
}
@Override | // Path: src/java/minijava/visitor/Visitor.java
// public interface Visitor<R> {
//
// //Lists
// public <T extends AST> R visit(NodeList<T> ns);
//
// //Declarations
// public R visit(Program n);
// public R visit(MainClass n);
// public R visit(ClassDecl n);
// public R visit(VarDecl n);
// public R visit(MethodDecl n);
//
// //Types
// public R visit(IntArrayType n);
// public R visit(BooleanType n);
// public R visit(IntegerType n);
// public R visit(ObjectType n);
//
// //Statements
// public R visit(Block n);
// public R visit(If n);
// public R visit(While n);
// public R visit(Print n);
// public R visit(Assign n);
// public R visit(ArrayAssign n);
//
// //Expressions
// public R visit(And n);
// public R visit(LessThan n);
// public R visit(Plus n);
// public R visit(Minus n);
// public R visit(Times n);
// public R visit(ArrayLookup n);
// public R visit(ArrayLength n);
// public R visit(Call n);
// public R visit(IntegerLiteral n);
// public R visit(BooleanLiteral n);
// public R visit(IdentifierExp n);
// public R visit(This n);
// public R visit(NewArray n);
// public R visit(NewObject n);
// public R visit(Not not);
//
// }
// Path: src/java/minijava/ast/ClassDecl.java
import java.util.List;
import minijava.visitor.Visitor;
package minijava.ast;
public class ClassDecl extends AST {
public final String name;
public final String superName; //May be null!
public final NodeList<VarDecl> vars;
public final NodeList<MethodDecl> methods;
public ClassDecl(String name, String superName, NodeList<VarDecl> vars,
NodeList<MethodDecl> methods) {
super();
this.name = name;
this.superName = superName;
this.vars = vars;
this.methods = methods;
}
public ClassDecl(String name, String superName, List<VarDecl> vars,
List<MethodDecl> methods) {
this(
name, superName,
new NodeList<VarDecl>(vars), new NodeList<MethodDecl>(methods)
);
}
@Override | public <R> R accept(Visitor<R> v) { |
mikedouglas/MiniJava | src/java/minijava/ast/This.java | // Path: src/java/minijava/visitor/Visitor.java
// public interface Visitor<R> {
//
// //Lists
// public <T extends AST> R visit(NodeList<T> ns);
//
// //Declarations
// public R visit(Program n);
// public R visit(MainClass n);
// public R visit(ClassDecl n);
// public R visit(VarDecl n);
// public R visit(MethodDecl n);
//
// //Types
// public R visit(IntArrayType n);
// public R visit(BooleanType n);
// public R visit(IntegerType n);
// public R visit(ObjectType n);
//
// //Statements
// public R visit(Block n);
// public R visit(If n);
// public R visit(While n);
// public R visit(Print n);
// public R visit(Assign n);
// public R visit(ArrayAssign n);
//
// //Expressions
// public R visit(And n);
// public R visit(LessThan n);
// public R visit(Plus n);
// public R visit(Minus n);
// public R visit(Times n);
// public R visit(ArrayLookup n);
// public R visit(ArrayLength n);
// public R visit(Call n);
// public R visit(IntegerLiteral n);
// public R visit(BooleanLiteral n);
// public R visit(IdentifierExp n);
// public R visit(This n);
// public R visit(NewArray n);
// public R visit(NewObject n);
// public R visit(Not not);
//
// }
| import minijava.visitor.Visitor; | package minijava.ast;
public class This extends Expression {
@Override | // Path: src/java/minijava/visitor/Visitor.java
// public interface Visitor<R> {
//
// //Lists
// public <T extends AST> R visit(NodeList<T> ns);
//
// //Declarations
// public R visit(Program n);
// public R visit(MainClass n);
// public R visit(ClassDecl n);
// public R visit(VarDecl n);
// public R visit(MethodDecl n);
//
// //Types
// public R visit(IntArrayType n);
// public R visit(BooleanType n);
// public R visit(IntegerType n);
// public R visit(ObjectType n);
//
// //Statements
// public R visit(Block n);
// public R visit(If n);
// public R visit(While n);
// public R visit(Print n);
// public R visit(Assign n);
// public R visit(ArrayAssign n);
//
// //Expressions
// public R visit(And n);
// public R visit(LessThan n);
// public R visit(Plus n);
// public R visit(Minus n);
// public R visit(Times n);
// public R visit(ArrayLookup n);
// public R visit(ArrayLength n);
// public R visit(Call n);
// public R visit(IntegerLiteral n);
// public R visit(BooleanLiteral n);
// public R visit(IdentifierExp n);
// public R visit(This n);
// public R visit(NewArray n);
// public R visit(NewObject n);
// public R visit(Not not);
//
// }
// Path: src/java/minijava/ast/This.java
import minijava.visitor.Visitor;
package minijava.ast;
public class This extends Expression {
@Override | public <R> R accept(Visitor<R> v) { |
mikedouglas/MiniJava | src/java/minijava/typechecker/MiniJavaTypeChecker.java | // Path: src/java/minijava/ast/Program.java
// public class Program extends AST {
//
// public final MainClass mainClass;
// public final NodeList<ClassDecl> classes;
//
// public Program(MainClass mainClass, NodeList<ClassDecl> otherClasses) {
// this.mainClass=mainClass;
// this.classes=otherClasses;
// }
//
// public Program(MainClass m, List<ClassDecl> cs) {
// this(m, new NodeList<ClassDecl>(cs));
// }
//
// public <R> R accept(Visitor<R> v) {
// return v.visit(this);
// }
//
// }
//
// Path: src/java/minijava/parser/MiniJavaParser.java
// public class MiniJavaParser {
//
// /**
// * Read input from a File and parse it into an AST representation.
// */
// public static Program parse(File file) throws IOException, ParseException {
// FileReader input = new FileReader(file);
// try {
// return parse(input);
// }
// finally { //No matter what happens, always close the file!
// input.close();
// }
// }
//
// /**
// * Read input from a java.io.Reader and parse it into an AST. It is the
// * caller's responsibility to close the Reader.
// */
// private static Program parse(Reader input) throws ParseException {
// JCCMiniJavaParser parser = new JCCMiniJavaParser(input);
// return parser.Program();
// }
//
// /**
// * Read input directly from a String and parse it into an AST.
// */
// public static Program parse(String inputText) throws ParseException {
// return parse(new StringReader(inputText));
// }
//
// /**
// * Normally we don't need to parse just expressions by themselves. But this
// * is a convenience method, used by the unit tests for creating error messages.
// * @throws ParseException
// */
// public static Expression parseExp(String exp) throws ParseException {
// JCCMiniJavaParser parser = new JCCMiniJavaParser(new StringReader(exp));
// return parser.Expression();
// }
// /**
// * Pretty print an AST node and return the result as a String.
// */
// public static String unparse(AST node) {
// return node.toString();
// // This assumes that toString on AST nodes is appropriately implemented.
// // If you decided to generate/implement your own AST classes rather than use
// // the ones we provided for you, you may need to implement this unparse method
// // differently.
// }
//
// }
//
// Path: src/java/minijava/typechecker/implementation/TypeCheckerImplementation.java
// public class TypeCheckerImplementation {
//
// Program program;
// ImpTable<ClassEntry> classTable;
// ErrorReport reporter;
// public TypeCheckerImplementation(Program program) {
// this.program = program;
// }
//
//
// public TypeChecked typeCheck() throws TypeCheckerException{
// reporter = new ErrorReport();
// buildClassTable();
//
// TypeCheckerVisitor checker = new TypeCheckerVisitor(classTable, reporter);
// checker.visit(program);
//
// reporter.close();//this will throw the first exception that was reported, if it exists.
// return new TypeChecked(program, classTable);
// }
//
// public Object buildClassTable(){
// ClassBuilderVisitor builder = new ClassBuilderVisitor(reporter);
// classTable = builder.visit(program);
//
// // Resolve class inheritance
// Iterator<Entry<String, ClassEntry>> itr = classTable.iterator();
// while (itr.hasNext()) {
// Entry<String, ClassEntry> entry;
// entry = (Entry<String, ClassEntry>) itr.next();
// String parentClassName = entry.getValue().getParentName();
//
// if (parentClassName != null) {
// ClassEntry parentClass = classTable.lookup(parentClassName);
// entry.getValue().setParentClass(parentClass);
// }
// }
//
// return classTable;
// }
//
// }
| import java.io.File;
import minijava.ast.Program;
import minijava.parser.MiniJavaParser;
import minijava.typechecker.implementation.TypeCheckerImplementation; | package minijava.typechecker;
/**
* This file constitutes the "interface" with the MiniJavaTypeChecker.
* It provides a few static methods that allow the MiniJava checker to be
* invoked on a given input program.
* <p>
* You may change the implementations of these methods, or any other methods
* and classes in this project, as long as your changes are compatible with
* the unit tests provided in the test packages.
*
* @author kdvolder
*/
public class MiniJavaTypeChecker {
/**
* Parse the contents of a given file and typecheck it. If type checking succeeds
* the method returns normally.
* <p>
* If the program has a type error or undeclared identifier error then an appropriate
* TypeCheckerException must be raised. The type checker may try to continue checking
* after the first error is encountered, but should nevertheless still raise a
* TypeCheckerException (this can be done by postponing the raising of the Exception
* until all of the input has been processed). See the class {@link ErrorReport}
* <p>
* Other Exceptions may be raised if the parsing or reading of the file fails.
* <p>
* The TypeChecker may return some representation of the TypeChecked program along with
* useful information derived by the checker.
* <p>
* This information will be passed along to the next phase of the compiler.
* <p>
* Right now what information goes in TypeChecked is irrelevant. All that matters is
* that errors get discovered. In later stages of the compiler however, you may find
* that your type checker computed valuable information (such as the symbol table from
* phase 1, which you may want to use again). At this point you will be able to
* add information into the TypeChecked object without breaking the type checker
* tests.
*/
public static TypeChecked parseAndCheck(File file) throws TypeCheckerException, Exception { | // Path: src/java/minijava/ast/Program.java
// public class Program extends AST {
//
// public final MainClass mainClass;
// public final NodeList<ClassDecl> classes;
//
// public Program(MainClass mainClass, NodeList<ClassDecl> otherClasses) {
// this.mainClass=mainClass;
// this.classes=otherClasses;
// }
//
// public Program(MainClass m, List<ClassDecl> cs) {
// this(m, new NodeList<ClassDecl>(cs));
// }
//
// public <R> R accept(Visitor<R> v) {
// return v.visit(this);
// }
//
// }
//
// Path: src/java/minijava/parser/MiniJavaParser.java
// public class MiniJavaParser {
//
// /**
// * Read input from a File and parse it into an AST representation.
// */
// public static Program parse(File file) throws IOException, ParseException {
// FileReader input = new FileReader(file);
// try {
// return parse(input);
// }
// finally { //No matter what happens, always close the file!
// input.close();
// }
// }
//
// /**
// * Read input from a java.io.Reader and parse it into an AST. It is the
// * caller's responsibility to close the Reader.
// */
// private static Program parse(Reader input) throws ParseException {
// JCCMiniJavaParser parser = new JCCMiniJavaParser(input);
// return parser.Program();
// }
//
// /**
// * Read input directly from a String and parse it into an AST.
// */
// public static Program parse(String inputText) throws ParseException {
// return parse(new StringReader(inputText));
// }
//
// /**
// * Normally we don't need to parse just expressions by themselves. But this
// * is a convenience method, used by the unit tests for creating error messages.
// * @throws ParseException
// */
// public static Expression parseExp(String exp) throws ParseException {
// JCCMiniJavaParser parser = new JCCMiniJavaParser(new StringReader(exp));
// return parser.Expression();
// }
// /**
// * Pretty print an AST node and return the result as a String.
// */
// public static String unparse(AST node) {
// return node.toString();
// // This assumes that toString on AST nodes is appropriately implemented.
// // If you decided to generate/implement your own AST classes rather than use
// // the ones we provided for you, you may need to implement this unparse method
// // differently.
// }
//
// }
//
// Path: src/java/minijava/typechecker/implementation/TypeCheckerImplementation.java
// public class TypeCheckerImplementation {
//
// Program program;
// ImpTable<ClassEntry> classTable;
// ErrorReport reporter;
// public TypeCheckerImplementation(Program program) {
// this.program = program;
// }
//
//
// public TypeChecked typeCheck() throws TypeCheckerException{
// reporter = new ErrorReport();
// buildClassTable();
//
// TypeCheckerVisitor checker = new TypeCheckerVisitor(classTable, reporter);
// checker.visit(program);
//
// reporter.close();//this will throw the first exception that was reported, if it exists.
// return new TypeChecked(program, classTable);
// }
//
// public Object buildClassTable(){
// ClassBuilderVisitor builder = new ClassBuilderVisitor(reporter);
// classTable = builder.visit(program);
//
// // Resolve class inheritance
// Iterator<Entry<String, ClassEntry>> itr = classTable.iterator();
// while (itr.hasNext()) {
// Entry<String, ClassEntry> entry;
// entry = (Entry<String, ClassEntry>) itr.next();
// String parentClassName = entry.getValue().getParentName();
//
// if (parentClassName != null) {
// ClassEntry parentClass = classTable.lookup(parentClassName);
// entry.getValue().setParentClass(parentClass);
// }
// }
//
// return classTable;
// }
//
// }
// Path: src/java/minijava/typechecker/MiniJavaTypeChecker.java
import java.io.File;
import minijava.ast.Program;
import minijava.parser.MiniJavaParser;
import minijava.typechecker.implementation.TypeCheckerImplementation;
package minijava.typechecker;
/**
* This file constitutes the "interface" with the MiniJavaTypeChecker.
* It provides a few static methods that allow the MiniJava checker to be
* invoked on a given input program.
* <p>
* You may change the implementations of these methods, or any other methods
* and classes in this project, as long as your changes are compatible with
* the unit tests provided in the test packages.
*
* @author kdvolder
*/
public class MiniJavaTypeChecker {
/**
* Parse the contents of a given file and typecheck it. If type checking succeeds
* the method returns normally.
* <p>
* If the program has a type error or undeclared identifier error then an appropriate
* TypeCheckerException must be raised. The type checker may try to continue checking
* after the first error is encountered, but should nevertheless still raise a
* TypeCheckerException (this can be done by postponing the raising of the Exception
* until all of the input has been processed). See the class {@link ErrorReport}
* <p>
* Other Exceptions may be raised if the parsing or reading of the file fails.
* <p>
* The TypeChecker may return some representation of the TypeChecked program along with
* useful information derived by the checker.
* <p>
* This information will be passed along to the next phase of the compiler.
* <p>
* Right now what information goes in TypeChecked is irrelevant. All that matters is
* that errors get discovered. In later stages of the compiler however, you may find
* that your type checker computed valuable information (such as the symbol table from
* phase 1, which you may want to use again). At this point you will be able to
* add information into the TypeChecked object without breaking the type checker
* tests.
*/
public static TypeChecked parseAndCheck(File file) throws TypeCheckerException, Exception { | Program program = MiniJavaParser.parse(file); |
mikedouglas/MiniJava | src/java/minijava/typechecker/MiniJavaTypeChecker.java | // Path: src/java/minijava/ast/Program.java
// public class Program extends AST {
//
// public final MainClass mainClass;
// public final NodeList<ClassDecl> classes;
//
// public Program(MainClass mainClass, NodeList<ClassDecl> otherClasses) {
// this.mainClass=mainClass;
// this.classes=otherClasses;
// }
//
// public Program(MainClass m, List<ClassDecl> cs) {
// this(m, new NodeList<ClassDecl>(cs));
// }
//
// public <R> R accept(Visitor<R> v) {
// return v.visit(this);
// }
//
// }
//
// Path: src/java/minijava/parser/MiniJavaParser.java
// public class MiniJavaParser {
//
// /**
// * Read input from a File and parse it into an AST representation.
// */
// public static Program parse(File file) throws IOException, ParseException {
// FileReader input = new FileReader(file);
// try {
// return parse(input);
// }
// finally { //No matter what happens, always close the file!
// input.close();
// }
// }
//
// /**
// * Read input from a java.io.Reader and parse it into an AST. It is the
// * caller's responsibility to close the Reader.
// */
// private static Program parse(Reader input) throws ParseException {
// JCCMiniJavaParser parser = new JCCMiniJavaParser(input);
// return parser.Program();
// }
//
// /**
// * Read input directly from a String and parse it into an AST.
// */
// public static Program parse(String inputText) throws ParseException {
// return parse(new StringReader(inputText));
// }
//
// /**
// * Normally we don't need to parse just expressions by themselves. But this
// * is a convenience method, used by the unit tests for creating error messages.
// * @throws ParseException
// */
// public static Expression parseExp(String exp) throws ParseException {
// JCCMiniJavaParser parser = new JCCMiniJavaParser(new StringReader(exp));
// return parser.Expression();
// }
// /**
// * Pretty print an AST node and return the result as a String.
// */
// public static String unparse(AST node) {
// return node.toString();
// // This assumes that toString on AST nodes is appropriately implemented.
// // If you decided to generate/implement your own AST classes rather than use
// // the ones we provided for you, you may need to implement this unparse method
// // differently.
// }
//
// }
//
// Path: src/java/minijava/typechecker/implementation/TypeCheckerImplementation.java
// public class TypeCheckerImplementation {
//
// Program program;
// ImpTable<ClassEntry> classTable;
// ErrorReport reporter;
// public TypeCheckerImplementation(Program program) {
// this.program = program;
// }
//
//
// public TypeChecked typeCheck() throws TypeCheckerException{
// reporter = new ErrorReport();
// buildClassTable();
//
// TypeCheckerVisitor checker = new TypeCheckerVisitor(classTable, reporter);
// checker.visit(program);
//
// reporter.close();//this will throw the first exception that was reported, if it exists.
// return new TypeChecked(program, classTable);
// }
//
// public Object buildClassTable(){
// ClassBuilderVisitor builder = new ClassBuilderVisitor(reporter);
// classTable = builder.visit(program);
//
// // Resolve class inheritance
// Iterator<Entry<String, ClassEntry>> itr = classTable.iterator();
// while (itr.hasNext()) {
// Entry<String, ClassEntry> entry;
// entry = (Entry<String, ClassEntry>) itr.next();
// String parentClassName = entry.getValue().getParentName();
//
// if (parentClassName != null) {
// ClassEntry parentClass = classTable.lookup(parentClassName);
// entry.getValue().setParentClass(parentClass);
// }
// }
//
// return classTable;
// }
//
// }
| import java.io.File;
import minijava.ast.Program;
import minijava.parser.MiniJavaParser;
import minijava.typechecker.implementation.TypeCheckerImplementation; | package minijava.typechecker;
/**
* This file constitutes the "interface" with the MiniJavaTypeChecker.
* It provides a few static methods that allow the MiniJava checker to be
* invoked on a given input program.
* <p>
* You may change the implementations of these methods, or any other methods
* and classes in this project, as long as your changes are compatible with
* the unit tests provided in the test packages.
*
* @author kdvolder
*/
public class MiniJavaTypeChecker {
/**
* Parse the contents of a given file and typecheck it. If type checking succeeds
* the method returns normally.
* <p>
* If the program has a type error or undeclared identifier error then an appropriate
* TypeCheckerException must be raised. The type checker may try to continue checking
* after the first error is encountered, but should nevertheless still raise a
* TypeCheckerException (this can be done by postponing the raising of the Exception
* until all of the input has been processed). See the class {@link ErrorReport}
* <p>
* Other Exceptions may be raised if the parsing or reading of the file fails.
* <p>
* The TypeChecker may return some representation of the TypeChecked program along with
* useful information derived by the checker.
* <p>
* This information will be passed along to the next phase of the compiler.
* <p>
* Right now what information goes in TypeChecked is irrelevant. All that matters is
* that errors get discovered. In later stages of the compiler however, you may find
* that your type checker computed valuable information (such as the symbol table from
* phase 1, which you may want to use again). At this point you will be able to
* add information into the TypeChecked object without breaking the type checker
* tests.
*/
public static TypeChecked parseAndCheck(File file) throws TypeCheckerException, Exception { | // Path: src/java/minijava/ast/Program.java
// public class Program extends AST {
//
// public final MainClass mainClass;
// public final NodeList<ClassDecl> classes;
//
// public Program(MainClass mainClass, NodeList<ClassDecl> otherClasses) {
// this.mainClass=mainClass;
// this.classes=otherClasses;
// }
//
// public Program(MainClass m, List<ClassDecl> cs) {
// this(m, new NodeList<ClassDecl>(cs));
// }
//
// public <R> R accept(Visitor<R> v) {
// return v.visit(this);
// }
//
// }
//
// Path: src/java/minijava/parser/MiniJavaParser.java
// public class MiniJavaParser {
//
// /**
// * Read input from a File and parse it into an AST representation.
// */
// public static Program parse(File file) throws IOException, ParseException {
// FileReader input = new FileReader(file);
// try {
// return parse(input);
// }
// finally { //No matter what happens, always close the file!
// input.close();
// }
// }
//
// /**
// * Read input from a java.io.Reader and parse it into an AST. It is the
// * caller's responsibility to close the Reader.
// */
// private static Program parse(Reader input) throws ParseException {
// JCCMiniJavaParser parser = new JCCMiniJavaParser(input);
// return parser.Program();
// }
//
// /**
// * Read input directly from a String and parse it into an AST.
// */
// public static Program parse(String inputText) throws ParseException {
// return parse(new StringReader(inputText));
// }
//
// /**
// * Normally we don't need to parse just expressions by themselves. But this
// * is a convenience method, used by the unit tests for creating error messages.
// * @throws ParseException
// */
// public static Expression parseExp(String exp) throws ParseException {
// JCCMiniJavaParser parser = new JCCMiniJavaParser(new StringReader(exp));
// return parser.Expression();
// }
// /**
// * Pretty print an AST node and return the result as a String.
// */
// public static String unparse(AST node) {
// return node.toString();
// // This assumes that toString on AST nodes is appropriately implemented.
// // If you decided to generate/implement your own AST classes rather than use
// // the ones we provided for you, you may need to implement this unparse method
// // differently.
// }
//
// }
//
// Path: src/java/minijava/typechecker/implementation/TypeCheckerImplementation.java
// public class TypeCheckerImplementation {
//
// Program program;
// ImpTable<ClassEntry> classTable;
// ErrorReport reporter;
// public TypeCheckerImplementation(Program program) {
// this.program = program;
// }
//
//
// public TypeChecked typeCheck() throws TypeCheckerException{
// reporter = new ErrorReport();
// buildClassTable();
//
// TypeCheckerVisitor checker = new TypeCheckerVisitor(classTable, reporter);
// checker.visit(program);
//
// reporter.close();//this will throw the first exception that was reported, if it exists.
// return new TypeChecked(program, classTable);
// }
//
// public Object buildClassTable(){
// ClassBuilderVisitor builder = new ClassBuilderVisitor(reporter);
// classTable = builder.visit(program);
//
// // Resolve class inheritance
// Iterator<Entry<String, ClassEntry>> itr = classTable.iterator();
// while (itr.hasNext()) {
// Entry<String, ClassEntry> entry;
// entry = (Entry<String, ClassEntry>) itr.next();
// String parentClassName = entry.getValue().getParentName();
//
// if (parentClassName != null) {
// ClassEntry parentClass = classTable.lookup(parentClassName);
// entry.getValue().setParentClass(parentClass);
// }
// }
//
// return classTable;
// }
//
// }
// Path: src/java/minijava/typechecker/MiniJavaTypeChecker.java
import java.io.File;
import minijava.ast.Program;
import minijava.parser.MiniJavaParser;
import minijava.typechecker.implementation.TypeCheckerImplementation;
package minijava.typechecker;
/**
* This file constitutes the "interface" with the MiniJavaTypeChecker.
* It provides a few static methods that allow the MiniJava checker to be
* invoked on a given input program.
* <p>
* You may change the implementations of these methods, or any other methods
* and classes in this project, as long as your changes are compatible with
* the unit tests provided in the test packages.
*
* @author kdvolder
*/
public class MiniJavaTypeChecker {
/**
* Parse the contents of a given file and typecheck it. If type checking succeeds
* the method returns normally.
* <p>
* If the program has a type error or undeclared identifier error then an appropriate
* TypeCheckerException must be raised. The type checker may try to continue checking
* after the first error is encountered, but should nevertheless still raise a
* TypeCheckerException (this can be done by postponing the raising of the Exception
* until all of the input has been processed). See the class {@link ErrorReport}
* <p>
* Other Exceptions may be raised if the parsing or reading of the file fails.
* <p>
* The TypeChecker may return some representation of the TypeChecked program along with
* useful information derived by the checker.
* <p>
* This information will be passed along to the next phase of the compiler.
* <p>
* Right now what information goes in TypeChecked is irrelevant. All that matters is
* that errors get discovered. In later stages of the compiler however, you may find
* that your type checker computed valuable information (such as the symbol table from
* phase 1, which you may want to use again). At this point you will be able to
* add information into the TypeChecked object without breaking the type checker
* tests.
*/
public static TypeChecked parseAndCheck(File file) throws TypeCheckerException, Exception { | Program program = MiniJavaParser.parse(file); |
mikedouglas/MiniJava | src/java/minijava/typechecker/MiniJavaTypeChecker.java | // Path: src/java/minijava/ast/Program.java
// public class Program extends AST {
//
// public final MainClass mainClass;
// public final NodeList<ClassDecl> classes;
//
// public Program(MainClass mainClass, NodeList<ClassDecl> otherClasses) {
// this.mainClass=mainClass;
// this.classes=otherClasses;
// }
//
// public Program(MainClass m, List<ClassDecl> cs) {
// this(m, new NodeList<ClassDecl>(cs));
// }
//
// public <R> R accept(Visitor<R> v) {
// return v.visit(this);
// }
//
// }
//
// Path: src/java/minijava/parser/MiniJavaParser.java
// public class MiniJavaParser {
//
// /**
// * Read input from a File and parse it into an AST representation.
// */
// public static Program parse(File file) throws IOException, ParseException {
// FileReader input = new FileReader(file);
// try {
// return parse(input);
// }
// finally { //No matter what happens, always close the file!
// input.close();
// }
// }
//
// /**
// * Read input from a java.io.Reader and parse it into an AST. It is the
// * caller's responsibility to close the Reader.
// */
// private static Program parse(Reader input) throws ParseException {
// JCCMiniJavaParser parser = new JCCMiniJavaParser(input);
// return parser.Program();
// }
//
// /**
// * Read input directly from a String and parse it into an AST.
// */
// public static Program parse(String inputText) throws ParseException {
// return parse(new StringReader(inputText));
// }
//
// /**
// * Normally we don't need to parse just expressions by themselves. But this
// * is a convenience method, used by the unit tests for creating error messages.
// * @throws ParseException
// */
// public static Expression parseExp(String exp) throws ParseException {
// JCCMiniJavaParser parser = new JCCMiniJavaParser(new StringReader(exp));
// return parser.Expression();
// }
// /**
// * Pretty print an AST node and return the result as a String.
// */
// public static String unparse(AST node) {
// return node.toString();
// // This assumes that toString on AST nodes is appropriately implemented.
// // If you decided to generate/implement your own AST classes rather than use
// // the ones we provided for you, you may need to implement this unparse method
// // differently.
// }
//
// }
//
// Path: src/java/minijava/typechecker/implementation/TypeCheckerImplementation.java
// public class TypeCheckerImplementation {
//
// Program program;
// ImpTable<ClassEntry> classTable;
// ErrorReport reporter;
// public TypeCheckerImplementation(Program program) {
// this.program = program;
// }
//
//
// public TypeChecked typeCheck() throws TypeCheckerException{
// reporter = new ErrorReport();
// buildClassTable();
//
// TypeCheckerVisitor checker = new TypeCheckerVisitor(classTable, reporter);
// checker.visit(program);
//
// reporter.close();//this will throw the first exception that was reported, if it exists.
// return new TypeChecked(program, classTable);
// }
//
// public Object buildClassTable(){
// ClassBuilderVisitor builder = new ClassBuilderVisitor(reporter);
// classTable = builder.visit(program);
//
// // Resolve class inheritance
// Iterator<Entry<String, ClassEntry>> itr = classTable.iterator();
// while (itr.hasNext()) {
// Entry<String, ClassEntry> entry;
// entry = (Entry<String, ClassEntry>) itr.next();
// String parentClassName = entry.getValue().getParentName();
//
// if (parentClassName != null) {
// ClassEntry parentClass = classTable.lookup(parentClassName);
// entry.getValue().setParentClass(parentClass);
// }
// }
//
// return classTable;
// }
//
// }
| import java.io.File;
import minijava.ast.Program;
import minijava.parser.MiniJavaParser;
import minijava.typechecker.implementation.TypeCheckerImplementation; | package minijava.typechecker;
/**
* This file constitutes the "interface" with the MiniJavaTypeChecker.
* It provides a few static methods that allow the MiniJava checker to be
* invoked on a given input program.
* <p>
* You may change the implementations of these methods, or any other methods
* and classes in this project, as long as your changes are compatible with
* the unit tests provided in the test packages.
*
* @author kdvolder
*/
public class MiniJavaTypeChecker {
/**
* Parse the contents of a given file and typecheck it. If type checking succeeds
* the method returns normally.
* <p>
* If the program has a type error or undeclared identifier error then an appropriate
* TypeCheckerException must be raised. The type checker may try to continue checking
* after the first error is encountered, but should nevertheless still raise a
* TypeCheckerException (this can be done by postponing the raising of the Exception
* until all of the input has been processed). See the class {@link ErrorReport}
* <p>
* Other Exceptions may be raised if the parsing or reading of the file fails.
* <p>
* The TypeChecker may return some representation of the TypeChecked program along with
* useful information derived by the checker.
* <p>
* This information will be passed along to the next phase of the compiler.
* <p>
* Right now what information goes in TypeChecked is irrelevant. All that matters is
* that errors get discovered. In later stages of the compiler however, you may find
* that your type checker computed valuable information (such as the symbol table from
* phase 1, which you may want to use again). At this point you will be able to
* add information into the TypeChecked object without breaking the type checker
* tests.
*/
public static TypeChecked parseAndCheck(File file) throws TypeCheckerException, Exception {
Program program = MiniJavaParser.parse(file); | // Path: src/java/minijava/ast/Program.java
// public class Program extends AST {
//
// public final MainClass mainClass;
// public final NodeList<ClassDecl> classes;
//
// public Program(MainClass mainClass, NodeList<ClassDecl> otherClasses) {
// this.mainClass=mainClass;
// this.classes=otherClasses;
// }
//
// public Program(MainClass m, List<ClassDecl> cs) {
// this(m, new NodeList<ClassDecl>(cs));
// }
//
// public <R> R accept(Visitor<R> v) {
// return v.visit(this);
// }
//
// }
//
// Path: src/java/minijava/parser/MiniJavaParser.java
// public class MiniJavaParser {
//
// /**
// * Read input from a File and parse it into an AST representation.
// */
// public static Program parse(File file) throws IOException, ParseException {
// FileReader input = new FileReader(file);
// try {
// return parse(input);
// }
// finally { //No matter what happens, always close the file!
// input.close();
// }
// }
//
// /**
// * Read input from a java.io.Reader and parse it into an AST. It is the
// * caller's responsibility to close the Reader.
// */
// private static Program parse(Reader input) throws ParseException {
// JCCMiniJavaParser parser = new JCCMiniJavaParser(input);
// return parser.Program();
// }
//
// /**
// * Read input directly from a String and parse it into an AST.
// */
// public static Program parse(String inputText) throws ParseException {
// return parse(new StringReader(inputText));
// }
//
// /**
// * Normally we don't need to parse just expressions by themselves. But this
// * is a convenience method, used by the unit tests for creating error messages.
// * @throws ParseException
// */
// public static Expression parseExp(String exp) throws ParseException {
// JCCMiniJavaParser parser = new JCCMiniJavaParser(new StringReader(exp));
// return parser.Expression();
// }
// /**
// * Pretty print an AST node and return the result as a String.
// */
// public static String unparse(AST node) {
// return node.toString();
// // This assumes that toString on AST nodes is appropriately implemented.
// // If you decided to generate/implement your own AST classes rather than use
// // the ones we provided for you, you may need to implement this unparse method
// // differently.
// }
//
// }
//
// Path: src/java/minijava/typechecker/implementation/TypeCheckerImplementation.java
// public class TypeCheckerImplementation {
//
// Program program;
// ImpTable<ClassEntry> classTable;
// ErrorReport reporter;
// public TypeCheckerImplementation(Program program) {
// this.program = program;
// }
//
//
// public TypeChecked typeCheck() throws TypeCheckerException{
// reporter = new ErrorReport();
// buildClassTable();
//
// TypeCheckerVisitor checker = new TypeCheckerVisitor(classTable, reporter);
// checker.visit(program);
//
// reporter.close();//this will throw the first exception that was reported, if it exists.
// return new TypeChecked(program, classTable);
// }
//
// public Object buildClassTable(){
// ClassBuilderVisitor builder = new ClassBuilderVisitor(reporter);
// classTable = builder.visit(program);
//
// // Resolve class inheritance
// Iterator<Entry<String, ClassEntry>> itr = classTable.iterator();
// while (itr.hasNext()) {
// Entry<String, ClassEntry> entry;
// entry = (Entry<String, ClassEntry>) itr.next();
// String parentClassName = entry.getValue().getParentName();
//
// if (parentClassName != null) {
// ClassEntry parentClass = classTable.lookup(parentClassName);
// entry.getValue().setParentClass(parentClass);
// }
// }
//
// return classTable;
// }
//
// }
// Path: src/java/minijava/typechecker/MiniJavaTypeChecker.java
import java.io.File;
import minijava.ast.Program;
import minijava.parser.MiniJavaParser;
import minijava.typechecker.implementation.TypeCheckerImplementation;
package minijava.typechecker;
/**
* This file constitutes the "interface" with the MiniJavaTypeChecker.
* It provides a few static methods that allow the MiniJava checker to be
* invoked on a given input program.
* <p>
* You may change the implementations of these methods, or any other methods
* and classes in this project, as long as your changes are compatible with
* the unit tests provided in the test packages.
*
* @author kdvolder
*/
public class MiniJavaTypeChecker {
/**
* Parse the contents of a given file and typecheck it. If type checking succeeds
* the method returns normally.
* <p>
* If the program has a type error or undeclared identifier error then an appropriate
* TypeCheckerException must be raised. The type checker may try to continue checking
* after the first error is encountered, but should nevertheless still raise a
* TypeCheckerException (this can be done by postponing the raising of the Exception
* until all of the input has been processed). See the class {@link ErrorReport}
* <p>
* Other Exceptions may be raised if the parsing or reading of the file fails.
* <p>
* The TypeChecker may return some representation of the TypeChecked program along with
* useful information derived by the checker.
* <p>
* This information will be passed along to the next phase of the compiler.
* <p>
* Right now what information goes in TypeChecked is irrelevant. All that matters is
* that errors get discovered. In later stages of the compiler however, you may find
* that your type checker computed valuable information (such as the symbol table from
* phase 1, which you may want to use again). At this point you will be able to
* add information into the TypeChecked object without breaking the type checker
* tests.
*/
public static TypeChecked parseAndCheck(File file) throws TypeCheckerException, Exception {
Program program = MiniJavaParser.parse(file); | return new TypeCheckerImplementation(program).typeCheck(); |
mikedouglas/MiniJava | src/java/minijava/ast/BooleanType.java | // Path: src/java/minijava/visitor/Visitor.java
// public interface Visitor<R> {
//
// //Lists
// public <T extends AST> R visit(NodeList<T> ns);
//
// //Declarations
// public R visit(Program n);
// public R visit(MainClass n);
// public R visit(ClassDecl n);
// public R visit(VarDecl n);
// public R visit(MethodDecl n);
//
// //Types
// public R visit(IntArrayType n);
// public R visit(BooleanType n);
// public R visit(IntegerType n);
// public R visit(ObjectType n);
//
// //Statements
// public R visit(Block n);
// public R visit(If n);
// public R visit(While n);
// public R visit(Print n);
// public R visit(Assign n);
// public R visit(ArrayAssign n);
//
// //Expressions
// public R visit(And n);
// public R visit(LessThan n);
// public R visit(Plus n);
// public R visit(Minus n);
// public R visit(Times n);
// public R visit(ArrayLookup n);
// public R visit(ArrayLength n);
// public R visit(Call n);
// public R visit(IntegerLiteral n);
// public R visit(BooleanLiteral n);
// public R visit(IdentifierExp n);
// public R visit(This n);
// public R visit(NewArray n);
// public R visit(NewObject n);
// public R visit(Not not);
//
// }
| import minijava.visitor.Visitor; | package minijava.ast;
public class BooleanType extends Type {
public static BooleanType instance = new BooleanType();
@Override | // Path: src/java/minijava/visitor/Visitor.java
// public interface Visitor<R> {
//
// //Lists
// public <T extends AST> R visit(NodeList<T> ns);
//
// //Declarations
// public R visit(Program n);
// public R visit(MainClass n);
// public R visit(ClassDecl n);
// public R visit(VarDecl n);
// public R visit(MethodDecl n);
//
// //Types
// public R visit(IntArrayType n);
// public R visit(BooleanType n);
// public R visit(IntegerType n);
// public R visit(ObjectType n);
//
// //Statements
// public R visit(Block n);
// public R visit(If n);
// public R visit(While n);
// public R visit(Print n);
// public R visit(Assign n);
// public R visit(ArrayAssign n);
//
// //Expressions
// public R visit(And n);
// public R visit(LessThan n);
// public R visit(Plus n);
// public R visit(Minus n);
// public R visit(Times n);
// public R visit(ArrayLookup n);
// public R visit(ArrayLength n);
// public R visit(Call n);
// public R visit(IntegerLiteral n);
// public R visit(BooleanLiteral n);
// public R visit(IdentifierExp n);
// public R visit(This n);
// public R visit(NewArray n);
// public R visit(NewObject n);
// public R visit(Not not);
//
// }
// Path: src/java/minijava/ast/BooleanType.java
import minijava.visitor.Visitor;
package minijava.ast;
public class BooleanType extends Type {
public static BooleanType instance = new BooleanType();
@Override | public <R> R accept(Visitor<R> v) { |
mikedouglas/MiniJava | src/java/minijava/ast/NewArray.java | // Path: src/java/minijava/visitor/Visitor.java
// public interface Visitor<R> {
//
// //Lists
// public <T extends AST> R visit(NodeList<T> ns);
//
// //Declarations
// public R visit(Program n);
// public R visit(MainClass n);
// public R visit(ClassDecl n);
// public R visit(VarDecl n);
// public R visit(MethodDecl n);
//
// //Types
// public R visit(IntArrayType n);
// public R visit(BooleanType n);
// public R visit(IntegerType n);
// public R visit(ObjectType n);
//
// //Statements
// public R visit(Block n);
// public R visit(If n);
// public R visit(While n);
// public R visit(Print n);
// public R visit(Assign n);
// public R visit(ArrayAssign n);
//
// //Expressions
// public R visit(And n);
// public R visit(LessThan n);
// public R visit(Plus n);
// public R visit(Minus n);
// public R visit(Times n);
// public R visit(ArrayLookup n);
// public R visit(ArrayLength n);
// public R visit(Call n);
// public R visit(IntegerLiteral n);
// public R visit(BooleanLiteral n);
// public R visit(IdentifierExp n);
// public R visit(This n);
// public R visit(NewArray n);
// public R visit(NewObject n);
// public R visit(Not not);
//
// }
| import minijava.visitor.Visitor; | package minijava.ast;
public class NewArray extends Expression {
public final Expression size;
public NewArray(Expression size) {
super();
super.setType(IntArrayType.instance);
this.size = size;
}
@Override | // Path: src/java/minijava/visitor/Visitor.java
// public interface Visitor<R> {
//
// //Lists
// public <T extends AST> R visit(NodeList<T> ns);
//
// //Declarations
// public R visit(Program n);
// public R visit(MainClass n);
// public R visit(ClassDecl n);
// public R visit(VarDecl n);
// public R visit(MethodDecl n);
//
// //Types
// public R visit(IntArrayType n);
// public R visit(BooleanType n);
// public R visit(IntegerType n);
// public R visit(ObjectType n);
//
// //Statements
// public R visit(Block n);
// public R visit(If n);
// public R visit(While n);
// public R visit(Print n);
// public R visit(Assign n);
// public R visit(ArrayAssign n);
//
// //Expressions
// public R visit(And n);
// public R visit(LessThan n);
// public R visit(Plus n);
// public R visit(Minus n);
// public R visit(Times n);
// public R visit(ArrayLookup n);
// public R visit(ArrayLength n);
// public R visit(Call n);
// public R visit(IntegerLiteral n);
// public R visit(BooleanLiteral n);
// public R visit(IdentifierExp n);
// public R visit(This n);
// public R visit(NewArray n);
// public R visit(NewObject n);
// public R visit(Not not);
//
// }
// Path: src/java/minijava/ast/NewArray.java
import minijava.visitor.Visitor;
package minijava.ast;
public class NewArray extends Expression {
public final Expression size;
public NewArray(Expression size) {
super();
super.setType(IntArrayType.instance);
this.size = size;
}
@Override | public <R> R accept(Visitor<R> v) { |
mikedouglas/MiniJava | src/java/minijava/ast/IntArrayType.java | // Path: src/java/minijava/visitor/Visitor.java
// public interface Visitor<R> {
//
// //Lists
// public <T extends AST> R visit(NodeList<T> ns);
//
// //Declarations
// public R visit(Program n);
// public R visit(MainClass n);
// public R visit(ClassDecl n);
// public R visit(VarDecl n);
// public R visit(MethodDecl n);
//
// //Types
// public R visit(IntArrayType n);
// public R visit(BooleanType n);
// public R visit(IntegerType n);
// public R visit(ObjectType n);
//
// //Statements
// public R visit(Block n);
// public R visit(If n);
// public R visit(While n);
// public R visit(Print n);
// public R visit(Assign n);
// public R visit(ArrayAssign n);
//
// //Expressions
// public R visit(And n);
// public R visit(LessThan n);
// public R visit(Plus n);
// public R visit(Minus n);
// public R visit(Times n);
// public R visit(ArrayLookup n);
// public R visit(ArrayLength n);
// public R visit(Call n);
// public R visit(IntegerLiteral n);
// public R visit(BooleanLiteral n);
// public R visit(IdentifierExp n);
// public R visit(This n);
// public R visit(NewArray n);
// public R visit(NewObject n);
// public R visit(Not not);
//
// }
| import minijava.visitor.Visitor; | package minijava.ast;
public class IntArrayType extends Type {
public static IntArrayType instance = new IntArrayType();
@Override | // Path: src/java/minijava/visitor/Visitor.java
// public interface Visitor<R> {
//
// //Lists
// public <T extends AST> R visit(NodeList<T> ns);
//
// //Declarations
// public R visit(Program n);
// public R visit(MainClass n);
// public R visit(ClassDecl n);
// public R visit(VarDecl n);
// public R visit(MethodDecl n);
//
// //Types
// public R visit(IntArrayType n);
// public R visit(BooleanType n);
// public R visit(IntegerType n);
// public R visit(ObjectType n);
//
// //Statements
// public R visit(Block n);
// public R visit(If n);
// public R visit(While n);
// public R visit(Print n);
// public R visit(Assign n);
// public R visit(ArrayAssign n);
//
// //Expressions
// public R visit(And n);
// public R visit(LessThan n);
// public R visit(Plus n);
// public R visit(Minus n);
// public R visit(Times n);
// public R visit(ArrayLookup n);
// public R visit(ArrayLength n);
// public R visit(Call n);
// public R visit(IntegerLiteral n);
// public R visit(BooleanLiteral n);
// public R visit(IdentifierExp n);
// public R visit(This n);
// public R visit(NewArray n);
// public R visit(NewObject n);
// public R visit(Not not);
//
// }
// Path: src/java/minijava/ast/IntArrayType.java
import minijava.visitor.Visitor;
package minijava.ast;
public class IntArrayType extends Type {
public static IntArrayType instance = new IntArrayType();
@Override | public <R> R accept(Visitor<R> v) { |
mikedouglas/MiniJava | src/java/minijava/test/util/ImpTableTest.java | // Path: src/java/minijava/util/ImpTable.java
// public class ImpTable<V> extends DefaultIndentable
// implements Iterable<Entry<String, V>>, Lookup<V>
// {
//
// public static class DuplicateException extends Exception {
//
// private static final long serialVersionUID = 8650830167061316305L;
//
// public DuplicateException(String arg0) {
// super(arg0);
// }
//
// }
//
// private Map<String, V> map = new HashMap<String, V>();
//
// @Override
// public Iterator<Entry<String,V>> iterator() {
// return map.entrySet().iterator();
// }
//
// /**
// * Insert an entry into the table. This modifies the table.
// * Duplicate entries (i.e. with the same id are not supported).
// * When a duplicate id is being entered a DuplicatException is
// * thrown.
// * <p>
// * Note: the name "put" different from the name "insert" in the
// * FunTable is deliberate. This will make sure you get compile
// * errors when you try to change code using imperative puts
// * to use functional inserts instead.
// */
// public void put(String id, V value) throws DuplicateException {
// Assert.assertNotNull(value);
// Assert.assertNotNull(id);
// V existing = map.get(id);
// if (existing!=null) throw new DuplicateException("Duplicate entry: "+id);
// map.put(id, value);
// }
//
// /**
// * Find an entry in the table. If no entry is found, null is returned.
// */
// public V lookup(String id) {
// return map.get(id);
// }
//
// @Override
// public void dump(IndentingWriter out) {
// out.println("Table {");
// out.indent();
// for (Entry<String, V> entry : this) {
// out.print(entry.getKey()+" = ");
// out.println(entry.getValue());
// }
// out.outdent();
// out.print("}");
// }
//
// public boolean isEmpty() {
// return size()==0;
// }
//
// @Override
// public int size() {
// return map.size();
// }
//
// }
//
// Path: src/java/minijava/util/ImpTable.java
// public static class DuplicateException extends Exception {
//
// private static final long serialVersionUID = 8650830167061316305L;
//
// public DuplicateException(String arg0) {
// super(arg0);
// }
//
// }
| import minijava.util.ImpTable;
import minijava.util.ImpTable.DuplicateException;
import org.junit.Assert;
import org.junit.Test; | package minijava.test.util;
/**
* It is a good idea to provide unit tests for all non-trivial
* data structure implementations. This class contains tests for
* our implementation of Symbol tables provided in the class
* minijava.table.ImpTable.
* <p>
* The implementation of Table that is provided is already complete.
* These tests should run and pass "out of the box".
*
* @author kdvolder
*/
public class ImpTableTest {
@Test public void testEmptyTable() { | // Path: src/java/minijava/util/ImpTable.java
// public class ImpTable<V> extends DefaultIndentable
// implements Iterable<Entry<String, V>>, Lookup<V>
// {
//
// public static class DuplicateException extends Exception {
//
// private static final long serialVersionUID = 8650830167061316305L;
//
// public DuplicateException(String arg0) {
// super(arg0);
// }
//
// }
//
// private Map<String, V> map = new HashMap<String, V>();
//
// @Override
// public Iterator<Entry<String,V>> iterator() {
// return map.entrySet().iterator();
// }
//
// /**
// * Insert an entry into the table. This modifies the table.
// * Duplicate entries (i.e. with the same id are not supported).
// * When a duplicate id is being entered a DuplicatException is
// * thrown.
// * <p>
// * Note: the name "put" different from the name "insert" in the
// * FunTable is deliberate. This will make sure you get compile
// * errors when you try to change code using imperative puts
// * to use functional inserts instead.
// */
// public void put(String id, V value) throws DuplicateException {
// Assert.assertNotNull(value);
// Assert.assertNotNull(id);
// V existing = map.get(id);
// if (existing!=null) throw new DuplicateException("Duplicate entry: "+id);
// map.put(id, value);
// }
//
// /**
// * Find an entry in the table. If no entry is found, null is returned.
// */
// public V lookup(String id) {
// return map.get(id);
// }
//
// @Override
// public void dump(IndentingWriter out) {
// out.println("Table {");
// out.indent();
// for (Entry<String, V> entry : this) {
// out.print(entry.getKey()+" = ");
// out.println(entry.getValue());
// }
// out.outdent();
// out.print("}");
// }
//
// public boolean isEmpty() {
// return size()==0;
// }
//
// @Override
// public int size() {
// return map.size();
// }
//
// }
//
// Path: src/java/minijava/util/ImpTable.java
// public static class DuplicateException extends Exception {
//
// private static final long serialVersionUID = 8650830167061316305L;
//
// public DuplicateException(String arg0) {
// super(arg0);
// }
//
// }
// Path: src/java/minijava/test/util/ImpTableTest.java
import minijava.util.ImpTable;
import minijava.util.ImpTable.DuplicateException;
import org.junit.Assert;
import org.junit.Test;
package minijava.test.util;
/**
* It is a good idea to provide unit tests for all non-trivial
* data structure implementations. This class contains tests for
* our implementation of Symbol tables provided in the class
* minijava.table.ImpTable.
* <p>
* The implementation of Table that is provided is already complete.
* These tests should run and pass "out of the box".
*
* @author kdvolder
*/
public class ImpTableTest {
@Test public void testEmptyTable() { | ImpTable<Integer> tab = new ImpTable<Integer>(); |
mikedouglas/MiniJava | src/java/minijava/test/util/ImpTableTest.java | // Path: src/java/minijava/util/ImpTable.java
// public class ImpTable<V> extends DefaultIndentable
// implements Iterable<Entry<String, V>>, Lookup<V>
// {
//
// public static class DuplicateException extends Exception {
//
// private static final long serialVersionUID = 8650830167061316305L;
//
// public DuplicateException(String arg0) {
// super(arg0);
// }
//
// }
//
// private Map<String, V> map = new HashMap<String, V>();
//
// @Override
// public Iterator<Entry<String,V>> iterator() {
// return map.entrySet().iterator();
// }
//
// /**
// * Insert an entry into the table. This modifies the table.
// * Duplicate entries (i.e. with the same id are not supported).
// * When a duplicate id is being entered a DuplicatException is
// * thrown.
// * <p>
// * Note: the name "put" different from the name "insert" in the
// * FunTable is deliberate. This will make sure you get compile
// * errors when you try to change code using imperative puts
// * to use functional inserts instead.
// */
// public void put(String id, V value) throws DuplicateException {
// Assert.assertNotNull(value);
// Assert.assertNotNull(id);
// V existing = map.get(id);
// if (existing!=null) throw new DuplicateException("Duplicate entry: "+id);
// map.put(id, value);
// }
//
// /**
// * Find an entry in the table. If no entry is found, null is returned.
// */
// public V lookup(String id) {
// return map.get(id);
// }
//
// @Override
// public void dump(IndentingWriter out) {
// out.println("Table {");
// out.indent();
// for (Entry<String, V> entry : this) {
// out.print(entry.getKey()+" = ");
// out.println(entry.getValue());
// }
// out.outdent();
// out.print("}");
// }
//
// public boolean isEmpty() {
// return size()==0;
// }
//
// @Override
// public int size() {
// return map.size();
// }
//
// }
//
// Path: src/java/minijava/util/ImpTable.java
// public static class DuplicateException extends Exception {
//
// private static final long serialVersionUID = 8650830167061316305L;
//
// public DuplicateException(String arg0) {
// super(arg0);
// }
//
// }
| import minijava.util.ImpTable;
import minijava.util.ImpTable.DuplicateException;
import org.junit.Assert;
import org.junit.Test; | package minijava.test.util;
/**
* It is a good idea to provide unit tests for all non-trivial
* data structure implementations. This class contains tests for
* our implementation of Symbol tables provided in the class
* minijava.table.ImpTable.
* <p>
* The implementation of Table that is provided is already complete.
* These tests should run and pass "out of the box".
*
* @author kdvolder
*/
public class ImpTableTest {
@Test public void testEmptyTable() {
ImpTable<Integer> tab = new ImpTable<Integer>();
Assert.assertTrue(tab.isEmpty());
Assert.assertNull(tab.lookup("something"));
}
| // Path: src/java/minijava/util/ImpTable.java
// public class ImpTable<V> extends DefaultIndentable
// implements Iterable<Entry<String, V>>, Lookup<V>
// {
//
// public static class DuplicateException extends Exception {
//
// private static final long serialVersionUID = 8650830167061316305L;
//
// public DuplicateException(String arg0) {
// super(arg0);
// }
//
// }
//
// private Map<String, V> map = new HashMap<String, V>();
//
// @Override
// public Iterator<Entry<String,V>> iterator() {
// return map.entrySet().iterator();
// }
//
// /**
// * Insert an entry into the table. This modifies the table.
// * Duplicate entries (i.e. with the same id are not supported).
// * When a duplicate id is being entered a DuplicatException is
// * thrown.
// * <p>
// * Note: the name "put" different from the name "insert" in the
// * FunTable is deliberate. This will make sure you get compile
// * errors when you try to change code using imperative puts
// * to use functional inserts instead.
// */
// public void put(String id, V value) throws DuplicateException {
// Assert.assertNotNull(value);
// Assert.assertNotNull(id);
// V existing = map.get(id);
// if (existing!=null) throw new DuplicateException("Duplicate entry: "+id);
// map.put(id, value);
// }
//
// /**
// * Find an entry in the table. If no entry is found, null is returned.
// */
// public V lookup(String id) {
// return map.get(id);
// }
//
// @Override
// public void dump(IndentingWriter out) {
// out.println("Table {");
// out.indent();
// for (Entry<String, V> entry : this) {
// out.print(entry.getKey()+" = ");
// out.println(entry.getValue());
// }
// out.outdent();
// out.print("}");
// }
//
// public boolean isEmpty() {
// return size()==0;
// }
//
// @Override
// public int size() {
// return map.size();
// }
//
// }
//
// Path: src/java/minijava/util/ImpTable.java
// public static class DuplicateException extends Exception {
//
// private static final long serialVersionUID = 8650830167061316305L;
//
// public DuplicateException(String arg0) {
// super(arg0);
// }
//
// }
// Path: src/java/minijava/test/util/ImpTableTest.java
import minijava.util.ImpTable;
import minijava.util.ImpTable.DuplicateException;
import org.junit.Assert;
import org.junit.Test;
package minijava.test.util;
/**
* It is a good idea to provide unit tests for all non-trivial
* data structure implementations. This class contains tests for
* our implementation of Symbol tables provided in the class
* minijava.table.ImpTable.
* <p>
* The implementation of Table that is provided is already complete.
* These tests should run and pass "out of the box".
*
* @author kdvolder
*/
public class ImpTableTest {
@Test public void testEmptyTable() {
ImpTable<Integer> tab = new ImpTable<Integer>();
Assert.assertTrue(tab.isEmpty());
Assert.assertNull(tab.lookup("something"));
}
| @Test public void testOneInsert() throws DuplicateException { |
mikedouglas/MiniJava | src/java/minijava/ast/LessThan.java | // Path: src/java/minijava/visitor/Visitor.java
// public interface Visitor<R> {
//
// //Lists
// public <T extends AST> R visit(NodeList<T> ns);
//
// //Declarations
// public R visit(Program n);
// public R visit(MainClass n);
// public R visit(ClassDecl n);
// public R visit(VarDecl n);
// public R visit(MethodDecl n);
//
// //Types
// public R visit(IntArrayType n);
// public R visit(BooleanType n);
// public R visit(IntegerType n);
// public R visit(ObjectType n);
//
// //Statements
// public R visit(Block n);
// public R visit(If n);
// public R visit(While n);
// public R visit(Print n);
// public R visit(Assign n);
// public R visit(ArrayAssign n);
//
// //Expressions
// public R visit(And n);
// public R visit(LessThan n);
// public R visit(Plus n);
// public R visit(Minus n);
// public R visit(Times n);
// public R visit(ArrayLookup n);
// public R visit(ArrayLength n);
// public R visit(Call n);
// public R visit(IntegerLiteral n);
// public R visit(BooleanLiteral n);
// public R visit(IdentifierExp n);
// public R visit(This n);
// public R visit(NewArray n);
// public R visit(NewObject n);
// public R visit(Not not);
//
// }
| import minijava.visitor.Visitor; | package minijava.ast;
public class LessThan extends Expression {
public final Expression e1;
public final Expression e2;
public LessThan(Expression e1, Expression e2) {
super();
super.setType(BooleanType.instance);
this.e1 = e1;
this.e2 = e2;
}
@Override | // Path: src/java/minijava/visitor/Visitor.java
// public interface Visitor<R> {
//
// //Lists
// public <T extends AST> R visit(NodeList<T> ns);
//
// //Declarations
// public R visit(Program n);
// public R visit(MainClass n);
// public R visit(ClassDecl n);
// public R visit(VarDecl n);
// public R visit(MethodDecl n);
//
// //Types
// public R visit(IntArrayType n);
// public R visit(BooleanType n);
// public R visit(IntegerType n);
// public R visit(ObjectType n);
//
// //Statements
// public R visit(Block n);
// public R visit(If n);
// public R visit(While n);
// public R visit(Print n);
// public R visit(Assign n);
// public R visit(ArrayAssign n);
//
// //Expressions
// public R visit(And n);
// public R visit(LessThan n);
// public R visit(Plus n);
// public R visit(Minus n);
// public R visit(Times n);
// public R visit(ArrayLookup n);
// public R visit(ArrayLength n);
// public R visit(Call n);
// public R visit(IntegerLiteral n);
// public R visit(BooleanLiteral n);
// public R visit(IdentifierExp n);
// public R visit(This n);
// public R visit(NewArray n);
// public R visit(NewObject n);
// public R visit(Not not);
//
// }
// Path: src/java/minijava/ast/LessThan.java
import minijava.visitor.Visitor;
package minijava.ast;
public class LessThan extends Expression {
public final Expression e1;
public final Expression e2;
public LessThan(Expression e1, Expression e2) {
super();
super.setType(BooleanType.instance);
this.e1 = e1;
this.e2 = e2;
}
@Override | public <R> R accept(Visitor<R> v) { |
mikedouglas/MiniJava | src/java/minijava/ast/Plus.java | // Path: src/java/minijava/visitor/Visitor.java
// public interface Visitor<R> {
//
// //Lists
// public <T extends AST> R visit(NodeList<T> ns);
//
// //Declarations
// public R visit(Program n);
// public R visit(MainClass n);
// public R visit(ClassDecl n);
// public R visit(VarDecl n);
// public R visit(MethodDecl n);
//
// //Types
// public R visit(IntArrayType n);
// public R visit(BooleanType n);
// public R visit(IntegerType n);
// public R visit(ObjectType n);
//
// //Statements
// public R visit(Block n);
// public R visit(If n);
// public R visit(While n);
// public R visit(Print n);
// public R visit(Assign n);
// public R visit(ArrayAssign n);
//
// //Expressions
// public R visit(And n);
// public R visit(LessThan n);
// public R visit(Plus n);
// public R visit(Minus n);
// public R visit(Times n);
// public R visit(ArrayLookup n);
// public R visit(ArrayLength n);
// public R visit(Call n);
// public R visit(IntegerLiteral n);
// public R visit(BooleanLiteral n);
// public R visit(IdentifierExp n);
// public R visit(This n);
// public R visit(NewArray n);
// public R visit(NewObject n);
// public R visit(Not not);
//
// }
| import minijava.visitor.Visitor; | package minijava.ast;
public class Plus extends Expression {
public final Expression e1;
public final Expression e2;
public Plus(Expression e1, Expression e2) {
super();
super.setType(IntegerType.instance);
this.e1 = e1;
this.e2 = e2;
}
@Override | // Path: src/java/minijava/visitor/Visitor.java
// public interface Visitor<R> {
//
// //Lists
// public <T extends AST> R visit(NodeList<T> ns);
//
// //Declarations
// public R visit(Program n);
// public R visit(MainClass n);
// public R visit(ClassDecl n);
// public R visit(VarDecl n);
// public R visit(MethodDecl n);
//
// //Types
// public R visit(IntArrayType n);
// public R visit(BooleanType n);
// public R visit(IntegerType n);
// public R visit(ObjectType n);
//
// //Statements
// public R visit(Block n);
// public R visit(If n);
// public R visit(While n);
// public R visit(Print n);
// public R visit(Assign n);
// public R visit(ArrayAssign n);
//
// //Expressions
// public R visit(And n);
// public R visit(LessThan n);
// public R visit(Plus n);
// public R visit(Minus n);
// public R visit(Times n);
// public R visit(ArrayLookup n);
// public R visit(ArrayLength n);
// public R visit(Call n);
// public R visit(IntegerLiteral n);
// public R visit(BooleanLiteral n);
// public R visit(IdentifierExp n);
// public R visit(This n);
// public R visit(NewArray n);
// public R visit(NewObject n);
// public R visit(Not not);
//
// }
// Path: src/java/minijava/ast/Plus.java
import minijava.visitor.Visitor;
package minijava.ast;
public class Plus extends Expression {
public final Expression e1;
public final Expression e2;
public Plus(Expression e1, Expression e2) {
super();
super.setType(IntegerType.instance);
this.e1 = e1;
this.e2 = e2;
}
@Override | public <R> R accept(Visitor<R> v) { |
mikedouglas/MiniJava | src/java/minijava/ast/ArrayAssign.java | // Path: src/java/minijava/visitor/Visitor.java
// public interface Visitor<R> {
//
// //Lists
// public <T extends AST> R visit(NodeList<T> ns);
//
// //Declarations
// public R visit(Program n);
// public R visit(MainClass n);
// public R visit(ClassDecl n);
// public R visit(VarDecl n);
// public R visit(MethodDecl n);
//
// //Types
// public R visit(IntArrayType n);
// public R visit(BooleanType n);
// public R visit(IntegerType n);
// public R visit(ObjectType n);
//
// //Statements
// public R visit(Block n);
// public R visit(If n);
// public R visit(While n);
// public R visit(Print n);
// public R visit(Assign n);
// public R visit(ArrayAssign n);
//
// //Expressions
// public R visit(And n);
// public R visit(LessThan n);
// public R visit(Plus n);
// public R visit(Minus n);
// public R visit(Times n);
// public R visit(ArrayLookup n);
// public R visit(ArrayLength n);
// public R visit(Call n);
// public R visit(IntegerLiteral n);
// public R visit(BooleanLiteral n);
// public R visit(IdentifierExp n);
// public R visit(This n);
// public R visit(NewArray n);
// public R visit(NewObject n);
// public R visit(Not not);
//
// }
| import minijava.visitor.Visitor; | package minijava.ast;
public class ArrayAssign extends Statement {
public final String name;
public final Expression index;
public final Expression value;
public ArrayAssign(String name, Expression index, Expression value) {
super();
this.name = name;
this.index = index;
this.value = value;
}
@Override | // Path: src/java/minijava/visitor/Visitor.java
// public interface Visitor<R> {
//
// //Lists
// public <T extends AST> R visit(NodeList<T> ns);
//
// //Declarations
// public R visit(Program n);
// public R visit(MainClass n);
// public R visit(ClassDecl n);
// public R visit(VarDecl n);
// public R visit(MethodDecl n);
//
// //Types
// public R visit(IntArrayType n);
// public R visit(BooleanType n);
// public R visit(IntegerType n);
// public R visit(ObjectType n);
//
// //Statements
// public R visit(Block n);
// public R visit(If n);
// public R visit(While n);
// public R visit(Print n);
// public R visit(Assign n);
// public R visit(ArrayAssign n);
//
// //Expressions
// public R visit(And n);
// public R visit(LessThan n);
// public R visit(Plus n);
// public R visit(Minus n);
// public R visit(Times n);
// public R visit(ArrayLookup n);
// public R visit(ArrayLength n);
// public R visit(Call n);
// public R visit(IntegerLiteral n);
// public R visit(BooleanLiteral n);
// public R visit(IdentifierExp n);
// public R visit(This n);
// public R visit(NewArray n);
// public R visit(NewObject n);
// public R visit(Not not);
//
// }
// Path: src/java/minijava/ast/ArrayAssign.java
import minijava.visitor.Visitor;
package minijava.ast;
public class ArrayAssign extends Statement {
public final String name;
public final Expression index;
public final Expression value;
public ArrayAssign(String name, Expression index, Expression value) {
super();
this.name = name;
this.index = index;
this.value = value;
}
@Override | public <R> R accept(Visitor<R> v) { |
mikedouglas/MiniJava | src/java/minijava/ast/Print.java | // Path: src/java/minijava/visitor/Visitor.java
// public interface Visitor<R> {
//
// //Lists
// public <T extends AST> R visit(NodeList<T> ns);
//
// //Declarations
// public R visit(Program n);
// public R visit(MainClass n);
// public R visit(ClassDecl n);
// public R visit(VarDecl n);
// public R visit(MethodDecl n);
//
// //Types
// public R visit(IntArrayType n);
// public R visit(BooleanType n);
// public R visit(IntegerType n);
// public R visit(ObjectType n);
//
// //Statements
// public R visit(Block n);
// public R visit(If n);
// public R visit(While n);
// public R visit(Print n);
// public R visit(Assign n);
// public R visit(ArrayAssign n);
//
// //Expressions
// public R visit(And n);
// public R visit(LessThan n);
// public R visit(Plus n);
// public R visit(Minus n);
// public R visit(Times n);
// public R visit(ArrayLookup n);
// public R visit(ArrayLength n);
// public R visit(Call n);
// public R visit(IntegerLiteral n);
// public R visit(BooleanLiteral n);
// public R visit(IdentifierExp n);
// public R visit(This n);
// public R visit(NewArray n);
// public R visit(NewObject n);
// public R visit(Not not);
//
// }
| import minijava.visitor.Visitor; | package minijava.ast;
public class Print extends Statement {
public final Expression exp;
public Print(Expression exp) {
super();
this.exp = exp;
}
@Override | // Path: src/java/minijava/visitor/Visitor.java
// public interface Visitor<R> {
//
// //Lists
// public <T extends AST> R visit(NodeList<T> ns);
//
// //Declarations
// public R visit(Program n);
// public R visit(MainClass n);
// public R visit(ClassDecl n);
// public R visit(VarDecl n);
// public R visit(MethodDecl n);
//
// //Types
// public R visit(IntArrayType n);
// public R visit(BooleanType n);
// public R visit(IntegerType n);
// public R visit(ObjectType n);
//
// //Statements
// public R visit(Block n);
// public R visit(If n);
// public R visit(While n);
// public R visit(Print n);
// public R visit(Assign n);
// public R visit(ArrayAssign n);
//
// //Expressions
// public R visit(And n);
// public R visit(LessThan n);
// public R visit(Plus n);
// public R visit(Minus n);
// public R visit(Times n);
// public R visit(ArrayLookup n);
// public R visit(ArrayLength n);
// public R visit(Call n);
// public R visit(IntegerLiteral n);
// public R visit(BooleanLiteral n);
// public R visit(IdentifierExp n);
// public R visit(This n);
// public R visit(NewArray n);
// public R visit(NewObject n);
// public R visit(Not not);
//
// }
// Path: src/java/minijava/ast/Print.java
import minijava.visitor.Visitor;
package minijava.ast;
public class Print extends Statement {
public final Expression exp;
public Print(Expression exp) {
super();
this.exp = exp;
}
@Override | public <R> R accept(Visitor<R> v) { |
mikedouglas/MiniJava | src/java/minijava/ast/IntegerType.java | // Path: src/java/minijava/visitor/Visitor.java
// public interface Visitor<R> {
//
// //Lists
// public <T extends AST> R visit(NodeList<T> ns);
//
// //Declarations
// public R visit(Program n);
// public R visit(MainClass n);
// public R visit(ClassDecl n);
// public R visit(VarDecl n);
// public R visit(MethodDecl n);
//
// //Types
// public R visit(IntArrayType n);
// public R visit(BooleanType n);
// public R visit(IntegerType n);
// public R visit(ObjectType n);
//
// //Statements
// public R visit(Block n);
// public R visit(If n);
// public R visit(While n);
// public R visit(Print n);
// public R visit(Assign n);
// public R visit(ArrayAssign n);
//
// //Expressions
// public R visit(And n);
// public R visit(LessThan n);
// public R visit(Plus n);
// public R visit(Minus n);
// public R visit(Times n);
// public R visit(ArrayLookup n);
// public R visit(ArrayLength n);
// public R visit(Call n);
// public R visit(IntegerLiteral n);
// public R visit(BooleanLiteral n);
// public R visit(IdentifierExp n);
// public R visit(This n);
// public R visit(NewArray n);
// public R visit(NewObject n);
// public R visit(Not not);
//
// }
| import minijava.visitor.Visitor; | package minijava.ast;
public class IntegerType extends Type {
public static IntegerType instance = new IntegerType();
@Override | // Path: src/java/minijava/visitor/Visitor.java
// public interface Visitor<R> {
//
// //Lists
// public <T extends AST> R visit(NodeList<T> ns);
//
// //Declarations
// public R visit(Program n);
// public R visit(MainClass n);
// public R visit(ClassDecl n);
// public R visit(VarDecl n);
// public R visit(MethodDecl n);
//
// //Types
// public R visit(IntArrayType n);
// public R visit(BooleanType n);
// public R visit(IntegerType n);
// public R visit(ObjectType n);
//
// //Statements
// public R visit(Block n);
// public R visit(If n);
// public R visit(While n);
// public R visit(Print n);
// public R visit(Assign n);
// public R visit(ArrayAssign n);
//
// //Expressions
// public R visit(And n);
// public R visit(LessThan n);
// public R visit(Plus n);
// public R visit(Minus n);
// public R visit(Times n);
// public R visit(ArrayLookup n);
// public R visit(ArrayLength n);
// public R visit(Call n);
// public R visit(IntegerLiteral n);
// public R visit(BooleanLiteral n);
// public R visit(IdentifierExp n);
// public R visit(This n);
// public R visit(NewArray n);
// public R visit(NewObject n);
// public R visit(Not not);
//
// }
// Path: src/java/minijava/ast/IntegerType.java
import minijava.visitor.Visitor;
package minijava.ast;
public class IntegerType extends Type {
public static IntegerType instance = new IntegerType();
@Override | public <R> R accept(Visitor<R> v) { |
mikedouglas/MiniJava | src/java/minijava/ast/IntegerLiteral.java | // Path: src/java/minijava/visitor/Visitor.java
// public interface Visitor<R> {
//
// //Lists
// public <T extends AST> R visit(NodeList<T> ns);
//
// //Declarations
// public R visit(Program n);
// public R visit(MainClass n);
// public R visit(ClassDecl n);
// public R visit(VarDecl n);
// public R visit(MethodDecl n);
//
// //Types
// public R visit(IntArrayType n);
// public R visit(BooleanType n);
// public R visit(IntegerType n);
// public R visit(ObjectType n);
//
// //Statements
// public R visit(Block n);
// public R visit(If n);
// public R visit(While n);
// public R visit(Print n);
// public R visit(Assign n);
// public R visit(ArrayAssign n);
//
// //Expressions
// public R visit(And n);
// public R visit(LessThan n);
// public R visit(Plus n);
// public R visit(Minus n);
// public R visit(Times n);
// public R visit(ArrayLookup n);
// public R visit(ArrayLength n);
// public R visit(Call n);
// public R visit(IntegerLiteral n);
// public R visit(BooleanLiteral n);
// public R visit(IdentifierExp n);
// public R visit(This n);
// public R visit(NewArray n);
// public R visit(NewObject n);
// public R visit(Not not);
//
// }
| import minijava.visitor.Visitor; | package minijava.ast;
public class IntegerLiteral extends Expression {
public final int value;
public IntegerLiteral(int value) {
super();
super.setType(IntegerType.instance);
this.value = value;
}
public IntegerLiteral(String image) {
this(Integer.parseInt(image));
}
@Override | // Path: src/java/minijava/visitor/Visitor.java
// public interface Visitor<R> {
//
// //Lists
// public <T extends AST> R visit(NodeList<T> ns);
//
// //Declarations
// public R visit(Program n);
// public R visit(MainClass n);
// public R visit(ClassDecl n);
// public R visit(VarDecl n);
// public R visit(MethodDecl n);
//
// //Types
// public R visit(IntArrayType n);
// public R visit(BooleanType n);
// public R visit(IntegerType n);
// public R visit(ObjectType n);
//
// //Statements
// public R visit(Block n);
// public R visit(If n);
// public R visit(While n);
// public R visit(Print n);
// public R visit(Assign n);
// public R visit(ArrayAssign n);
//
// //Expressions
// public R visit(And n);
// public R visit(LessThan n);
// public R visit(Plus n);
// public R visit(Minus n);
// public R visit(Times n);
// public R visit(ArrayLookup n);
// public R visit(ArrayLength n);
// public R visit(Call n);
// public R visit(IntegerLiteral n);
// public R visit(BooleanLiteral n);
// public R visit(IdentifierExp n);
// public R visit(This n);
// public R visit(NewArray n);
// public R visit(NewObject n);
// public R visit(Not not);
//
// }
// Path: src/java/minijava/ast/IntegerLiteral.java
import minijava.visitor.Visitor;
package minijava.ast;
public class IntegerLiteral extends Expression {
public final int value;
public IntegerLiteral(int value) {
super();
super.setType(IntegerType.instance);
this.value = value;
}
public IntegerLiteral(String image) {
this(Integer.parseInt(image));
}
@Override | public <R> R accept(Visitor<R> v) { |
mikedouglas/MiniJava | src/java/minijava/ast/Block.java | // Path: src/java/minijava/visitor/Visitor.java
// public interface Visitor<R> {
//
// //Lists
// public <T extends AST> R visit(NodeList<T> ns);
//
// //Declarations
// public R visit(Program n);
// public R visit(MainClass n);
// public R visit(ClassDecl n);
// public R visit(VarDecl n);
// public R visit(MethodDecl n);
//
// //Types
// public R visit(IntArrayType n);
// public R visit(BooleanType n);
// public R visit(IntegerType n);
// public R visit(ObjectType n);
//
// //Statements
// public R visit(Block n);
// public R visit(If n);
// public R visit(While n);
// public R visit(Print n);
// public R visit(Assign n);
// public R visit(ArrayAssign n);
//
// //Expressions
// public R visit(And n);
// public R visit(LessThan n);
// public R visit(Plus n);
// public R visit(Minus n);
// public R visit(Times n);
// public R visit(ArrayLookup n);
// public R visit(ArrayLength n);
// public R visit(Call n);
// public R visit(IntegerLiteral n);
// public R visit(BooleanLiteral n);
// public R visit(IdentifierExp n);
// public R visit(This n);
// public R visit(NewArray n);
// public R visit(NewObject n);
// public R visit(Not not);
//
// }
| import java.util.List;
import minijava.visitor.Visitor; | package minijava.ast;
public class Block extends Statement {
public final NodeList<Statement> statements;
public Block(NodeList<Statement> statements) {
super();
this.statements = statements;
}
public Block(List<Statement> statements) {
this(new NodeList<Statement>(statements));
}
@Override | // Path: src/java/minijava/visitor/Visitor.java
// public interface Visitor<R> {
//
// //Lists
// public <T extends AST> R visit(NodeList<T> ns);
//
// //Declarations
// public R visit(Program n);
// public R visit(MainClass n);
// public R visit(ClassDecl n);
// public R visit(VarDecl n);
// public R visit(MethodDecl n);
//
// //Types
// public R visit(IntArrayType n);
// public R visit(BooleanType n);
// public R visit(IntegerType n);
// public R visit(ObjectType n);
//
// //Statements
// public R visit(Block n);
// public R visit(If n);
// public R visit(While n);
// public R visit(Print n);
// public R visit(Assign n);
// public R visit(ArrayAssign n);
//
// //Expressions
// public R visit(And n);
// public R visit(LessThan n);
// public R visit(Plus n);
// public R visit(Minus n);
// public R visit(Times n);
// public R visit(ArrayLookup n);
// public R visit(ArrayLength n);
// public R visit(Call n);
// public R visit(IntegerLiteral n);
// public R visit(BooleanLiteral n);
// public R visit(IdentifierExp n);
// public R visit(This n);
// public R visit(NewArray n);
// public R visit(NewObject n);
// public R visit(Not not);
//
// }
// Path: src/java/minijava/ast/Block.java
import java.util.List;
import minijava.visitor.Visitor;
package minijava.ast;
public class Block extends Statement {
public final NodeList<Statement> statements;
public Block(NodeList<Statement> statements) {
super();
this.statements = statements;
}
public Block(List<Statement> statements) {
this(new NodeList<Statement>(statements));
}
@Override | public <R> R accept(Visitor<R> v) { |
mikedouglas/MiniJava | src/java/minijava/ast/MethodDecl.java | // Path: src/java/minijava/visitor/Visitor.java
// public interface Visitor<R> {
//
// //Lists
// public <T extends AST> R visit(NodeList<T> ns);
//
// //Declarations
// public R visit(Program n);
// public R visit(MainClass n);
// public R visit(ClassDecl n);
// public R visit(VarDecl n);
// public R visit(MethodDecl n);
//
// //Types
// public R visit(IntArrayType n);
// public R visit(BooleanType n);
// public R visit(IntegerType n);
// public R visit(ObjectType n);
//
// //Statements
// public R visit(Block n);
// public R visit(If n);
// public R visit(While n);
// public R visit(Print n);
// public R visit(Assign n);
// public R visit(ArrayAssign n);
//
// //Expressions
// public R visit(And n);
// public R visit(LessThan n);
// public R visit(Plus n);
// public R visit(Minus n);
// public R visit(Times n);
// public R visit(ArrayLookup n);
// public R visit(ArrayLength n);
// public R visit(Call n);
// public R visit(IntegerLiteral n);
// public R visit(BooleanLiteral n);
// public R visit(IdentifierExp n);
// public R visit(This n);
// public R visit(NewArray n);
// public R visit(NewObject n);
// public R visit(Not not);
//
// }
| import java.util.List;
import minijava.visitor.Visitor; | package minijava.ast;
public class MethodDecl extends AST {
public final Type returnType;
public final String name;
public final NodeList<VarDecl> formals;
public final NodeList<VarDecl> vars;
public final NodeList<Statement> statements;
public final Expression returnExp;
public MethodDecl(Type returnType, String name, NodeList<VarDecl> formals,
NodeList<VarDecl> vars, NodeList<Statement> statements, Expression returnExp) {
super();
this.returnType = returnType;
this.name = name;
this.formals = formals;
this.vars = vars;
this.statements = statements;
this.returnExp = returnExp;
}
public MethodDecl(Type returnType, String name, List<VarDecl> formals,
List<VarDecl> vars, List<Statement> statements, Expression returnExp) {
this(
returnType, name, new NodeList<VarDecl>(formals),
new NodeList<VarDecl>(vars),
new NodeList<Statement>(statements),
returnExp
);
}
@Override | // Path: src/java/minijava/visitor/Visitor.java
// public interface Visitor<R> {
//
// //Lists
// public <T extends AST> R visit(NodeList<T> ns);
//
// //Declarations
// public R visit(Program n);
// public R visit(MainClass n);
// public R visit(ClassDecl n);
// public R visit(VarDecl n);
// public R visit(MethodDecl n);
//
// //Types
// public R visit(IntArrayType n);
// public R visit(BooleanType n);
// public R visit(IntegerType n);
// public R visit(ObjectType n);
//
// //Statements
// public R visit(Block n);
// public R visit(If n);
// public R visit(While n);
// public R visit(Print n);
// public R visit(Assign n);
// public R visit(ArrayAssign n);
//
// //Expressions
// public R visit(And n);
// public R visit(LessThan n);
// public R visit(Plus n);
// public R visit(Minus n);
// public R visit(Times n);
// public R visit(ArrayLookup n);
// public R visit(ArrayLength n);
// public R visit(Call n);
// public R visit(IntegerLiteral n);
// public R visit(BooleanLiteral n);
// public R visit(IdentifierExp n);
// public R visit(This n);
// public R visit(NewArray n);
// public R visit(NewObject n);
// public R visit(Not not);
//
// }
// Path: src/java/minijava/ast/MethodDecl.java
import java.util.List;
import minijava.visitor.Visitor;
package minijava.ast;
public class MethodDecl extends AST {
public final Type returnType;
public final String name;
public final NodeList<VarDecl> formals;
public final NodeList<VarDecl> vars;
public final NodeList<Statement> statements;
public final Expression returnExp;
public MethodDecl(Type returnType, String name, NodeList<VarDecl> formals,
NodeList<VarDecl> vars, NodeList<Statement> statements, Expression returnExp) {
super();
this.returnType = returnType;
this.name = name;
this.formals = formals;
this.vars = vars;
this.statements = statements;
this.returnExp = returnExp;
}
public MethodDecl(Type returnType, String name, List<VarDecl> formals,
List<VarDecl> vars, List<Statement> statements, Expression returnExp) {
this(
returnType, name, new NodeList<VarDecl>(formals),
new NodeList<VarDecl>(vars),
new NodeList<Statement>(statements),
returnExp
);
}
@Override | public <R> R accept(Visitor<R> v) { |
mikedouglas/MiniJava | src/java/minijava/ast/If.java | // Path: src/java/minijava/visitor/Visitor.java
// public interface Visitor<R> {
//
// //Lists
// public <T extends AST> R visit(NodeList<T> ns);
//
// //Declarations
// public R visit(Program n);
// public R visit(MainClass n);
// public R visit(ClassDecl n);
// public R visit(VarDecl n);
// public R visit(MethodDecl n);
//
// //Types
// public R visit(IntArrayType n);
// public R visit(BooleanType n);
// public R visit(IntegerType n);
// public R visit(ObjectType n);
//
// //Statements
// public R visit(Block n);
// public R visit(If n);
// public R visit(While n);
// public R visit(Print n);
// public R visit(Assign n);
// public R visit(ArrayAssign n);
//
// //Expressions
// public R visit(And n);
// public R visit(LessThan n);
// public R visit(Plus n);
// public R visit(Minus n);
// public R visit(Times n);
// public R visit(ArrayLookup n);
// public R visit(ArrayLength n);
// public R visit(Call n);
// public R visit(IntegerLiteral n);
// public R visit(BooleanLiteral n);
// public R visit(IdentifierExp n);
// public R visit(This n);
// public R visit(NewArray n);
// public R visit(NewObject n);
// public R visit(Not not);
//
// }
| import minijava.visitor.Visitor; | package minijava.ast;
public class If extends Statement {
public final Expression tst;
public final Statement thn;
public final Statement els;
public If(Expression tst, Statement thn, Statement els) {
super();
this.tst = tst;
this.thn = thn;
this.els = els;
}
@Override | // Path: src/java/minijava/visitor/Visitor.java
// public interface Visitor<R> {
//
// //Lists
// public <T extends AST> R visit(NodeList<T> ns);
//
// //Declarations
// public R visit(Program n);
// public R visit(MainClass n);
// public R visit(ClassDecl n);
// public R visit(VarDecl n);
// public R visit(MethodDecl n);
//
// //Types
// public R visit(IntArrayType n);
// public R visit(BooleanType n);
// public R visit(IntegerType n);
// public R visit(ObjectType n);
//
// //Statements
// public R visit(Block n);
// public R visit(If n);
// public R visit(While n);
// public R visit(Print n);
// public R visit(Assign n);
// public R visit(ArrayAssign n);
//
// //Expressions
// public R visit(And n);
// public R visit(LessThan n);
// public R visit(Plus n);
// public R visit(Minus n);
// public R visit(Times n);
// public R visit(ArrayLookup n);
// public R visit(ArrayLength n);
// public R visit(Call n);
// public R visit(IntegerLiteral n);
// public R visit(BooleanLiteral n);
// public R visit(IdentifierExp n);
// public R visit(This n);
// public R visit(NewArray n);
// public R visit(NewObject n);
// public R visit(Not not);
//
// }
// Path: src/java/minijava/ast/If.java
import minijava.visitor.Visitor;
package minijava.ast;
public class If extends Statement {
public final Expression tst;
public final Statement thn;
public final Statement els;
public If(Expression tst, Statement thn, Statement els) {
super();
this.tst = tst;
this.thn = thn;
this.els = els;
}
@Override | public <R> R accept(Visitor<R> v) { |
mikedouglas/MiniJava | src/java/minijava/ast/While.java | // Path: src/java/minijava/visitor/Visitor.java
// public interface Visitor<R> {
//
// //Lists
// public <T extends AST> R visit(NodeList<T> ns);
//
// //Declarations
// public R visit(Program n);
// public R visit(MainClass n);
// public R visit(ClassDecl n);
// public R visit(VarDecl n);
// public R visit(MethodDecl n);
//
// //Types
// public R visit(IntArrayType n);
// public R visit(BooleanType n);
// public R visit(IntegerType n);
// public R visit(ObjectType n);
//
// //Statements
// public R visit(Block n);
// public R visit(If n);
// public R visit(While n);
// public R visit(Print n);
// public R visit(Assign n);
// public R visit(ArrayAssign n);
//
// //Expressions
// public R visit(And n);
// public R visit(LessThan n);
// public R visit(Plus n);
// public R visit(Minus n);
// public R visit(Times n);
// public R visit(ArrayLookup n);
// public R visit(ArrayLength n);
// public R visit(Call n);
// public R visit(IntegerLiteral n);
// public R visit(BooleanLiteral n);
// public R visit(IdentifierExp n);
// public R visit(This n);
// public R visit(NewArray n);
// public R visit(NewObject n);
// public R visit(Not not);
//
// }
| import minijava.visitor.Visitor; | package minijava.ast;
public class While extends Statement {
public final Expression tst;
public final Statement body;
public While(Expression tst, Statement body) {
super();
this.tst = tst;
this.body = body;
}
@Override | // Path: src/java/minijava/visitor/Visitor.java
// public interface Visitor<R> {
//
// //Lists
// public <T extends AST> R visit(NodeList<T> ns);
//
// //Declarations
// public R visit(Program n);
// public R visit(MainClass n);
// public R visit(ClassDecl n);
// public R visit(VarDecl n);
// public R visit(MethodDecl n);
//
// //Types
// public R visit(IntArrayType n);
// public R visit(BooleanType n);
// public R visit(IntegerType n);
// public R visit(ObjectType n);
//
// //Statements
// public R visit(Block n);
// public R visit(If n);
// public R visit(While n);
// public R visit(Print n);
// public R visit(Assign n);
// public R visit(ArrayAssign n);
//
// //Expressions
// public R visit(And n);
// public R visit(LessThan n);
// public R visit(Plus n);
// public R visit(Minus n);
// public R visit(Times n);
// public R visit(ArrayLookup n);
// public R visit(ArrayLength n);
// public R visit(Call n);
// public R visit(IntegerLiteral n);
// public R visit(BooleanLiteral n);
// public R visit(IdentifierExp n);
// public R visit(This n);
// public R visit(NewArray n);
// public R visit(NewObject n);
// public R visit(Not not);
//
// }
// Path: src/java/minijava/ast/While.java
import minijava.visitor.Visitor;
package minijava.ast;
public class While extends Statement {
public final Expression tst;
public final Statement body;
public While(Expression tst, Statement body) {
super();
this.tst = tst;
this.body = body;
}
@Override | public <R> R accept(Visitor<R> v) { |
mikedouglas/MiniJava | src/java/minijava/typechecker/implementation/ClassEntry.java | // Path: src/java/minijava/ast/Type.java
// public abstract class Type extends AST {
//
// @Override
// public abstract boolean equals(Object other);
//
// }
//
// Path: src/java/minijava/util/ImpTable.java
// public class ImpTable<V> extends DefaultIndentable
// implements Iterable<Entry<String, V>>, Lookup<V>
// {
//
// public static class DuplicateException extends Exception {
//
// private static final long serialVersionUID = 8650830167061316305L;
//
// public DuplicateException(String arg0) {
// super(arg0);
// }
//
// }
//
// private Map<String, V> map = new HashMap<String, V>();
//
// @Override
// public Iterator<Entry<String,V>> iterator() {
// return map.entrySet().iterator();
// }
//
// /**
// * Insert an entry into the table. This modifies the table.
// * Duplicate entries (i.e. with the same id are not supported).
// * When a duplicate id is being entered a DuplicatException is
// * thrown.
// * <p>
// * Note: the name "put" different from the name "insert" in the
// * FunTable is deliberate. This will make sure you get compile
// * errors when you try to change code using imperative puts
// * to use functional inserts instead.
// */
// public void put(String id, V value) throws DuplicateException {
// Assert.assertNotNull(value);
// Assert.assertNotNull(id);
// V existing = map.get(id);
// if (existing!=null) throw new DuplicateException("Duplicate entry: "+id);
// map.put(id, value);
// }
//
// /**
// * Find an entry in the table. If no entry is found, null is returned.
// */
// public V lookup(String id) {
// return map.get(id);
// }
//
// @Override
// public void dump(IndentingWriter out) {
// out.println("Table {");
// out.indent();
// for (Entry<String, V> entry : this) {
// out.print(entry.getKey()+" = ");
// out.println(entry.getValue());
// }
// out.outdent();
// out.print("}");
// }
//
// public boolean isEmpty() {
// return size()==0;
// }
//
// @Override
// public int size() {
// return map.size();
// }
//
// }
//
// Path: src/java/minijava/util/Indentable.java
// public interface Indentable {
//
// void dump(IndentingWriter out);
//
// }
//
// Path: src/java/minijava/util/IndentingWriter.java
// public class IndentingWriter {
//
// /**
// * Current level of indentation.
// */
// private int indentation = 0;
//
// /**
// * This flag is true until we have printed something on a line.
// * We use this to postpone printing of indentation spaces until something is
// * actually printed on a line. This allows indentation level to be changed
// * even after a newline has already been printed.
// * => flag replaced by col field that keeps track of the current column
// */
// private boolean startOfLine = true;
//
// /**
// * Where to send the actual output to.
// */
// private PrintWriter out;
//
// private int col = 0;
//
// public IndentingWriter(PrintWriter out) {
// this.out = out;
// }
//
// public IndentingWriter(Writer out) {
// this(new PrintWriter(out));
// }
//
// public IndentingWriter(OutputStream out) {
// this(new OutputStreamWriter(out));
// }
//
// public IndentingWriter(File out) throws IOException {
// this(new BufferedWriter(new FileWriter(out)));
// }
//
// /**
// * Close the wrapped PrintWriter.
// */
// public void close() {
// out.close();
// }
//
// public void print(String string) {
// if (startOfLine) {
// startOfLine = false;
// for (int i = 0; i < indentation; i++) {
// print(" ");
// }
// }
// out.print(string);
// col += string.length();
// }
// public void println() {
// out.println();
// startOfLine = true;
// col = 0;
// }
//
// /**
// * Write an object to this IndentableWriter. If the object implements
// * Indentable, then that implementation will be used. Otherwise we fall back
// * on the object's toString method.
// */
// public void print(Object obj) {
// if (obj instanceof Indentable) {
// Indentable iObj = (Indentable) obj;
// iObj.dump(this);
// }
// else {
// this.print(""+obj);
// }
// }
//
// public void println(Object obj) {
// print(obj);
// println();
// }
//
// public void indent() {
// indentation++;
// }
// public void outdent() {
// indentation--;
// }
//
// public void tabTo(int toCol) {
// while (col<toCol)
// print(" ");
// }
//
// }
| import java.util.Map.Entry;
import minijava.ast.Type;
import minijava.util.ImpTable;
import minijava.util.Indentable;
import minijava.util.IndentingWriter; | package minijava.typechecker.implementation;
public class ClassEntry implements Indentable {
String parentName;
ClassEntry parentClass; | // Path: src/java/minijava/ast/Type.java
// public abstract class Type extends AST {
//
// @Override
// public abstract boolean equals(Object other);
//
// }
//
// Path: src/java/minijava/util/ImpTable.java
// public class ImpTable<V> extends DefaultIndentable
// implements Iterable<Entry<String, V>>, Lookup<V>
// {
//
// public static class DuplicateException extends Exception {
//
// private static final long serialVersionUID = 8650830167061316305L;
//
// public DuplicateException(String arg0) {
// super(arg0);
// }
//
// }
//
// private Map<String, V> map = new HashMap<String, V>();
//
// @Override
// public Iterator<Entry<String,V>> iterator() {
// return map.entrySet().iterator();
// }
//
// /**
// * Insert an entry into the table. This modifies the table.
// * Duplicate entries (i.e. with the same id are not supported).
// * When a duplicate id is being entered a DuplicatException is
// * thrown.
// * <p>
// * Note: the name "put" different from the name "insert" in the
// * FunTable is deliberate. This will make sure you get compile
// * errors when you try to change code using imperative puts
// * to use functional inserts instead.
// */
// public void put(String id, V value) throws DuplicateException {
// Assert.assertNotNull(value);
// Assert.assertNotNull(id);
// V existing = map.get(id);
// if (existing!=null) throw new DuplicateException("Duplicate entry: "+id);
// map.put(id, value);
// }
//
// /**
// * Find an entry in the table. If no entry is found, null is returned.
// */
// public V lookup(String id) {
// return map.get(id);
// }
//
// @Override
// public void dump(IndentingWriter out) {
// out.println("Table {");
// out.indent();
// for (Entry<String, V> entry : this) {
// out.print(entry.getKey()+" = ");
// out.println(entry.getValue());
// }
// out.outdent();
// out.print("}");
// }
//
// public boolean isEmpty() {
// return size()==0;
// }
//
// @Override
// public int size() {
// return map.size();
// }
//
// }
//
// Path: src/java/minijava/util/Indentable.java
// public interface Indentable {
//
// void dump(IndentingWriter out);
//
// }
//
// Path: src/java/minijava/util/IndentingWriter.java
// public class IndentingWriter {
//
// /**
// * Current level of indentation.
// */
// private int indentation = 0;
//
// /**
// * This flag is true until we have printed something on a line.
// * We use this to postpone printing of indentation spaces until something is
// * actually printed on a line. This allows indentation level to be changed
// * even after a newline has already been printed.
// * => flag replaced by col field that keeps track of the current column
// */
// private boolean startOfLine = true;
//
// /**
// * Where to send the actual output to.
// */
// private PrintWriter out;
//
// private int col = 0;
//
// public IndentingWriter(PrintWriter out) {
// this.out = out;
// }
//
// public IndentingWriter(Writer out) {
// this(new PrintWriter(out));
// }
//
// public IndentingWriter(OutputStream out) {
// this(new OutputStreamWriter(out));
// }
//
// public IndentingWriter(File out) throws IOException {
// this(new BufferedWriter(new FileWriter(out)));
// }
//
// /**
// * Close the wrapped PrintWriter.
// */
// public void close() {
// out.close();
// }
//
// public void print(String string) {
// if (startOfLine) {
// startOfLine = false;
// for (int i = 0; i < indentation; i++) {
// print(" ");
// }
// }
// out.print(string);
// col += string.length();
// }
// public void println() {
// out.println();
// startOfLine = true;
// col = 0;
// }
//
// /**
// * Write an object to this IndentableWriter. If the object implements
// * Indentable, then that implementation will be used. Otherwise we fall back
// * on the object's toString method.
// */
// public void print(Object obj) {
// if (obj instanceof Indentable) {
// Indentable iObj = (Indentable) obj;
// iObj.dump(this);
// }
// else {
// this.print(""+obj);
// }
// }
//
// public void println(Object obj) {
// print(obj);
// println();
// }
//
// public void indent() {
// indentation++;
// }
// public void outdent() {
// indentation--;
// }
//
// public void tabTo(int toCol) {
// while (col<toCol)
// print(" ");
// }
//
// }
// Path: src/java/minijava/typechecker/implementation/ClassEntry.java
import java.util.Map.Entry;
import minijava.ast.Type;
import minijava.util.ImpTable;
import minijava.util.Indentable;
import minijava.util.IndentingWriter;
package minijava.typechecker.implementation;
public class ClassEntry implements Indentable {
String parentName;
ClassEntry parentClass; | ImpTable<MethodEntry> methods; |
mikedouglas/MiniJava | src/java/minijava/typechecker/implementation/ClassEntry.java | // Path: src/java/minijava/ast/Type.java
// public abstract class Type extends AST {
//
// @Override
// public abstract boolean equals(Object other);
//
// }
//
// Path: src/java/minijava/util/ImpTable.java
// public class ImpTable<V> extends DefaultIndentable
// implements Iterable<Entry<String, V>>, Lookup<V>
// {
//
// public static class DuplicateException extends Exception {
//
// private static final long serialVersionUID = 8650830167061316305L;
//
// public DuplicateException(String arg0) {
// super(arg0);
// }
//
// }
//
// private Map<String, V> map = new HashMap<String, V>();
//
// @Override
// public Iterator<Entry<String,V>> iterator() {
// return map.entrySet().iterator();
// }
//
// /**
// * Insert an entry into the table. This modifies the table.
// * Duplicate entries (i.e. with the same id are not supported).
// * When a duplicate id is being entered a DuplicatException is
// * thrown.
// * <p>
// * Note: the name "put" different from the name "insert" in the
// * FunTable is deliberate. This will make sure you get compile
// * errors when you try to change code using imperative puts
// * to use functional inserts instead.
// */
// public void put(String id, V value) throws DuplicateException {
// Assert.assertNotNull(value);
// Assert.assertNotNull(id);
// V existing = map.get(id);
// if (existing!=null) throw new DuplicateException("Duplicate entry: "+id);
// map.put(id, value);
// }
//
// /**
// * Find an entry in the table. If no entry is found, null is returned.
// */
// public V lookup(String id) {
// return map.get(id);
// }
//
// @Override
// public void dump(IndentingWriter out) {
// out.println("Table {");
// out.indent();
// for (Entry<String, V> entry : this) {
// out.print(entry.getKey()+" = ");
// out.println(entry.getValue());
// }
// out.outdent();
// out.print("}");
// }
//
// public boolean isEmpty() {
// return size()==0;
// }
//
// @Override
// public int size() {
// return map.size();
// }
//
// }
//
// Path: src/java/minijava/util/Indentable.java
// public interface Indentable {
//
// void dump(IndentingWriter out);
//
// }
//
// Path: src/java/minijava/util/IndentingWriter.java
// public class IndentingWriter {
//
// /**
// * Current level of indentation.
// */
// private int indentation = 0;
//
// /**
// * This flag is true until we have printed something on a line.
// * We use this to postpone printing of indentation spaces until something is
// * actually printed on a line. This allows indentation level to be changed
// * even after a newline has already been printed.
// * => flag replaced by col field that keeps track of the current column
// */
// private boolean startOfLine = true;
//
// /**
// * Where to send the actual output to.
// */
// private PrintWriter out;
//
// private int col = 0;
//
// public IndentingWriter(PrintWriter out) {
// this.out = out;
// }
//
// public IndentingWriter(Writer out) {
// this(new PrintWriter(out));
// }
//
// public IndentingWriter(OutputStream out) {
// this(new OutputStreamWriter(out));
// }
//
// public IndentingWriter(File out) throws IOException {
// this(new BufferedWriter(new FileWriter(out)));
// }
//
// /**
// * Close the wrapped PrintWriter.
// */
// public void close() {
// out.close();
// }
//
// public void print(String string) {
// if (startOfLine) {
// startOfLine = false;
// for (int i = 0; i < indentation; i++) {
// print(" ");
// }
// }
// out.print(string);
// col += string.length();
// }
// public void println() {
// out.println();
// startOfLine = true;
// col = 0;
// }
//
// /**
// * Write an object to this IndentableWriter. If the object implements
// * Indentable, then that implementation will be used. Otherwise we fall back
// * on the object's toString method.
// */
// public void print(Object obj) {
// if (obj instanceof Indentable) {
// Indentable iObj = (Indentable) obj;
// iObj.dump(this);
// }
// else {
// this.print(""+obj);
// }
// }
//
// public void println(Object obj) {
// print(obj);
// println();
// }
//
// public void indent() {
// indentation++;
// }
// public void outdent() {
// indentation--;
// }
//
// public void tabTo(int toCol) {
// while (col<toCol)
// print(" ");
// }
//
// }
| import java.util.Map.Entry;
import minijava.ast.Type;
import minijava.util.ImpTable;
import minijava.util.Indentable;
import minijava.util.IndentingWriter; | package minijava.typechecker.implementation;
public class ClassEntry implements Indentable {
String parentName;
ClassEntry parentClass;
ImpTable<MethodEntry> methods; | // Path: src/java/minijava/ast/Type.java
// public abstract class Type extends AST {
//
// @Override
// public abstract boolean equals(Object other);
//
// }
//
// Path: src/java/minijava/util/ImpTable.java
// public class ImpTable<V> extends DefaultIndentable
// implements Iterable<Entry<String, V>>, Lookup<V>
// {
//
// public static class DuplicateException extends Exception {
//
// private static final long serialVersionUID = 8650830167061316305L;
//
// public DuplicateException(String arg0) {
// super(arg0);
// }
//
// }
//
// private Map<String, V> map = new HashMap<String, V>();
//
// @Override
// public Iterator<Entry<String,V>> iterator() {
// return map.entrySet().iterator();
// }
//
// /**
// * Insert an entry into the table. This modifies the table.
// * Duplicate entries (i.e. with the same id are not supported).
// * When a duplicate id is being entered a DuplicatException is
// * thrown.
// * <p>
// * Note: the name "put" different from the name "insert" in the
// * FunTable is deliberate. This will make sure you get compile
// * errors when you try to change code using imperative puts
// * to use functional inserts instead.
// */
// public void put(String id, V value) throws DuplicateException {
// Assert.assertNotNull(value);
// Assert.assertNotNull(id);
// V existing = map.get(id);
// if (existing!=null) throw new DuplicateException("Duplicate entry: "+id);
// map.put(id, value);
// }
//
// /**
// * Find an entry in the table. If no entry is found, null is returned.
// */
// public V lookup(String id) {
// return map.get(id);
// }
//
// @Override
// public void dump(IndentingWriter out) {
// out.println("Table {");
// out.indent();
// for (Entry<String, V> entry : this) {
// out.print(entry.getKey()+" = ");
// out.println(entry.getValue());
// }
// out.outdent();
// out.print("}");
// }
//
// public boolean isEmpty() {
// return size()==0;
// }
//
// @Override
// public int size() {
// return map.size();
// }
//
// }
//
// Path: src/java/minijava/util/Indentable.java
// public interface Indentable {
//
// void dump(IndentingWriter out);
//
// }
//
// Path: src/java/minijava/util/IndentingWriter.java
// public class IndentingWriter {
//
// /**
// * Current level of indentation.
// */
// private int indentation = 0;
//
// /**
// * This flag is true until we have printed something on a line.
// * We use this to postpone printing of indentation spaces until something is
// * actually printed on a line. This allows indentation level to be changed
// * even after a newline has already been printed.
// * => flag replaced by col field that keeps track of the current column
// */
// private boolean startOfLine = true;
//
// /**
// * Where to send the actual output to.
// */
// private PrintWriter out;
//
// private int col = 0;
//
// public IndentingWriter(PrintWriter out) {
// this.out = out;
// }
//
// public IndentingWriter(Writer out) {
// this(new PrintWriter(out));
// }
//
// public IndentingWriter(OutputStream out) {
// this(new OutputStreamWriter(out));
// }
//
// public IndentingWriter(File out) throws IOException {
// this(new BufferedWriter(new FileWriter(out)));
// }
//
// /**
// * Close the wrapped PrintWriter.
// */
// public void close() {
// out.close();
// }
//
// public void print(String string) {
// if (startOfLine) {
// startOfLine = false;
// for (int i = 0; i < indentation; i++) {
// print(" ");
// }
// }
// out.print(string);
// col += string.length();
// }
// public void println() {
// out.println();
// startOfLine = true;
// col = 0;
// }
//
// /**
// * Write an object to this IndentableWriter. If the object implements
// * Indentable, then that implementation will be used. Otherwise we fall back
// * on the object's toString method.
// */
// public void print(Object obj) {
// if (obj instanceof Indentable) {
// Indentable iObj = (Indentable) obj;
// iObj.dump(this);
// }
// else {
// this.print(""+obj);
// }
// }
//
// public void println(Object obj) {
// print(obj);
// println();
// }
//
// public void indent() {
// indentation++;
// }
// public void outdent() {
// indentation--;
// }
//
// public void tabTo(int toCol) {
// while (col<toCol)
// print(" ");
// }
//
// }
// Path: src/java/minijava/typechecker/implementation/ClassEntry.java
import java.util.Map.Entry;
import minijava.ast.Type;
import minijava.util.ImpTable;
import minijava.util.Indentable;
import minijava.util.IndentingWriter;
package minijava.typechecker.implementation;
public class ClassEntry implements Indentable {
String parentName;
ClassEntry parentClass;
ImpTable<MethodEntry> methods; | ImpTable<Type> fields; |
mikedouglas/MiniJava | src/java/minijava/ast/BooleanLiteral.java | // Path: src/java/minijava/visitor/Visitor.java
// public interface Visitor<R> {
//
// //Lists
// public <T extends AST> R visit(NodeList<T> ns);
//
// //Declarations
// public R visit(Program n);
// public R visit(MainClass n);
// public R visit(ClassDecl n);
// public R visit(VarDecl n);
// public R visit(MethodDecl n);
//
// //Types
// public R visit(IntArrayType n);
// public R visit(BooleanType n);
// public R visit(IntegerType n);
// public R visit(ObjectType n);
//
// //Statements
// public R visit(Block n);
// public R visit(If n);
// public R visit(While n);
// public R visit(Print n);
// public R visit(Assign n);
// public R visit(ArrayAssign n);
//
// //Expressions
// public R visit(And n);
// public R visit(LessThan n);
// public R visit(Plus n);
// public R visit(Minus n);
// public R visit(Times n);
// public R visit(ArrayLookup n);
// public R visit(ArrayLength n);
// public R visit(Call n);
// public R visit(IntegerLiteral n);
// public R visit(BooleanLiteral n);
// public R visit(IdentifierExp n);
// public R visit(This n);
// public R visit(NewArray n);
// public R visit(NewObject n);
// public R visit(Not not);
//
// }
| import minijava.visitor.Visitor; | package minijava.ast;
public class BooleanLiteral extends Expression {
public final boolean value;
public BooleanLiteral(boolean value) {
super();
super.setType(BooleanType.instance);
this.value = value;
}
@Override | // Path: src/java/minijava/visitor/Visitor.java
// public interface Visitor<R> {
//
// //Lists
// public <T extends AST> R visit(NodeList<T> ns);
//
// //Declarations
// public R visit(Program n);
// public R visit(MainClass n);
// public R visit(ClassDecl n);
// public R visit(VarDecl n);
// public R visit(MethodDecl n);
//
// //Types
// public R visit(IntArrayType n);
// public R visit(BooleanType n);
// public R visit(IntegerType n);
// public R visit(ObjectType n);
//
// //Statements
// public R visit(Block n);
// public R visit(If n);
// public R visit(While n);
// public R visit(Print n);
// public R visit(Assign n);
// public R visit(ArrayAssign n);
//
// //Expressions
// public R visit(And n);
// public R visit(LessThan n);
// public R visit(Plus n);
// public R visit(Minus n);
// public R visit(Times n);
// public R visit(ArrayLookup n);
// public R visit(ArrayLength n);
// public R visit(Call n);
// public R visit(IntegerLiteral n);
// public R visit(BooleanLiteral n);
// public R visit(IdentifierExp n);
// public R visit(This n);
// public R visit(NewArray n);
// public R visit(NewObject n);
// public R visit(Not not);
//
// }
// Path: src/java/minijava/ast/BooleanLiteral.java
import minijava.visitor.Visitor;
package minijava.ast;
public class BooleanLiteral extends Expression {
public final boolean value;
public BooleanLiteral(boolean value) {
super();
super.setType(BooleanType.instance);
this.value = value;
}
@Override | public <R> R accept(Visitor<R> v) { |
mikedouglas/MiniJava | src/java/minijava/ast/IdentifierExp.java | // Path: src/java/minijava/visitor/Visitor.java
// public interface Visitor<R> {
//
// //Lists
// public <T extends AST> R visit(NodeList<T> ns);
//
// //Declarations
// public R visit(Program n);
// public R visit(MainClass n);
// public R visit(ClassDecl n);
// public R visit(VarDecl n);
// public R visit(MethodDecl n);
//
// //Types
// public R visit(IntArrayType n);
// public R visit(BooleanType n);
// public R visit(IntegerType n);
// public R visit(ObjectType n);
//
// //Statements
// public R visit(Block n);
// public R visit(If n);
// public R visit(While n);
// public R visit(Print n);
// public R visit(Assign n);
// public R visit(ArrayAssign n);
//
// //Expressions
// public R visit(And n);
// public R visit(LessThan n);
// public R visit(Plus n);
// public R visit(Minus n);
// public R visit(Times n);
// public R visit(ArrayLookup n);
// public R visit(ArrayLength n);
// public R visit(Call n);
// public R visit(IntegerLiteral n);
// public R visit(BooleanLiteral n);
// public R visit(IdentifierExp n);
// public R visit(This n);
// public R visit(NewArray n);
// public R visit(NewObject n);
// public R visit(Not not);
//
// }
| import minijava.visitor.Visitor; | package minijava.ast;
public class IdentifierExp extends Expression {
public final String name;
public IdentifierExp(String name) {
super();
this.name = name;
}
@Override | // Path: src/java/minijava/visitor/Visitor.java
// public interface Visitor<R> {
//
// //Lists
// public <T extends AST> R visit(NodeList<T> ns);
//
// //Declarations
// public R visit(Program n);
// public R visit(MainClass n);
// public R visit(ClassDecl n);
// public R visit(VarDecl n);
// public R visit(MethodDecl n);
//
// //Types
// public R visit(IntArrayType n);
// public R visit(BooleanType n);
// public R visit(IntegerType n);
// public R visit(ObjectType n);
//
// //Statements
// public R visit(Block n);
// public R visit(If n);
// public R visit(While n);
// public R visit(Print n);
// public R visit(Assign n);
// public R visit(ArrayAssign n);
//
// //Expressions
// public R visit(And n);
// public R visit(LessThan n);
// public R visit(Plus n);
// public R visit(Minus n);
// public R visit(Times n);
// public R visit(ArrayLookup n);
// public R visit(ArrayLength n);
// public R visit(Call n);
// public R visit(IntegerLiteral n);
// public R visit(BooleanLiteral n);
// public R visit(IdentifierExp n);
// public R visit(This n);
// public R visit(NewArray n);
// public R visit(NewObject n);
// public R visit(Not not);
//
// }
// Path: src/java/minijava/ast/IdentifierExp.java
import minijava.visitor.Visitor;
package minijava.ast;
public class IdentifierExp extends Expression {
public final String name;
public IdentifierExp(String name) {
super();
this.name = name;
}
@Override | public <R> R accept(Visitor<R> v) { |
mikedouglas/MiniJava | src/java/minijava/ast/MainClass.java | // Path: src/java/minijava/visitor/Visitor.java
// public interface Visitor<R> {
//
// //Lists
// public <T extends AST> R visit(NodeList<T> ns);
//
// //Declarations
// public R visit(Program n);
// public R visit(MainClass n);
// public R visit(ClassDecl n);
// public R visit(VarDecl n);
// public R visit(MethodDecl n);
//
// //Types
// public R visit(IntArrayType n);
// public R visit(BooleanType n);
// public R visit(IntegerType n);
// public R visit(ObjectType n);
//
// //Statements
// public R visit(Block n);
// public R visit(If n);
// public R visit(While n);
// public R visit(Print n);
// public R visit(Assign n);
// public R visit(ArrayAssign n);
//
// //Expressions
// public R visit(And n);
// public R visit(LessThan n);
// public R visit(Plus n);
// public R visit(Minus n);
// public R visit(Times n);
// public R visit(ArrayLookup n);
// public R visit(ArrayLength n);
// public R visit(Call n);
// public R visit(IntegerLiteral n);
// public R visit(BooleanLiteral n);
// public R visit(IdentifierExp n);
// public R visit(This n);
// public R visit(NewArray n);
// public R visit(NewObject n);
// public R visit(Not not);
//
// }
| import minijava.visitor.Visitor; | package minijava.ast;
public class MainClass extends AST {
public final String className;
public final String argName;
public final Statement statement;
public MainClass(String className, String argName, Statement statement) {
super();
this.className = className;
this.argName = argName;
this.statement = statement;
}
@Override | // Path: src/java/minijava/visitor/Visitor.java
// public interface Visitor<R> {
//
// //Lists
// public <T extends AST> R visit(NodeList<T> ns);
//
// //Declarations
// public R visit(Program n);
// public R visit(MainClass n);
// public R visit(ClassDecl n);
// public R visit(VarDecl n);
// public R visit(MethodDecl n);
//
// //Types
// public R visit(IntArrayType n);
// public R visit(BooleanType n);
// public R visit(IntegerType n);
// public R visit(ObjectType n);
//
// //Statements
// public R visit(Block n);
// public R visit(If n);
// public R visit(While n);
// public R visit(Print n);
// public R visit(Assign n);
// public R visit(ArrayAssign n);
//
// //Expressions
// public R visit(And n);
// public R visit(LessThan n);
// public R visit(Plus n);
// public R visit(Minus n);
// public R visit(Times n);
// public R visit(ArrayLookup n);
// public R visit(ArrayLength n);
// public R visit(Call n);
// public R visit(IntegerLiteral n);
// public R visit(BooleanLiteral n);
// public R visit(IdentifierExp n);
// public R visit(This n);
// public R visit(NewArray n);
// public R visit(NewObject n);
// public R visit(Not not);
//
// }
// Path: src/java/minijava/ast/MainClass.java
import minijava.visitor.Visitor;
package minijava.ast;
public class MainClass extends AST {
public final String className;
public final String argName;
public final Statement statement;
public MainClass(String className, String argName, Statement statement) {
super();
this.className = className;
this.argName = argName;
this.statement = statement;
}
@Override | public <R> R accept(Visitor<R> v) { |
mikedouglas/MiniJava | src/java/minijava/typechecker/ErrorMessage.java | // Path: src/java/minijava/ast/Call.java
// public class Call extends Expression {
//
// public final Expression receiver;
// public final String name;
// public final NodeList<Expression> rands;
//
// public Call(Expression receiver, String name, NodeList<Expression> rands) {
// super();
// this.receiver = receiver;
// this.name = name;
// this.rands = rands;
// }
//
// @Override
// public <R> R accept(Visitor<R> v) {
// return v.visit(this);
// }
//
// }
//
// Path: src/java/minijava/ast/Expression.java
// public abstract class Expression extends AST {
//
// /**
// * The type of an expression is set by the type checking phase.
// */
// public Type type;
//
// public Type getType() {
// Assert.assertNotNull("Was this AST typechecked?", type);
// return type;
// }
//
// public void setType(Type theType) {
// //Assert.assertNull(type);
// //As our visitor is written, we expect the types of some nodes to be set multiple times.
// //as long as there is no conflict in these type settings, there is no problem, and the assertion has been
// //modified to reflect that.
// assert(type==null || type.equals(theType));
// type = theType;
// }
//
// }
//
// Path: src/java/minijava/ast/ObjectType.java
// public class ObjectType extends Type {
//
// public final String name;
//
// public ObjectType(String name) {
// super();
// this.name = name;
// }
//
// @Override
// public <R> R accept(Visitor<R> v) {
// return v.visit(this);
// }
//
// @Override
// public boolean equals(Object other) {
// if (this.getClass()==other.getClass()) {
// return this.name.equals(((ObjectType)other).name);
// }
// return false;
// }
// }
//
// Path: src/java/minijava/ast/Type.java
// public abstract class Type extends AST {
//
// @Override
// public abstract boolean equals(Object other);
//
// }
| import minijava.ast.Call;
import minijava.ast.Expression;
import minijava.ast.ObjectType;
import minijava.ast.Type; | package minijava.typechecker;
/**
* A class to represent Entries in an Error report.
* It provides static methods to create different types of messages.
* <p>
* If we assume that the TypeChecker only uses the ErrorReport and
* ErrorMessage classes to create error reports than we can use this
* to write relatively precise unit tests for the expected error output
* without specifying the exact syntax of expected error messages
* (Unit tests can use the instances of ErrorMessage class or assume that
* the implementation of the ErrorMessage class produces similar error Strings.
*/
public class ErrorMessage {
private String msg;
/**
* Constructor is private so that you can't make messages that are
* "arbitrarily formatted".
*/
private ErrorMessage(String msg) {
this.msg = msg;
}
public static ErrorMessage undefinedId(String name) {
return new ErrorMessage("Unbound Identifier: "+name);
}
public static ErrorMessage duplicateDefinition(String name) {
return new ErrorMessage("Multiply defined Identifier: "+name);
}
| // Path: src/java/minijava/ast/Call.java
// public class Call extends Expression {
//
// public final Expression receiver;
// public final String name;
// public final NodeList<Expression> rands;
//
// public Call(Expression receiver, String name, NodeList<Expression> rands) {
// super();
// this.receiver = receiver;
// this.name = name;
// this.rands = rands;
// }
//
// @Override
// public <R> R accept(Visitor<R> v) {
// return v.visit(this);
// }
//
// }
//
// Path: src/java/minijava/ast/Expression.java
// public abstract class Expression extends AST {
//
// /**
// * The type of an expression is set by the type checking phase.
// */
// public Type type;
//
// public Type getType() {
// Assert.assertNotNull("Was this AST typechecked?", type);
// return type;
// }
//
// public void setType(Type theType) {
// //Assert.assertNull(type);
// //As our visitor is written, we expect the types of some nodes to be set multiple times.
// //as long as there is no conflict in these type settings, there is no problem, and the assertion has been
// //modified to reflect that.
// assert(type==null || type.equals(theType));
// type = theType;
// }
//
// }
//
// Path: src/java/minijava/ast/ObjectType.java
// public class ObjectType extends Type {
//
// public final String name;
//
// public ObjectType(String name) {
// super();
// this.name = name;
// }
//
// @Override
// public <R> R accept(Visitor<R> v) {
// return v.visit(this);
// }
//
// @Override
// public boolean equals(Object other) {
// if (this.getClass()==other.getClass()) {
// return this.name.equals(((ObjectType)other).name);
// }
// return false;
// }
// }
//
// Path: src/java/minijava/ast/Type.java
// public abstract class Type extends AST {
//
// @Override
// public abstract boolean equals(Object other);
//
// }
// Path: src/java/minijava/typechecker/ErrorMessage.java
import minijava.ast.Call;
import minijava.ast.Expression;
import minijava.ast.ObjectType;
import minijava.ast.Type;
package minijava.typechecker;
/**
* A class to represent Entries in an Error report.
* It provides static methods to create different types of messages.
* <p>
* If we assume that the TypeChecker only uses the ErrorReport and
* ErrorMessage classes to create error reports than we can use this
* to write relatively precise unit tests for the expected error output
* without specifying the exact syntax of expected error messages
* (Unit tests can use the instances of ErrorMessage class or assume that
* the implementation of the ErrorMessage class produces similar error Strings.
*/
public class ErrorMessage {
private String msg;
/**
* Constructor is private so that you can't make messages that are
* "arbitrarily formatted".
*/
private ErrorMessage(String msg) {
this.msg = msg;
}
public static ErrorMessage undefinedId(String name) {
return new ErrorMessage("Unbound Identifier: "+name);
}
public static ErrorMessage duplicateDefinition(String name) {
return new ErrorMessage("Multiply defined Identifier: "+name);
}
| public static ErrorMessage typeError(Expression exp, Type expected, |
mikedouglas/MiniJava | src/java/minijava/typechecker/ErrorMessage.java | // Path: src/java/minijava/ast/Call.java
// public class Call extends Expression {
//
// public final Expression receiver;
// public final String name;
// public final NodeList<Expression> rands;
//
// public Call(Expression receiver, String name, NodeList<Expression> rands) {
// super();
// this.receiver = receiver;
// this.name = name;
// this.rands = rands;
// }
//
// @Override
// public <R> R accept(Visitor<R> v) {
// return v.visit(this);
// }
//
// }
//
// Path: src/java/minijava/ast/Expression.java
// public abstract class Expression extends AST {
//
// /**
// * The type of an expression is set by the type checking phase.
// */
// public Type type;
//
// public Type getType() {
// Assert.assertNotNull("Was this AST typechecked?", type);
// return type;
// }
//
// public void setType(Type theType) {
// //Assert.assertNull(type);
// //As our visitor is written, we expect the types of some nodes to be set multiple times.
// //as long as there is no conflict in these type settings, there is no problem, and the assertion has been
// //modified to reflect that.
// assert(type==null || type.equals(theType));
// type = theType;
// }
//
// }
//
// Path: src/java/minijava/ast/ObjectType.java
// public class ObjectType extends Type {
//
// public final String name;
//
// public ObjectType(String name) {
// super();
// this.name = name;
// }
//
// @Override
// public <R> R accept(Visitor<R> v) {
// return v.visit(this);
// }
//
// @Override
// public boolean equals(Object other) {
// if (this.getClass()==other.getClass()) {
// return this.name.equals(((ObjectType)other).name);
// }
// return false;
// }
// }
//
// Path: src/java/minijava/ast/Type.java
// public abstract class Type extends AST {
//
// @Override
// public abstract boolean equals(Object other);
//
// }
| import minijava.ast.Call;
import minijava.ast.Expression;
import minijava.ast.ObjectType;
import minijava.ast.Type; | package minijava.typechecker;
/**
* A class to represent Entries in an Error report.
* It provides static methods to create different types of messages.
* <p>
* If we assume that the TypeChecker only uses the ErrorReport and
* ErrorMessage classes to create error reports than we can use this
* to write relatively precise unit tests for the expected error output
* without specifying the exact syntax of expected error messages
* (Unit tests can use the instances of ErrorMessage class or assume that
* the implementation of the ErrorMessage class produces similar error Strings.
*/
public class ErrorMessage {
private String msg;
/**
* Constructor is private so that you can't make messages that are
* "arbitrarily formatted".
*/
private ErrorMessage(String msg) {
this.msg = msg;
}
public static ErrorMessage undefinedId(String name) {
return new ErrorMessage("Unbound Identifier: "+name);
}
public static ErrorMessage duplicateDefinition(String name) {
return new ErrorMessage("Multiply defined Identifier: "+name);
}
| // Path: src/java/minijava/ast/Call.java
// public class Call extends Expression {
//
// public final Expression receiver;
// public final String name;
// public final NodeList<Expression> rands;
//
// public Call(Expression receiver, String name, NodeList<Expression> rands) {
// super();
// this.receiver = receiver;
// this.name = name;
// this.rands = rands;
// }
//
// @Override
// public <R> R accept(Visitor<R> v) {
// return v.visit(this);
// }
//
// }
//
// Path: src/java/minijava/ast/Expression.java
// public abstract class Expression extends AST {
//
// /**
// * The type of an expression is set by the type checking phase.
// */
// public Type type;
//
// public Type getType() {
// Assert.assertNotNull("Was this AST typechecked?", type);
// return type;
// }
//
// public void setType(Type theType) {
// //Assert.assertNull(type);
// //As our visitor is written, we expect the types of some nodes to be set multiple times.
// //as long as there is no conflict in these type settings, there is no problem, and the assertion has been
// //modified to reflect that.
// assert(type==null || type.equals(theType));
// type = theType;
// }
//
// }
//
// Path: src/java/minijava/ast/ObjectType.java
// public class ObjectType extends Type {
//
// public final String name;
//
// public ObjectType(String name) {
// super();
// this.name = name;
// }
//
// @Override
// public <R> R accept(Visitor<R> v) {
// return v.visit(this);
// }
//
// @Override
// public boolean equals(Object other) {
// if (this.getClass()==other.getClass()) {
// return this.name.equals(((ObjectType)other).name);
// }
// return false;
// }
// }
//
// Path: src/java/minijava/ast/Type.java
// public abstract class Type extends AST {
//
// @Override
// public abstract boolean equals(Object other);
//
// }
// Path: src/java/minijava/typechecker/ErrorMessage.java
import minijava.ast.Call;
import minijava.ast.Expression;
import minijava.ast.ObjectType;
import minijava.ast.Type;
package minijava.typechecker;
/**
* A class to represent Entries in an Error report.
* It provides static methods to create different types of messages.
* <p>
* If we assume that the TypeChecker only uses the ErrorReport and
* ErrorMessage classes to create error reports than we can use this
* to write relatively precise unit tests for the expected error output
* without specifying the exact syntax of expected error messages
* (Unit tests can use the instances of ErrorMessage class or assume that
* the implementation of the ErrorMessage class produces similar error Strings.
*/
public class ErrorMessage {
private String msg;
/**
* Constructor is private so that you can't make messages that are
* "arbitrarily formatted".
*/
private ErrorMessage(String msg) {
this.msg = msg;
}
public static ErrorMessage undefinedId(String name) {
return new ErrorMessage("Unbound Identifier: "+name);
}
public static ErrorMessage duplicateDefinition(String name) {
return new ErrorMessage("Multiply defined Identifier: "+name);
}
| public static ErrorMessage typeError(Expression exp, Type expected, |
mikedouglas/MiniJava | src/java/minijava/typechecker/ErrorMessage.java | // Path: src/java/minijava/ast/Call.java
// public class Call extends Expression {
//
// public final Expression receiver;
// public final String name;
// public final NodeList<Expression> rands;
//
// public Call(Expression receiver, String name, NodeList<Expression> rands) {
// super();
// this.receiver = receiver;
// this.name = name;
// this.rands = rands;
// }
//
// @Override
// public <R> R accept(Visitor<R> v) {
// return v.visit(this);
// }
//
// }
//
// Path: src/java/minijava/ast/Expression.java
// public abstract class Expression extends AST {
//
// /**
// * The type of an expression is set by the type checking phase.
// */
// public Type type;
//
// public Type getType() {
// Assert.assertNotNull("Was this AST typechecked?", type);
// return type;
// }
//
// public void setType(Type theType) {
// //Assert.assertNull(type);
// //As our visitor is written, we expect the types of some nodes to be set multiple times.
// //as long as there is no conflict in these type settings, there is no problem, and the assertion has been
// //modified to reflect that.
// assert(type==null || type.equals(theType));
// type = theType;
// }
//
// }
//
// Path: src/java/minijava/ast/ObjectType.java
// public class ObjectType extends Type {
//
// public final String name;
//
// public ObjectType(String name) {
// super();
// this.name = name;
// }
//
// @Override
// public <R> R accept(Visitor<R> v) {
// return v.visit(this);
// }
//
// @Override
// public boolean equals(Object other) {
// if (this.getClass()==other.getClass()) {
// return this.name.equals(((ObjectType)other).name);
// }
// return false;
// }
// }
//
// Path: src/java/minijava/ast/Type.java
// public abstract class Type extends AST {
//
// @Override
// public abstract boolean equals(Object other);
//
// }
| import minijava.ast.Call;
import minijava.ast.Expression;
import minijava.ast.ObjectType;
import minijava.ast.Type; | package minijava.typechecker;
/**
* A class to represent Entries in an Error report.
* It provides static methods to create different types of messages.
* <p>
* If we assume that the TypeChecker only uses the ErrorReport and
* ErrorMessage classes to create error reports than we can use this
* to write relatively precise unit tests for the expected error output
* without specifying the exact syntax of expected error messages
* (Unit tests can use the instances of ErrorMessage class or assume that
* the implementation of the ErrorMessage class produces similar error Strings.
*/
public class ErrorMessage {
private String msg;
/**
* Constructor is private so that you can't make messages that are
* "arbitrarily formatted".
*/
private ErrorMessage(String msg) {
this.msg = msg;
}
public static ErrorMessage undefinedId(String name) {
return new ErrorMessage("Unbound Identifier: "+name);
}
public static ErrorMessage duplicateDefinition(String name) {
return new ErrorMessage("Multiply defined Identifier: "+name);
}
public static ErrorMessage typeError(Expression exp, Type expected,
Type actual) {
return new ErrorMessage(exp+" has type "+actual+" expected "+expected);
}
public static ErrorMessage typeErrorExpectObject(Expression exp, Type actual) {
return new ErrorMessage(exp+" has type "+actual+" expected an object type");
}
| // Path: src/java/minijava/ast/Call.java
// public class Call extends Expression {
//
// public final Expression receiver;
// public final String name;
// public final NodeList<Expression> rands;
//
// public Call(Expression receiver, String name, NodeList<Expression> rands) {
// super();
// this.receiver = receiver;
// this.name = name;
// this.rands = rands;
// }
//
// @Override
// public <R> R accept(Visitor<R> v) {
// return v.visit(this);
// }
//
// }
//
// Path: src/java/minijava/ast/Expression.java
// public abstract class Expression extends AST {
//
// /**
// * The type of an expression is set by the type checking phase.
// */
// public Type type;
//
// public Type getType() {
// Assert.assertNotNull("Was this AST typechecked?", type);
// return type;
// }
//
// public void setType(Type theType) {
// //Assert.assertNull(type);
// //As our visitor is written, we expect the types of some nodes to be set multiple times.
// //as long as there is no conflict in these type settings, there is no problem, and the assertion has been
// //modified to reflect that.
// assert(type==null || type.equals(theType));
// type = theType;
// }
//
// }
//
// Path: src/java/minijava/ast/ObjectType.java
// public class ObjectType extends Type {
//
// public final String name;
//
// public ObjectType(String name) {
// super();
// this.name = name;
// }
//
// @Override
// public <R> R accept(Visitor<R> v) {
// return v.visit(this);
// }
//
// @Override
// public boolean equals(Object other) {
// if (this.getClass()==other.getClass()) {
// return this.name.equals(((ObjectType)other).name);
// }
// return false;
// }
// }
//
// Path: src/java/minijava/ast/Type.java
// public abstract class Type extends AST {
//
// @Override
// public abstract boolean equals(Object other);
//
// }
// Path: src/java/minijava/typechecker/ErrorMessage.java
import minijava.ast.Call;
import minijava.ast.Expression;
import minijava.ast.ObjectType;
import minijava.ast.Type;
package minijava.typechecker;
/**
* A class to represent Entries in an Error report.
* It provides static methods to create different types of messages.
* <p>
* If we assume that the TypeChecker only uses the ErrorReport and
* ErrorMessage classes to create error reports than we can use this
* to write relatively precise unit tests for the expected error output
* without specifying the exact syntax of expected error messages
* (Unit tests can use the instances of ErrorMessage class or assume that
* the implementation of the ErrorMessage class produces similar error Strings.
*/
public class ErrorMessage {
private String msg;
/**
* Constructor is private so that you can't make messages that are
* "arbitrarily formatted".
*/
private ErrorMessage(String msg) {
this.msg = msg;
}
public static ErrorMessage undefinedId(String name) {
return new ErrorMessage("Unbound Identifier: "+name);
}
public static ErrorMessage duplicateDefinition(String name) {
return new ErrorMessage("Multiply defined Identifier: "+name);
}
public static ErrorMessage typeError(Expression exp, Type expected,
Type actual) {
return new ErrorMessage(exp+" has type "+actual+" expected "+expected);
}
public static ErrorMessage typeErrorExpectObject(Expression exp, Type actual) {
return new ErrorMessage(exp+" has type "+actual+" expected an object type");
}
| public static ErrorMessage wrongNumberOfArguments(Call call, int expected) { |
mikedouglas/MiniJava | src/java/minijava/typechecker/ErrorMessage.java | // Path: src/java/minijava/ast/Call.java
// public class Call extends Expression {
//
// public final Expression receiver;
// public final String name;
// public final NodeList<Expression> rands;
//
// public Call(Expression receiver, String name, NodeList<Expression> rands) {
// super();
// this.receiver = receiver;
// this.name = name;
// this.rands = rands;
// }
//
// @Override
// public <R> R accept(Visitor<R> v) {
// return v.visit(this);
// }
//
// }
//
// Path: src/java/minijava/ast/Expression.java
// public abstract class Expression extends AST {
//
// /**
// * The type of an expression is set by the type checking phase.
// */
// public Type type;
//
// public Type getType() {
// Assert.assertNotNull("Was this AST typechecked?", type);
// return type;
// }
//
// public void setType(Type theType) {
// //Assert.assertNull(type);
// //As our visitor is written, we expect the types of some nodes to be set multiple times.
// //as long as there is no conflict in these type settings, there is no problem, and the assertion has been
// //modified to reflect that.
// assert(type==null || type.equals(theType));
// type = theType;
// }
//
// }
//
// Path: src/java/minijava/ast/ObjectType.java
// public class ObjectType extends Type {
//
// public final String name;
//
// public ObjectType(String name) {
// super();
// this.name = name;
// }
//
// @Override
// public <R> R accept(Visitor<R> v) {
// return v.visit(this);
// }
//
// @Override
// public boolean equals(Object other) {
// if (this.getClass()==other.getClass()) {
// return this.name.equals(((ObjectType)other).name);
// }
// return false;
// }
// }
//
// Path: src/java/minijava/ast/Type.java
// public abstract class Type extends AST {
//
// @Override
// public abstract boolean equals(Object other);
//
// }
| import minijava.ast.Call;
import minijava.ast.Expression;
import minijava.ast.ObjectType;
import minijava.ast.Type; | package minijava.typechecker;
/**
* A class to represent Entries in an Error report.
* It provides static methods to create different types of messages.
* <p>
* If we assume that the TypeChecker only uses the ErrorReport and
* ErrorMessage classes to create error reports than we can use this
* to write relatively precise unit tests for the expected error output
* without specifying the exact syntax of expected error messages
* (Unit tests can use the instances of ErrorMessage class or assume that
* the implementation of the ErrorMessage class produces similar error Strings.
*/
public class ErrorMessage {
private String msg;
/**
* Constructor is private so that you can't make messages that are
* "arbitrarily formatted".
*/
private ErrorMessage(String msg) {
this.msg = msg;
}
public static ErrorMessage undefinedId(String name) {
return new ErrorMessage("Unbound Identifier: "+name);
}
public static ErrorMessage duplicateDefinition(String name) {
return new ErrorMessage("Multiply defined Identifier: "+name);
}
public static ErrorMessage typeError(Expression exp, Type expected,
Type actual) {
return new ErrorMessage(exp+" has type "+actual+" expected "+expected);
}
public static ErrorMessage typeErrorExpectObject(Expression exp, Type actual) {
return new ErrorMessage(exp+" has type "+actual+" expected an object type");
}
public static ErrorMessage wrongNumberOfArguments(Call call, int expected) {
return new ErrorMessage("Wrong number of arguments (expected "+expected+"): "+call);
}
| // Path: src/java/minijava/ast/Call.java
// public class Call extends Expression {
//
// public final Expression receiver;
// public final String name;
// public final NodeList<Expression> rands;
//
// public Call(Expression receiver, String name, NodeList<Expression> rands) {
// super();
// this.receiver = receiver;
// this.name = name;
// this.rands = rands;
// }
//
// @Override
// public <R> R accept(Visitor<R> v) {
// return v.visit(this);
// }
//
// }
//
// Path: src/java/minijava/ast/Expression.java
// public abstract class Expression extends AST {
//
// /**
// * The type of an expression is set by the type checking phase.
// */
// public Type type;
//
// public Type getType() {
// Assert.assertNotNull("Was this AST typechecked?", type);
// return type;
// }
//
// public void setType(Type theType) {
// //Assert.assertNull(type);
// //As our visitor is written, we expect the types of some nodes to be set multiple times.
// //as long as there is no conflict in these type settings, there is no problem, and the assertion has been
// //modified to reflect that.
// assert(type==null || type.equals(theType));
// type = theType;
// }
//
// }
//
// Path: src/java/minijava/ast/ObjectType.java
// public class ObjectType extends Type {
//
// public final String name;
//
// public ObjectType(String name) {
// super();
// this.name = name;
// }
//
// @Override
// public <R> R accept(Visitor<R> v) {
// return v.visit(this);
// }
//
// @Override
// public boolean equals(Object other) {
// if (this.getClass()==other.getClass()) {
// return this.name.equals(((ObjectType)other).name);
// }
// return false;
// }
// }
//
// Path: src/java/minijava/ast/Type.java
// public abstract class Type extends AST {
//
// @Override
// public abstract boolean equals(Object other);
//
// }
// Path: src/java/minijava/typechecker/ErrorMessage.java
import minijava.ast.Call;
import minijava.ast.Expression;
import minijava.ast.ObjectType;
import minijava.ast.Type;
package minijava.typechecker;
/**
* A class to represent Entries in an Error report.
* It provides static methods to create different types of messages.
* <p>
* If we assume that the TypeChecker only uses the ErrorReport and
* ErrorMessage classes to create error reports than we can use this
* to write relatively precise unit tests for the expected error output
* without specifying the exact syntax of expected error messages
* (Unit tests can use the instances of ErrorMessage class or assume that
* the implementation of the ErrorMessage class produces similar error Strings.
*/
public class ErrorMessage {
private String msg;
/**
* Constructor is private so that you can't make messages that are
* "arbitrarily formatted".
*/
private ErrorMessage(String msg) {
this.msg = msg;
}
public static ErrorMessage undefinedId(String name) {
return new ErrorMessage("Unbound Identifier: "+name);
}
public static ErrorMessage duplicateDefinition(String name) {
return new ErrorMessage("Multiply defined Identifier: "+name);
}
public static ErrorMessage typeError(Expression exp, Type expected,
Type actual) {
return new ErrorMessage(exp+" has type "+actual+" expected "+expected);
}
public static ErrorMessage typeErrorExpectObject(Expression exp, Type actual) {
return new ErrorMessage(exp+" has type "+actual+" expected an object type");
}
public static ErrorMessage wrongNumberOfArguments(Call call, int expected) {
return new ErrorMessage("Wrong number of arguments (expected "+expected+"): "+call);
}
| public static ErrorMessage badMethodOverriding(ObjectType objectType, |
mikedouglas/MiniJava | src/java/minijava/ast/And.java | // Path: src/java/minijava/visitor/Visitor.java
// public interface Visitor<R> {
//
// //Lists
// public <T extends AST> R visit(NodeList<T> ns);
//
// //Declarations
// public R visit(Program n);
// public R visit(MainClass n);
// public R visit(ClassDecl n);
// public R visit(VarDecl n);
// public R visit(MethodDecl n);
//
// //Types
// public R visit(IntArrayType n);
// public R visit(BooleanType n);
// public R visit(IntegerType n);
// public R visit(ObjectType n);
//
// //Statements
// public R visit(Block n);
// public R visit(If n);
// public R visit(While n);
// public R visit(Print n);
// public R visit(Assign n);
// public R visit(ArrayAssign n);
//
// //Expressions
// public R visit(And n);
// public R visit(LessThan n);
// public R visit(Plus n);
// public R visit(Minus n);
// public R visit(Times n);
// public R visit(ArrayLookup n);
// public R visit(ArrayLength n);
// public R visit(Call n);
// public R visit(IntegerLiteral n);
// public R visit(BooleanLiteral n);
// public R visit(IdentifierExp n);
// public R visit(This n);
// public R visit(NewArray n);
// public R visit(NewObject n);
// public R visit(Not not);
//
// }
| import minijava.visitor.Visitor; | package minijava.ast;
public class And extends Expression {
public final Expression e1;
public final Expression e2;
public And(Expression e1, Expression e2) {
super();
super.setType(BooleanType.instance);
this.e1 = e1;
this.e2 = e2;
}
@Override | // Path: src/java/minijava/visitor/Visitor.java
// public interface Visitor<R> {
//
// //Lists
// public <T extends AST> R visit(NodeList<T> ns);
//
// //Declarations
// public R visit(Program n);
// public R visit(MainClass n);
// public R visit(ClassDecl n);
// public R visit(VarDecl n);
// public R visit(MethodDecl n);
//
// //Types
// public R visit(IntArrayType n);
// public R visit(BooleanType n);
// public R visit(IntegerType n);
// public R visit(ObjectType n);
//
// //Statements
// public R visit(Block n);
// public R visit(If n);
// public R visit(While n);
// public R visit(Print n);
// public R visit(Assign n);
// public R visit(ArrayAssign n);
//
// //Expressions
// public R visit(And n);
// public R visit(LessThan n);
// public R visit(Plus n);
// public R visit(Minus n);
// public R visit(Times n);
// public R visit(ArrayLookup n);
// public R visit(ArrayLength n);
// public R visit(Call n);
// public R visit(IntegerLiteral n);
// public R visit(BooleanLiteral n);
// public R visit(IdentifierExp n);
// public R visit(This n);
// public R visit(NewArray n);
// public R visit(NewObject n);
// public R visit(Not not);
//
// }
// Path: src/java/minijava/ast/And.java
import minijava.visitor.Visitor;
package minijava.ast;
public class And extends Expression {
public final Expression e1;
public final Expression e2;
public And(Expression e1, Expression e2) {
super();
super.setType(BooleanType.instance);
this.e1 = e1;
this.e2 = e2;
}
@Override | public <R> R accept(Visitor<R> v) { |
mikedouglas/MiniJava | src/java/minijava/ast/ArrayLookup.java | // Path: src/java/minijava/visitor/Visitor.java
// public interface Visitor<R> {
//
// //Lists
// public <T extends AST> R visit(NodeList<T> ns);
//
// //Declarations
// public R visit(Program n);
// public R visit(MainClass n);
// public R visit(ClassDecl n);
// public R visit(VarDecl n);
// public R visit(MethodDecl n);
//
// //Types
// public R visit(IntArrayType n);
// public R visit(BooleanType n);
// public R visit(IntegerType n);
// public R visit(ObjectType n);
//
// //Statements
// public R visit(Block n);
// public R visit(If n);
// public R visit(While n);
// public R visit(Print n);
// public R visit(Assign n);
// public R visit(ArrayAssign n);
//
// //Expressions
// public R visit(And n);
// public R visit(LessThan n);
// public R visit(Plus n);
// public R visit(Minus n);
// public R visit(Times n);
// public R visit(ArrayLookup n);
// public R visit(ArrayLength n);
// public R visit(Call n);
// public R visit(IntegerLiteral n);
// public R visit(BooleanLiteral n);
// public R visit(IdentifierExp n);
// public R visit(This n);
// public R visit(NewArray n);
// public R visit(NewObject n);
// public R visit(Not not);
//
// }
| import minijava.visitor.Visitor; | package minijava.ast;
public class ArrayLookup extends Expression {
public final Expression array;
public final Expression index;
public ArrayLookup(Expression array, Expression index) {
super();
super.setType(IntegerType.instance);//all arrays contain integers
this.array = array;
this.index = index;
}
@Override | // Path: src/java/minijava/visitor/Visitor.java
// public interface Visitor<R> {
//
// //Lists
// public <T extends AST> R visit(NodeList<T> ns);
//
// //Declarations
// public R visit(Program n);
// public R visit(MainClass n);
// public R visit(ClassDecl n);
// public R visit(VarDecl n);
// public R visit(MethodDecl n);
//
// //Types
// public R visit(IntArrayType n);
// public R visit(BooleanType n);
// public R visit(IntegerType n);
// public R visit(ObjectType n);
//
// //Statements
// public R visit(Block n);
// public R visit(If n);
// public R visit(While n);
// public R visit(Print n);
// public R visit(Assign n);
// public R visit(ArrayAssign n);
//
// //Expressions
// public R visit(And n);
// public R visit(LessThan n);
// public R visit(Plus n);
// public R visit(Minus n);
// public R visit(Times n);
// public R visit(ArrayLookup n);
// public R visit(ArrayLength n);
// public R visit(Call n);
// public R visit(IntegerLiteral n);
// public R visit(BooleanLiteral n);
// public R visit(IdentifierExp n);
// public R visit(This n);
// public R visit(NewArray n);
// public R visit(NewObject n);
// public R visit(Not not);
//
// }
// Path: src/java/minijava/ast/ArrayLookup.java
import minijava.visitor.Visitor;
package minijava.ast;
public class ArrayLookup extends Expression {
public final Expression array;
public final Expression index;
public ArrayLookup(Expression array, Expression index) {
super();
super.setType(IntegerType.instance);//all arrays contain integers
this.array = array;
this.index = index;
}
@Override | public <R> R accept(Visitor<R> v) { |
mikedouglas/MiniJava | src/java/minijava/ast/Assign.java | // Path: src/java/minijava/visitor/Visitor.java
// public interface Visitor<R> {
//
// //Lists
// public <T extends AST> R visit(NodeList<T> ns);
//
// //Declarations
// public R visit(Program n);
// public R visit(MainClass n);
// public R visit(ClassDecl n);
// public R visit(VarDecl n);
// public R visit(MethodDecl n);
//
// //Types
// public R visit(IntArrayType n);
// public R visit(BooleanType n);
// public R visit(IntegerType n);
// public R visit(ObjectType n);
//
// //Statements
// public R visit(Block n);
// public R visit(If n);
// public R visit(While n);
// public R visit(Print n);
// public R visit(Assign n);
// public R visit(ArrayAssign n);
//
// //Expressions
// public R visit(And n);
// public R visit(LessThan n);
// public R visit(Plus n);
// public R visit(Minus n);
// public R visit(Times n);
// public R visit(ArrayLookup n);
// public R visit(ArrayLength n);
// public R visit(Call n);
// public R visit(IntegerLiteral n);
// public R visit(BooleanLiteral n);
// public R visit(IdentifierExp n);
// public R visit(This n);
// public R visit(NewArray n);
// public R visit(NewObject n);
// public R visit(Not not);
//
// }
| import minijava.visitor.Visitor; | package minijava.ast;
public class Assign extends Statement {
public final String name;
public final Expression value;
public Assign(String name, Expression value) {
super();
this.name = name;
this.value = value;
}
@Override | // Path: src/java/minijava/visitor/Visitor.java
// public interface Visitor<R> {
//
// //Lists
// public <T extends AST> R visit(NodeList<T> ns);
//
// //Declarations
// public R visit(Program n);
// public R visit(MainClass n);
// public R visit(ClassDecl n);
// public R visit(VarDecl n);
// public R visit(MethodDecl n);
//
// //Types
// public R visit(IntArrayType n);
// public R visit(BooleanType n);
// public R visit(IntegerType n);
// public R visit(ObjectType n);
//
// //Statements
// public R visit(Block n);
// public R visit(If n);
// public R visit(While n);
// public R visit(Print n);
// public R visit(Assign n);
// public R visit(ArrayAssign n);
//
// //Expressions
// public R visit(And n);
// public R visit(LessThan n);
// public R visit(Plus n);
// public R visit(Minus n);
// public R visit(Times n);
// public R visit(ArrayLookup n);
// public R visit(ArrayLength n);
// public R visit(Call n);
// public R visit(IntegerLiteral n);
// public R visit(BooleanLiteral n);
// public R visit(IdentifierExp n);
// public R visit(This n);
// public R visit(NewArray n);
// public R visit(NewObject n);
// public R visit(Not not);
//
// }
// Path: src/java/minijava/ast/Assign.java
import minijava.visitor.Visitor;
package minijava.ast;
public class Assign extends Statement {
public final String name;
public final Expression value;
public Assign(String name, Expression value) {
super();
this.name = name;
this.value = value;
}
@Override | public <R> R accept(Visitor<R> v) { |
mikedouglas/MiniJava | src/java/minijava/ast/Call.java | // Path: src/java/minijava/visitor/Visitor.java
// public interface Visitor<R> {
//
// //Lists
// public <T extends AST> R visit(NodeList<T> ns);
//
// //Declarations
// public R visit(Program n);
// public R visit(MainClass n);
// public R visit(ClassDecl n);
// public R visit(VarDecl n);
// public R visit(MethodDecl n);
//
// //Types
// public R visit(IntArrayType n);
// public R visit(BooleanType n);
// public R visit(IntegerType n);
// public R visit(ObjectType n);
//
// //Statements
// public R visit(Block n);
// public R visit(If n);
// public R visit(While n);
// public R visit(Print n);
// public R visit(Assign n);
// public R visit(ArrayAssign n);
//
// //Expressions
// public R visit(And n);
// public R visit(LessThan n);
// public R visit(Plus n);
// public R visit(Minus n);
// public R visit(Times n);
// public R visit(ArrayLookup n);
// public R visit(ArrayLength n);
// public R visit(Call n);
// public R visit(IntegerLiteral n);
// public R visit(BooleanLiteral n);
// public R visit(IdentifierExp n);
// public R visit(This n);
// public R visit(NewArray n);
// public R visit(NewObject n);
// public R visit(Not not);
//
// }
| import minijava.visitor.Visitor; | package minijava.ast;
public class Call extends Expression {
public final Expression receiver;
public final String name;
public final NodeList<Expression> rands;
public Call(Expression receiver, String name, NodeList<Expression> rands) {
super();
this.receiver = receiver;
this.name = name;
this.rands = rands;
}
@Override | // Path: src/java/minijava/visitor/Visitor.java
// public interface Visitor<R> {
//
// //Lists
// public <T extends AST> R visit(NodeList<T> ns);
//
// //Declarations
// public R visit(Program n);
// public R visit(MainClass n);
// public R visit(ClassDecl n);
// public R visit(VarDecl n);
// public R visit(MethodDecl n);
//
// //Types
// public R visit(IntArrayType n);
// public R visit(BooleanType n);
// public R visit(IntegerType n);
// public R visit(ObjectType n);
//
// //Statements
// public R visit(Block n);
// public R visit(If n);
// public R visit(While n);
// public R visit(Print n);
// public R visit(Assign n);
// public R visit(ArrayAssign n);
//
// //Expressions
// public R visit(And n);
// public R visit(LessThan n);
// public R visit(Plus n);
// public R visit(Minus n);
// public R visit(Times n);
// public R visit(ArrayLookup n);
// public R visit(ArrayLength n);
// public R visit(Call n);
// public R visit(IntegerLiteral n);
// public R visit(BooleanLiteral n);
// public R visit(IdentifierExp n);
// public R visit(This n);
// public R visit(NewArray n);
// public R visit(NewObject n);
// public R visit(Not not);
//
// }
// Path: src/java/minijava/ast/Call.java
import minijava.visitor.Visitor;
package minijava.ast;
public class Call extends Expression {
public final Expression receiver;
public final String name;
public final NodeList<Expression> rands;
public Call(Expression receiver, String name, NodeList<Expression> rands) {
super();
this.receiver = receiver;
this.name = name;
this.rands = rands;
}
@Override | public <R> R accept(Visitor<R> v) { |
mikedouglas/MiniJava | src/java/minijava/test/parser/Test2LexInternal.java | // Path: src/java/minijava/test/SampleCode.java
// public class SampleCode {
//
// /**
// * Points to a directory containing sample java code to parse.
// */
// public final static File sample_dir = new File("resources/sample");
//
// /**
// * Filter for selecting Java files only.
// */
// private static final FilenameFilter javaFileFilter = new FilenameFilter() {
// @Override
// public boolean accept(File dir, String name) {
// return name.endsWith(".java");
// }
// };
//
// /**
// * @return An array of sample MiniJava files.
// */
// public static File[] sampleFiles() {
// File[] files = sample_dir.listFiles(javaFileFilter);
// // Should sort the array to ensure that we produce the files in the same order
// // independent of the order in which the OS produces them.
// Arrays.sort(files);
// return files;
// }
//
// }
| import static minijava.parser.jcc.JCCMiniJavaParserConstants.EOF;
import static minijava.parser.jcc.JCCMiniJavaParserConstants.IDENTIFIER;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.StringReader;
import minijava.parser.jcc.JCCMiniJavaParser;
import minijava.parser.jcc.JCCMiniJavaParserConstants;
import minijava.parser.jcc.Token;
import minijava.test.SampleCode;
import org.junit.Assert;
import org.junit.Test; | }
@Test public void comments() {
test( "// A single line comment\n" +
"/* A multi line comment\n" +
" with more than one\n" +
" line of comments in it\n" +
"*/\n" +
" \t // should allow them to preceeded by spaces or tabs\n",
new int[0] );
}
@Test public void starComments() {
test("/**/" , new int[0] );
test("/***/" , new int[0] );
test("/****/" , new int[0] );
}
@Test public void commensWithSomethingInBetweem() {
test( "/* A comment */" +
"anIdentifier" +
"/* Another comment */",
new int[] { IDENTIFIER } );
}
@Test public void commentAtEOF() {
test("// A single line comment",
new int[0] );
}
@Test public void sampleCode() throws FileNotFoundException {
//Read all the sample code. It should contain only valid tokens. | // Path: src/java/minijava/test/SampleCode.java
// public class SampleCode {
//
// /**
// * Points to a directory containing sample java code to parse.
// */
// public final static File sample_dir = new File("resources/sample");
//
// /**
// * Filter for selecting Java files only.
// */
// private static final FilenameFilter javaFileFilter = new FilenameFilter() {
// @Override
// public boolean accept(File dir, String name) {
// return name.endsWith(".java");
// }
// };
//
// /**
// * @return An array of sample MiniJava files.
// */
// public static File[] sampleFiles() {
// File[] files = sample_dir.listFiles(javaFileFilter);
// // Should sort the array to ensure that we produce the files in the same order
// // independent of the order in which the OS produces them.
// Arrays.sort(files);
// return files;
// }
//
// }
// Path: src/java/minijava/test/parser/Test2LexInternal.java
import static minijava.parser.jcc.JCCMiniJavaParserConstants.EOF;
import static minijava.parser.jcc.JCCMiniJavaParserConstants.IDENTIFIER;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.StringReader;
import minijava.parser.jcc.JCCMiniJavaParser;
import minijava.parser.jcc.JCCMiniJavaParserConstants;
import minijava.parser.jcc.Token;
import minijava.test.SampleCode;
import org.junit.Assert;
import org.junit.Test;
}
@Test public void comments() {
test( "// A single line comment\n" +
"/* A multi line comment\n" +
" with more than one\n" +
" line of comments in it\n" +
"*/\n" +
" \t // should allow them to preceeded by spaces or tabs\n",
new int[0] );
}
@Test public void starComments() {
test("/**/" , new int[0] );
test("/***/" , new int[0] );
test("/****/" , new int[0] );
}
@Test public void commensWithSomethingInBetweem() {
test( "/* A comment */" +
"anIdentifier" +
"/* Another comment */",
new int[] { IDENTIFIER } );
}
@Test public void commentAtEOF() {
test("// A single line comment",
new int[0] );
}
@Test public void sampleCode() throws FileNotFoundException {
//Read all the sample code. It should contain only valid tokens. | File[] files = SampleCode.sampleFiles(); |
mikedouglas/MiniJava | src/java/minijava/ast/Program.java | // Path: src/java/minijava/visitor/Visitor.java
// public interface Visitor<R> {
//
// //Lists
// public <T extends AST> R visit(NodeList<T> ns);
//
// //Declarations
// public R visit(Program n);
// public R visit(MainClass n);
// public R visit(ClassDecl n);
// public R visit(VarDecl n);
// public R visit(MethodDecl n);
//
// //Types
// public R visit(IntArrayType n);
// public R visit(BooleanType n);
// public R visit(IntegerType n);
// public R visit(ObjectType n);
//
// //Statements
// public R visit(Block n);
// public R visit(If n);
// public R visit(While n);
// public R visit(Print n);
// public R visit(Assign n);
// public R visit(ArrayAssign n);
//
// //Expressions
// public R visit(And n);
// public R visit(LessThan n);
// public R visit(Plus n);
// public R visit(Minus n);
// public R visit(Times n);
// public R visit(ArrayLookup n);
// public R visit(ArrayLength n);
// public R visit(Call n);
// public R visit(IntegerLiteral n);
// public R visit(BooleanLiteral n);
// public R visit(IdentifierExp n);
// public R visit(This n);
// public R visit(NewArray n);
// public R visit(NewObject n);
// public R visit(Not not);
//
// }
| import java.util.List;
import minijava.visitor.Visitor; | package minijava.ast;
public class Program extends AST {
public final MainClass mainClass;
public final NodeList<ClassDecl> classes;
public Program(MainClass mainClass, NodeList<ClassDecl> otherClasses) {
this.mainClass=mainClass;
this.classes=otherClasses;
}
public Program(MainClass m, List<ClassDecl> cs) {
this(m, new NodeList<ClassDecl>(cs));
}
| // Path: src/java/minijava/visitor/Visitor.java
// public interface Visitor<R> {
//
// //Lists
// public <T extends AST> R visit(NodeList<T> ns);
//
// //Declarations
// public R visit(Program n);
// public R visit(MainClass n);
// public R visit(ClassDecl n);
// public R visit(VarDecl n);
// public R visit(MethodDecl n);
//
// //Types
// public R visit(IntArrayType n);
// public R visit(BooleanType n);
// public R visit(IntegerType n);
// public R visit(ObjectType n);
//
// //Statements
// public R visit(Block n);
// public R visit(If n);
// public R visit(While n);
// public R visit(Print n);
// public R visit(Assign n);
// public R visit(ArrayAssign n);
//
// //Expressions
// public R visit(And n);
// public R visit(LessThan n);
// public R visit(Plus n);
// public R visit(Minus n);
// public R visit(Times n);
// public R visit(ArrayLookup n);
// public R visit(ArrayLength n);
// public R visit(Call n);
// public R visit(IntegerLiteral n);
// public R visit(BooleanLiteral n);
// public R visit(IdentifierExp n);
// public R visit(This n);
// public R visit(NewArray n);
// public R visit(NewObject n);
// public R visit(Not not);
//
// }
// Path: src/java/minijava/ast/Program.java
import java.util.List;
import minijava.visitor.Visitor;
package minijava.ast;
public class Program extends AST {
public final MainClass mainClass;
public final NodeList<ClassDecl> classes;
public Program(MainClass mainClass, NodeList<ClassDecl> otherClasses) {
this.mainClass=mainClass;
this.classes=otherClasses;
}
public Program(MainClass m, List<ClassDecl> cs) {
this(m, new NodeList<ClassDecl>(cs));
}
| public <R> R accept(Visitor<R> v) { |
mikedouglas/MiniJava | src/java/minijava/ast/ArrayLength.java | // Path: src/java/minijava/visitor/Visitor.java
// public interface Visitor<R> {
//
// //Lists
// public <T extends AST> R visit(NodeList<T> ns);
//
// //Declarations
// public R visit(Program n);
// public R visit(MainClass n);
// public R visit(ClassDecl n);
// public R visit(VarDecl n);
// public R visit(MethodDecl n);
//
// //Types
// public R visit(IntArrayType n);
// public R visit(BooleanType n);
// public R visit(IntegerType n);
// public R visit(ObjectType n);
//
// //Statements
// public R visit(Block n);
// public R visit(If n);
// public R visit(While n);
// public R visit(Print n);
// public R visit(Assign n);
// public R visit(ArrayAssign n);
//
// //Expressions
// public R visit(And n);
// public R visit(LessThan n);
// public R visit(Plus n);
// public R visit(Minus n);
// public R visit(Times n);
// public R visit(ArrayLookup n);
// public R visit(ArrayLength n);
// public R visit(Call n);
// public R visit(IntegerLiteral n);
// public R visit(BooleanLiteral n);
// public R visit(IdentifierExp n);
// public R visit(This n);
// public R visit(NewArray n);
// public R visit(NewObject n);
// public R visit(Not not);
//
// }
| import minijava.visitor.Visitor; | package minijava.ast;
public class ArrayLength extends Expression {
public final Expression array;
public ArrayLength(Expression array) {
super();
super.setType(IntegerType.instance);
this.array = array;
}
@Override | // Path: src/java/minijava/visitor/Visitor.java
// public interface Visitor<R> {
//
// //Lists
// public <T extends AST> R visit(NodeList<T> ns);
//
// //Declarations
// public R visit(Program n);
// public R visit(MainClass n);
// public R visit(ClassDecl n);
// public R visit(VarDecl n);
// public R visit(MethodDecl n);
//
// //Types
// public R visit(IntArrayType n);
// public R visit(BooleanType n);
// public R visit(IntegerType n);
// public R visit(ObjectType n);
//
// //Statements
// public R visit(Block n);
// public R visit(If n);
// public R visit(While n);
// public R visit(Print n);
// public R visit(Assign n);
// public R visit(ArrayAssign n);
//
// //Expressions
// public R visit(And n);
// public R visit(LessThan n);
// public R visit(Plus n);
// public R visit(Minus n);
// public R visit(Times n);
// public R visit(ArrayLookup n);
// public R visit(ArrayLength n);
// public R visit(Call n);
// public R visit(IntegerLiteral n);
// public R visit(BooleanLiteral n);
// public R visit(IdentifierExp n);
// public R visit(This n);
// public R visit(NewArray n);
// public R visit(NewObject n);
// public R visit(Not not);
//
// }
// Path: src/java/minijava/ast/ArrayLength.java
import minijava.visitor.Visitor;
package minijava.ast;
public class ArrayLength extends Expression {
public final Expression array;
public ArrayLength(Expression array) {
super();
super.setType(IntegerType.instance);
this.array = array;
}
@Override | public <R> R accept(Visitor<R> v) { |
mikedouglas/MiniJava | src/java/minijava/ast/ObjectType.java | // Path: src/java/minijava/visitor/Visitor.java
// public interface Visitor<R> {
//
// //Lists
// public <T extends AST> R visit(NodeList<T> ns);
//
// //Declarations
// public R visit(Program n);
// public R visit(MainClass n);
// public R visit(ClassDecl n);
// public R visit(VarDecl n);
// public R visit(MethodDecl n);
//
// //Types
// public R visit(IntArrayType n);
// public R visit(BooleanType n);
// public R visit(IntegerType n);
// public R visit(ObjectType n);
//
// //Statements
// public R visit(Block n);
// public R visit(If n);
// public R visit(While n);
// public R visit(Print n);
// public R visit(Assign n);
// public R visit(ArrayAssign n);
//
// //Expressions
// public R visit(And n);
// public R visit(LessThan n);
// public R visit(Plus n);
// public R visit(Minus n);
// public R visit(Times n);
// public R visit(ArrayLookup n);
// public R visit(ArrayLength n);
// public R visit(Call n);
// public R visit(IntegerLiteral n);
// public R visit(BooleanLiteral n);
// public R visit(IdentifierExp n);
// public R visit(This n);
// public R visit(NewArray n);
// public R visit(NewObject n);
// public R visit(Not not);
//
// }
| import minijava.visitor.Visitor; | package minijava.ast;
public class ObjectType extends Type {
public final String name;
public ObjectType(String name) {
super();
this.name = name;
}
@Override | // Path: src/java/minijava/visitor/Visitor.java
// public interface Visitor<R> {
//
// //Lists
// public <T extends AST> R visit(NodeList<T> ns);
//
// //Declarations
// public R visit(Program n);
// public R visit(MainClass n);
// public R visit(ClassDecl n);
// public R visit(VarDecl n);
// public R visit(MethodDecl n);
//
// //Types
// public R visit(IntArrayType n);
// public R visit(BooleanType n);
// public R visit(IntegerType n);
// public R visit(ObjectType n);
//
// //Statements
// public R visit(Block n);
// public R visit(If n);
// public R visit(While n);
// public R visit(Print n);
// public R visit(Assign n);
// public R visit(ArrayAssign n);
//
// //Expressions
// public R visit(And n);
// public R visit(LessThan n);
// public R visit(Plus n);
// public R visit(Minus n);
// public R visit(Times n);
// public R visit(ArrayLookup n);
// public R visit(ArrayLength n);
// public R visit(Call n);
// public R visit(IntegerLiteral n);
// public R visit(BooleanLiteral n);
// public R visit(IdentifierExp n);
// public R visit(This n);
// public R visit(NewArray n);
// public R visit(NewObject n);
// public R visit(Not not);
//
// }
// Path: src/java/minijava/ast/ObjectType.java
import minijava.visitor.Visitor;
package minijava.ast;
public class ObjectType extends Type {
public final String name;
public ObjectType(String name) {
super();
this.name = name;
}
@Override | public <R> R accept(Visitor<R> v) { |
mikedouglas/MiniJava | src/java/minijava/ast/NodeList.java | // Path: src/java/minijava/visitor/Visitor.java
// public interface Visitor<R> {
//
// //Lists
// public <T extends AST> R visit(NodeList<T> ns);
//
// //Declarations
// public R visit(Program n);
// public R visit(MainClass n);
// public R visit(ClassDecl n);
// public R visit(VarDecl n);
// public R visit(MethodDecl n);
//
// //Types
// public R visit(IntArrayType n);
// public R visit(BooleanType n);
// public R visit(IntegerType n);
// public R visit(ObjectType n);
//
// //Statements
// public R visit(Block n);
// public R visit(If n);
// public R visit(While n);
// public R visit(Print n);
// public R visit(Assign n);
// public R visit(ArrayAssign n);
//
// //Expressions
// public R visit(And n);
// public R visit(LessThan n);
// public R visit(Plus n);
// public R visit(Minus n);
// public R visit(Times n);
// public R visit(ArrayLookup n);
// public R visit(ArrayLength n);
// public R visit(Call n);
// public R visit(IntegerLiteral n);
// public R visit(BooleanLiteral n);
// public R visit(IdentifierExp n);
// public R visit(This n);
// public R visit(NewArray n);
// public R visit(NewObject n);
// public R visit(Not not);
//
// }
| import java.util.List;
import minijava.visitor.Visitor; | package minijava.ast;
public class NodeList<T extends AST> extends AST {
private List<T> nodes;
public NodeList(List<T> nodes) {
this.nodes = nodes;
}
public int size() {
return nodes.size();
}
public T elementAt(int i) {
return nodes.get(i);
}
@Override | // Path: src/java/minijava/visitor/Visitor.java
// public interface Visitor<R> {
//
// //Lists
// public <T extends AST> R visit(NodeList<T> ns);
//
// //Declarations
// public R visit(Program n);
// public R visit(MainClass n);
// public R visit(ClassDecl n);
// public R visit(VarDecl n);
// public R visit(MethodDecl n);
//
// //Types
// public R visit(IntArrayType n);
// public R visit(BooleanType n);
// public R visit(IntegerType n);
// public R visit(ObjectType n);
//
// //Statements
// public R visit(Block n);
// public R visit(If n);
// public R visit(While n);
// public R visit(Print n);
// public R visit(Assign n);
// public R visit(ArrayAssign n);
//
// //Expressions
// public R visit(And n);
// public R visit(LessThan n);
// public R visit(Plus n);
// public R visit(Minus n);
// public R visit(Times n);
// public R visit(ArrayLookup n);
// public R visit(ArrayLength n);
// public R visit(Call n);
// public R visit(IntegerLiteral n);
// public R visit(BooleanLiteral n);
// public R visit(IdentifierExp n);
// public R visit(This n);
// public R visit(NewArray n);
// public R visit(NewObject n);
// public R visit(Not not);
//
// }
// Path: src/java/minijava/ast/NodeList.java
import java.util.List;
import minijava.visitor.Visitor;
package minijava.ast;
public class NodeList<T extends AST> extends AST {
private List<T> nodes;
public NodeList(List<T> nodes) {
this.nodes = nodes;
}
public int size() {
return nodes.size();
}
public T elementAt(int i) {
return nodes.get(i);
}
@Override | public <R> R accept(Visitor<R> v) { |
mikedouglas/MiniJava | src/java/minijava/ast/Times.java | // Path: src/java/minijava/visitor/Visitor.java
// public interface Visitor<R> {
//
// //Lists
// public <T extends AST> R visit(NodeList<T> ns);
//
// //Declarations
// public R visit(Program n);
// public R visit(MainClass n);
// public R visit(ClassDecl n);
// public R visit(VarDecl n);
// public R visit(MethodDecl n);
//
// //Types
// public R visit(IntArrayType n);
// public R visit(BooleanType n);
// public R visit(IntegerType n);
// public R visit(ObjectType n);
//
// //Statements
// public R visit(Block n);
// public R visit(If n);
// public R visit(While n);
// public R visit(Print n);
// public R visit(Assign n);
// public R visit(ArrayAssign n);
//
// //Expressions
// public R visit(And n);
// public R visit(LessThan n);
// public R visit(Plus n);
// public R visit(Minus n);
// public R visit(Times n);
// public R visit(ArrayLookup n);
// public R visit(ArrayLength n);
// public R visit(Call n);
// public R visit(IntegerLiteral n);
// public R visit(BooleanLiteral n);
// public R visit(IdentifierExp n);
// public R visit(This n);
// public R visit(NewArray n);
// public R visit(NewObject n);
// public R visit(Not not);
//
// }
| import minijava.visitor.Visitor; | package minijava.ast;
public class Times extends Expression {
public final Expression e1;
public final Expression e2;
public Times(Expression e1, Expression e2) {
super();
super.setType(IntegerType.instance);
this.e1 = e1;
this.e2 = e2;
}
@Override | // Path: src/java/minijava/visitor/Visitor.java
// public interface Visitor<R> {
//
// //Lists
// public <T extends AST> R visit(NodeList<T> ns);
//
// //Declarations
// public R visit(Program n);
// public R visit(MainClass n);
// public R visit(ClassDecl n);
// public R visit(VarDecl n);
// public R visit(MethodDecl n);
//
// //Types
// public R visit(IntArrayType n);
// public R visit(BooleanType n);
// public R visit(IntegerType n);
// public R visit(ObjectType n);
//
// //Statements
// public R visit(Block n);
// public R visit(If n);
// public R visit(While n);
// public R visit(Print n);
// public R visit(Assign n);
// public R visit(ArrayAssign n);
//
// //Expressions
// public R visit(And n);
// public R visit(LessThan n);
// public R visit(Plus n);
// public R visit(Minus n);
// public R visit(Times n);
// public R visit(ArrayLookup n);
// public R visit(ArrayLength n);
// public R visit(Call n);
// public R visit(IntegerLiteral n);
// public R visit(BooleanLiteral n);
// public R visit(IdentifierExp n);
// public R visit(This n);
// public R visit(NewArray n);
// public R visit(NewObject n);
// public R visit(Not not);
//
// }
// Path: src/java/minijava/ast/Times.java
import minijava.visitor.Visitor;
package minijava.ast;
public class Times extends Expression {
public final Expression e1;
public final Expression e2;
public Times(Expression e1, Expression e2) {
super();
super.setType(IntegerType.instance);
this.e1 = e1;
this.e2 = e2;
}
@Override | public <R> R accept(Visitor<R> v) { |
mikedouglas/MiniJava | src/java/minijava/test/util/FunTableTest.java | // Path: src/java/minijava/util/FunTable.java
// public abstract class FunTable<V> extends DefaultIndentable
// implements Lookup<V>, Iterable<FunTable.Entry<V>> {
//
// FunTable() { super(); }
//
// /**
// * Dump contents of this table in nicely indented format.
// */
// public void dump(IndentingWriter out) {
// out.println("Table {");
// out.indent();
// for (Entry<V> entry : this) {
// out.print(entry.getId()+" = ");
// out.print(entry.getValue());
// out.println();
// }
// out.outdent();
// out.print("}");
// }
//
// /**
// * An instance of table that represents the EmptyTable.
// */
// public static final <V> FunTable<V> theEmpty() {return new EmptyTable<V>(); }
//
// /**
// * Extend a table with a new Table Entry associating an id to its
// * value. This does not modify the original table but returns a new
// * "extended" table.
// */
// public FunTable<V> insert(String id, V value) {
// return new Entry<V>(id, value, this);
// }
//
// /**
// * Finds the value of an Entry in a table. Returns null if no corresponding entry
// * exists in the table.
// */
// public V lookup(String id) {
// //Note: the book suggests a recursive implementation for this
// //function, which is also a good way to implement it.
// //However, in Java there is no proper tail call optimisation and
// //so recursive implementations can make large, unnecessary demand
// //on the stack. This implementation makes use of our implementation
// //Iterable and is equally readable yet more efficient
// //(no unbounded stack growth).
// for (Entry<V> entry : this)
// if (entry.getId().equals(id))
// return entry.getValue();
// return null;
// }
//
// /**
// * Returns true if and only if this table is empty.
// */
// public abstract boolean isEmpty();
//
//
// /**
// * An Entry in a table. Note that the constructor is not public.
// * You should use the "insert" method of Table to create table entries.
// * <p>
// * Note also that the "tail" pointer is not accessible to user code.
// * It is private and we have not provided an accessor for it. The fact
// * that the table is implemented as a "linked list" should be hidden
// * from user code!
// */
// public static class Entry<V> extends FunTable<V> {
//
// private String id;
// private V value;
// private FunTable<V> tail;
//
// private Entry(String id, V value, FunTable<V> table) {
// this.id = id;
// this.value = value;
// this.tail = table;
// }
//
// @Override
// public boolean isEmpty() {
// return false;
// }
//
// public String getId() {
// return id;
// }
//
// public V getValue() {
// return value;
// }
//
// @Override
// public FunTable<V> merge(FunTable<V> superEntries) {
// FunTable<V> rest = tail.merge(superEntries);
// return new Entry<V>(id, value, rest);
// }
//
// }
//
// @Override
// public Iterator<Entry<V>> iterator() {
// return new TableIterator(this);
// }
//
// public int size() {
// int count = 0;
// for (@SuppressWarnings("unused") Entry<V> entry : this) count++;
// return count;
// }
//
// /**
// * Merge two tables together into a new table.
// * <p>
// * The order of entries in both tables is preserved and the
// * entries if the leftmost table take priority over the rightmost
// * table if they have the same id.
// */
// public abstract FunTable<V> merge(FunTable<V> superEntries);
//
// ///////////// all code below here is strictly private ///////////////////
//
// /**
// * A class to represent an empty table. This class is a singleton:
// * there is only one instance of EmptyTable.
// */
// private static class EmptyTable<V> extends FunTable<V> {
// @Override
// public String toString() {
// return "Table{}";
// }
//
// @Override
// public boolean isEmpty() {
// return true;
// }
//
// @Override
// public FunTable<V> merge(FunTable<V> superEntries) {
// return superEntries;
// }
// }
//
// private class TableIterator implements Iterator<Entry<V>> {
//
// private FunTable<V> tablePtr;
//
// private TableIterator(FunTable<V> table) {
// this.tablePtr = table;
// }
//
// @Override
// public boolean hasNext() {
// return !tablePtr.isEmpty();
// }
//
// @Override
// public Entry<V> next() {
// if (!hasNext())
// throw new NoSuchElementException();
// else {
// Entry<V> entry = (Entry<V>) tablePtr;
// tablePtr = entry.tail;
// return entry;
// }
// }
//
// @Override
// public void remove() {
// throw new UnsupportedOperationException("Tables are immutable, can not remove elements");
// }
//
// }
//
// }
| import minijava.util.FunTable;
import org.junit.Assert;
import org.junit.Test; | package minijava.test.util;
/**
* It is a good idea to provide unit tests for all non-trivial
* data structure implementations. This class contains tests for
* our implementation of Symbol tables provided in the class
* minijava.table.FunTable.
* <p>
* The implementation of Table that is provided is already complete.
* These tests should run and pass "out of the box".
*
* @author kdvolder
*/
public class FunTableTest {
@Test public void testEmptyTable() { | // Path: src/java/minijava/util/FunTable.java
// public abstract class FunTable<V> extends DefaultIndentable
// implements Lookup<V>, Iterable<FunTable.Entry<V>> {
//
// FunTable() { super(); }
//
// /**
// * Dump contents of this table in nicely indented format.
// */
// public void dump(IndentingWriter out) {
// out.println("Table {");
// out.indent();
// for (Entry<V> entry : this) {
// out.print(entry.getId()+" = ");
// out.print(entry.getValue());
// out.println();
// }
// out.outdent();
// out.print("}");
// }
//
// /**
// * An instance of table that represents the EmptyTable.
// */
// public static final <V> FunTable<V> theEmpty() {return new EmptyTable<V>(); }
//
// /**
// * Extend a table with a new Table Entry associating an id to its
// * value. This does not modify the original table but returns a new
// * "extended" table.
// */
// public FunTable<V> insert(String id, V value) {
// return new Entry<V>(id, value, this);
// }
//
// /**
// * Finds the value of an Entry in a table. Returns null if no corresponding entry
// * exists in the table.
// */
// public V lookup(String id) {
// //Note: the book suggests a recursive implementation for this
// //function, which is also a good way to implement it.
// //However, in Java there is no proper tail call optimisation and
// //so recursive implementations can make large, unnecessary demand
// //on the stack. This implementation makes use of our implementation
// //Iterable and is equally readable yet more efficient
// //(no unbounded stack growth).
// for (Entry<V> entry : this)
// if (entry.getId().equals(id))
// return entry.getValue();
// return null;
// }
//
// /**
// * Returns true if and only if this table is empty.
// */
// public abstract boolean isEmpty();
//
//
// /**
// * An Entry in a table. Note that the constructor is not public.
// * You should use the "insert" method of Table to create table entries.
// * <p>
// * Note also that the "tail" pointer is not accessible to user code.
// * It is private and we have not provided an accessor for it. The fact
// * that the table is implemented as a "linked list" should be hidden
// * from user code!
// */
// public static class Entry<V> extends FunTable<V> {
//
// private String id;
// private V value;
// private FunTable<V> tail;
//
// private Entry(String id, V value, FunTable<V> table) {
// this.id = id;
// this.value = value;
// this.tail = table;
// }
//
// @Override
// public boolean isEmpty() {
// return false;
// }
//
// public String getId() {
// return id;
// }
//
// public V getValue() {
// return value;
// }
//
// @Override
// public FunTable<V> merge(FunTable<V> superEntries) {
// FunTable<V> rest = tail.merge(superEntries);
// return new Entry<V>(id, value, rest);
// }
//
// }
//
// @Override
// public Iterator<Entry<V>> iterator() {
// return new TableIterator(this);
// }
//
// public int size() {
// int count = 0;
// for (@SuppressWarnings("unused") Entry<V> entry : this) count++;
// return count;
// }
//
// /**
// * Merge two tables together into a new table.
// * <p>
// * The order of entries in both tables is preserved and the
// * entries if the leftmost table take priority over the rightmost
// * table if they have the same id.
// */
// public abstract FunTable<V> merge(FunTable<V> superEntries);
//
// ///////////// all code below here is strictly private ///////////////////
//
// /**
// * A class to represent an empty table. This class is a singleton:
// * there is only one instance of EmptyTable.
// */
// private static class EmptyTable<V> extends FunTable<V> {
// @Override
// public String toString() {
// return "Table{}";
// }
//
// @Override
// public boolean isEmpty() {
// return true;
// }
//
// @Override
// public FunTable<V> merge(FunTable<V> superEntries) {
// return superEntries;
// }
// }
//
// private class TableIterator implements Iterator<Entry<V>> {
//
// private FunTable<V> tablePtr;
//
// private TableIterator(FunTable<V> table) {
// this.tablePtr = table;
// }
//
// @Override
// public boolean hasNext() {
// return !tablePtr.isEmpty();
// }
//
// @Override
// public Entry<V> next() {
// if (!hasNext())
// throw new NoSuchElementException();
// else {
// Entry<V> entry = (Entry<V>) tablePtr;
// tablePtr = entry.tail;
// return entry;
// }
// }
//
// @Override
// public void remove() {
// throw new UnsupportedOperationException("Tables are immutable, can not remove elements");
// }
//
// }
//
// }
// Path: src/java/minijava/test/util/FunTableTest.java
import minijava.util.FunTable;
import org.junit.Assert;
import org.junit.Test;
package minijava.test.util;
/**
* It is a good idea to provide unit tests for all non-trivial
* data structure implementations. This class contains tests for
* our implementation of Symbol tables provided in the class
* minijava.table.FunTable.
* <p>
* The implementation of Table that is provided is already complete.
* These tests should run and pass "out of the box".
*
* @author kdvolder
*/
public class FunTableTest {
@Test public void testEmptyTable() { | FunTable<Integer> tab = FunTable.theEmpty(); |
mikedouglas/MiniJava | src/java/minijava/ast/NewObject.java | // Path: src/java/minijava/visitor/Visitor.java
// public interface Visitor<R> {
//
// //Lists
// public <T extends AST> R visit(NodeList<T> ns);
//
// //Declarations
// public R visit(Program n);
// public R visit(MainClass n);
// public R visit(ClassDecl n);
// public R visit(VarDecl n);
// public R visit(MethodDecl n);
//
// //Types
// public R visit(IntArrayType n);
// public R visit(BooleanType n);
// public R visit(IntegerType n);
// public R visit(ObjectType n);
//
// //Statements
// public R visit(Block n);
// public R visit(If n);
// public R visit(While n);
// public R visit(Print n);
// public R visit(Assign n);
// public R visit(ArrayAssign n);
//
// //Expressions
// public R visit(And n);
// public R visit(LessThan n);
// public R visit(Plus n);
// public R visit(Minus n);
// public R visit(Times n);
// public R visit(ArrayLookup n);
// public R visit(ArrayLength n);
// public R visit(Call n);
// public R visit(IntegerLiteral n);
// public R visit(BooleanLiteral n);
// public R visit(IdentifierExp n);
// public R visit(This n);
// public R visit(NewArray n);
// public R visit(NewObject n);
// public R visit(Not not);
//
// }
| import minijava.visitor.Visitor; | package minijava.ast;
public class NewObject extends Expression {
public final String typeName;
public NewObject(String typeName) {
super();
this.typeName = typeName;
}
@Override | // Path: src/java/minijava/visitor/Visitor.java
// public interface Visitor<R> {
//
// //Lists
// public <T extends AST> R visit(NodeList<T> ns);
//
// //Declarations
// public R visit(Program n);
// public R visit(MainClass n);
// public R visit(ClassDecl n);
// public R visit(VarDecl n);
// public R visit(MethodDecl n);
//
// //Types
// public R visit(IntArrayType n);
// public R visit(BooleanType n);
// public R visit(IntegerType n);
// public R visit(ObjectType n);
//
// //Statements
// public R visit(Block n);
// public R visit(If n);
// public R visit(While n);
// public R visit(Print n);
// public R visit(Assign n);
// public R visit(ArrayAssign n);
//
// //Expressions
// public R visit(And n);
// public R visit(LessThan n);
// public R visit(Plus n);
// public R visit(Minus n);
// public R visit(Times n);
// public R visit(ArrayLookup n);
// public R visit(ArrayLength n);
// public R visit(Call n);
// public R visit(IntegerLiteral n);
// public R visit(BooleanLiteral n);
// public R visit(IdentifierExp n);
// public R visit(This n);
// public R visit(NewArray n);
// public R visit(NewObject n);
// public R visit(Not not);
//
// }
// Path: src/java/minijava/ast/NewObject.java
import minijava.visitor.Visitor;
package minijava.ast;
public class NewObject extends Expression {
public final String typeName;
public NewObject(String typeName) {
super();
this.typeName = typeName;
}
@Override | public <R> R accept(Visitor<R> v) { |
mikedouglas/MiniJava | src/java/minijava/ast/Not.java | // Path: src/java/minijava/visitor/Visitor.java
// public interface Visitor<R> {
//
// //Lists
// public <T extends AST> R visit(NodeList<T> ns);
//
// //Declarations
// public R visit(Program n);
// public R visit(MainClass n);
// public R visit(ClassDecl n);
// public R visit(VarDecl n);
// public R visit(MethodDecl n);
//
// //Types
// public R visit(IntArrayType n);
// public R visit(BooleanType n);
// public R visit(IntegerType n);
// public R visit(ObjectType n);
//
// //Statements
// public R visit(Block n);
// public R visit(If n);
// public R visit(While n);
// public R visit(Print n);
// public R visit(Assign n);
// public R visit(ArrayAssign n);
//
// //Expressions
// public R visit(And n);
// public R visit(LessThan n);
// public R visit(Plus n);
// public R visit(Minus n);
// public R visit(Times n);
// public R visit(ArrayLookup n);
// public R visit(ArrayLength n);
// public R visit(Call n);
// public R visit(IntegerLiteral n);
// public R visit(BooleanLiteral n);
// public R visit(IdentifierExp n);
// public R visit(This n);
// public R visit(NewArray n);
// public R visit(NewObject n);
// public R visit(Not not);
//
// }
| import minijava.visitor.Visitor; | package minijava.ast;
public class Not extends Expression {
public final Expression e;
public Not(Expression e) {
super();
super.setType(BooleanType.instance);
this.e = e;
}
@Override | // Path: src/java/minijava/visitor/Visitor.java
// public interface Visitor<R> {
//
// //Lists
// public <T extends AST> R visit(NodeList<T> ns);
//
// //Declarations
// public R visit(Program n);
// public R visit(MainClass n);
// public R visit(ClassDecl n);
// public R visit(VarDecl n);
// public R visit(MethodDecl n);
//
// //Types
// public R visit(IntArrayType n);
// public R visit(BooleanType n);
// public R visit(IntegerType n);
// public R visit(ObjectType n);
//
// //Statements
// public R visit(Block n);
// public R visit(If n);
// public R visit(While n);
// public R visit(Print n);
// public R visit(Assign n);
// public R visit(ArrayAssign n);
//
// //Expressions
// public R visit(And n);
// public R visit(LessThan n);
// public R visit(Plus n);
// public R visit(Minus n);
// public R visit(Times n);
// public R visit(ArrayLookup n);
// public R visit(ArrayLength n);
// public R visit(Call n);
// public R visit(IntegerLiteral n);
// public R visit(BooleanLiteral n);
// public R visit(IdentifierExp n);
// public R visit(This n);
// public R visit(NewArray n);
// public R visit(NewObject n);
// public R visit(Not not);
//
// }
// Path: src/java/minijava/ast/Not.java
import minijava.visitor.Visitor;
package minijava.ast;
public class Not extends Expression {
public final Expression e;
public Not(Expression e) {
super();
super.setType(BooleanType.instance);
this.e = e;
}
@Override | public <R> R accept(Visitor<R> v) { |
CalebFenton/resequencer | src/main/java/org/cf/resequencer/sequence/ZipUtils.java | // Path: src/main/java/org/cf/resequencer/Console.java
// public class Console {
// private static final boolean StackTrace = false;
// public static int VerboseLevel;
// public static String LogFile = "console.log";
//
// public static void msgln() {
// System.out.println();
// }
//
// public static void msgln(final String msg) {
// System.out.println(msg);
// }
//
// public static void msg(final String msg) {
// System.out.print(msg);
// }
//
// public static void debug(final String msg) {
// if (VerboseLevel > 0) {
// System.out.println(msg);
// }
// }
//
// public static void debug(final String msg, final int verboseLevel) {
// if (verboseLevel <= VerboseLevel) {
// debug(msg);
// }
// }
//
// public static void warn(final String msg) {
// System.err.println("Warning: " + msg);
// if (StackTrace) {
// Thread.dumpStack();
// }
// }
//
// public static void error(final String msg) {
// System.err.println("Error: " + msg);
// if (StackTrace) {
// Thread.dumpStack();
// }
// }
//
// public static void die(final Exception ex) {
// die(ex, -1);
// }
//
// public static void die(final Exception ex, final int exitStatus) {
// if (StackTrace) {
// ex.printStackTrace();
// }
// System.err.println("" + ex);
// System.exit(exitStatus);
// }
//
// public static void die(final String msg) {
// die(msg, -1);
// }
//
// public static void die(final String msg, int exitStatus) {
// System.err.println("Fatal error: " + msg);
// if (StackTrace) {
// Thread.dumpStack();
// }
// System.exit(exitStatus);
// }
//
// // run command and return {result, exit status}
// public static String[] execute(String[] cmd) {
// debug("Executing: " + Arrays.asList(cmd).toString());
//
// StringBuffer output = new StringBuffer();
// Integer status = null;
//
// InputStream in = null;
// try {
// Process child = Runtime.getRuntime().exec(cmd);
//
// BufferedReader stdInput = new BufferedReader(new InputStreamReader(child.getInputStream()));
//
// String s;
// while ((s = stdInput.readLine()) != null) {
// output.append(s).append('\n');
// }
//
// status = child.waitFor();
//
// debug("Exit status: " + status, 2);
// } catch (Exception ex) {
// error("Run command failed.\n" + ex);
// } finally {
// IOUtils.closeQuietly(in);
// }
//
// return new String[] { output.toString(), String.valueOf(status) };
// }
//
// public static boolean deleteBestEffort(File path, String whatIsIt) {
// return deleteBestEffort(path, whatIsIt, 3, false);
// }
//
// public static boolean deleteBestEffort(File path, String whatIsIt, int maxTries) {
// return deleteBestEffort(path, whatIsIt, maxTries, false);
// }
//
// public static boolean deleteBestEffort(File path, String whatIsIt, int maxTries, boolean quiet) {
// System.gc();
//
// int tries = 0;
// while (!FileUtils.deleteQuietly(path) && (tries < maxTries)) {
// System.gc();
// tries++;
//
// if (!quiet) {
// warn("Unable to delete " + whatIsIt + ": " + path + ". Trying again ...");
// }
//
// try {
// Thread.sleep(3000);
// } catch (InterruptedException ex) {
// }
// }
//
// return !path.exists();
// }
// }
| import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.zip.Deflater;
import java.util.zip.ZipEntry;
import java.util.zip.ZipInputStream;
import java.util.zip.ZipOutputStream;
import org.apache.commons.io.FileUtils;
import org.cf.resequencer.Console; | if (directory == null) {
if (newFile.isDirectory()) {
break;
}
}
String destPath;
if ((destPaths == null) || (destPaths.length < inFilesIndex)) {
destPath = entry.getName();
} else {
destPath = destPaths[inFilesIndex];
}
makeDestDirectory(new File(destPath));
fos = new FileOutputStream(destPath);
int n;
while ((n = zin.read(buf, 0, 1024)) > -1) {
fos.write(buf, 0, n);
}
fos.close();
zin.closeEntry();
}
entry = zin.getNextEntry();
}
zin.close();
} catch (Exception ex) { | // Path: src/main/java/org/cf/resequencer/Console.java
// public class Console {
// private static final boolean StackTrace = false;
// public static int VerboseLevel;
// public static String LogFile = "console.log";
//
// public static void msgln() {
// System.out.println();
// }
//
// public static void msgln(final String msg) {
// System.out.println(msg);
// }
//
// public static void msg(final String msg) {
// System.out.print(msg);
// }
//
// public static void debug(final String msg) {
// if (VerboseLevel > 0) {
// System.out.println(msg);
// }
// }
//
// public static void debug(final String msg, final int verboseLevel) {
// if (verboseLevel <= VerboseLevel) {
// debug(msg);
// }
// }
//
// public static void warn(final String msg) {
// System.err.println("Warning: " + msg);
// if (StackTrace) {
// Thread.dumpStack();
// }
// }
//
// public static void error(final String msg) {
// System.err.println("Error: " + msg);
// if (StackTrace) {
// Thread.dumpStack();
// }
// }
//
// public static void die(final Exception ex) {
// die(ex, -1);
// }
//
// public static void die(final Exception ex, final int exitStatus) {
// if (StackTrace) {
// ex.printStackTrace();
// }
// System.err.println("" + ex);
// System.exit(exitStatus);
// }
//
// public static void die(final String msg) {
// die(msg, -1);
// }
//
// public static void die(final String msg, int exitStatus) {
// System.err.println("Fatal error: " + msg);
// if (StackTrace) {
// Thread.dumpStack();
// }
// System.exit(exitStatus);
// }
//
// // run command and return {result, exit status}
// public static String[] execute(String[] cmd) {
// debug("Executing: " + Arrays.asList(cmd).toString());
//
// StringBuffer output = new StringBuffer();
// Integer status = null;
//
// InputStream in = null;
// try {
// Process child = Runtime.getRuntime().exec(cmd);
//
// BufferedReader stdInput = new BufferedReader(new InputStreamReader(child.getInputStream()));
//
// String s;
// while ((s = stdInput.readLine()) != null) {
// output.append(s).append('\n');
// }
//
// status = child.waitFor();
//
// debug("Exit status: " + status, 2);
// } catch (Exception ex) {
// error("Run command failed.\n" + ex);
// } finally {
// IOUtils.closeQuietly(in);
// }
//
// return new String[] { output.toString(), String.valueOf(status) };
// }
//
// public static boolean deleteBestEffort(File path, String whatIsIt) {
// return deleteBestEffort(path, whatIsIt, 3, false);
// }
//
// public static boolean deleteBestEffort(File path, String whatIsIt, int maxTries) {
// return deleteBestEffort(path, whatIsIt, maxTries, false);
// }
//
// public static boolean deleteBestEffort(File path, String whatIsIt, int maxTries, boolean quiet) {
// System.gc();
//
// int tries = 0;
// while (!FileUtils.deleteQuietly(path) && (tries < maxTries)) {
// System.gc();
// tries++;
//
// if (!quiet) {
// warn("Unable to delete " + whatIsIt + ": " + path + ". Trying again ...");
// }
//
// try {
// Thread.sleep(3000);
// } catch (InterruptedException ex) {
// }
// }
//
// return !path.exists();
// }
// }
// Path: src/main/java/org/cf/resequencer/sequence/ZipUtils.java
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.zip.Deflater;
import java.util.zip.ZipEntry;
import java.util.zip.ZipInputStream;
import java.util.zip.ZipOutputStream;
import org.apache.commons.io.FileUtils;
import org.cf.resequencer.Console;
if (directory == null) {
if (newFile.isDirectory()) {
break;
}
}
String destPath;
if ((destPaths == null) || (destPaths.length < inFilesIndex)) {
destPath = entry.getName();
} else {
destPath = destPaths[inFilesIndex];
}
makeDestDirectory(new File(destPath));
fos = new FileOutputStream(destPath);
int n;
while ((n = zin.read(buf, 0, 1024)) > -1) {
fos.write(buf, 0, n);
}
fos.close();
zin.closeEntry();
}
entry = zin.getNextEntry();
}
zin.close();
} catch (Exception ex) { | Console.error("Problem while extracting file from " + zipFile.getPath() + ": " + ex + "."); |
CalebFenton/resequencer | src/main/java/org/cf/resequencer/patch/Operation.java | // Path: src/main/java/org/cf/resequencer/Console.java
// public class Console {
// private static final boolean StackTrace = false;
// public static int VerboseLevel;
// public static String LogFile = "console.log";
//
// public static void msgln() {
// System.out.println();
// }
//
// public static void msgln(final String msg) {
// System.out.println(msg);
// }
//
// public static void msg(final String msg) {
// System.out.print(msg);
// }
//
// public static void debug(final String msg) {
// if (VerboseLevel > 0) {
// System.out.println(msg);
// }
// }
//
// public static void debug(final String msg, final int verboseLevel) {
// if (verboseLevel <= VerboseLevel) {
// debug(msg);
// }
// }
//
// public static void warn(final String msg) {
// System.err.println("Warning: " + msg);
// if (StackTrace) {
// Thread.dumpStack();
// }
// }
//
// public static void error(final String msg) {
// System.err.println("Error: " + msg);
// if (StackTrace) {
// Thread.dumpStack();
// }
// }
//
// public static void die(final Exception ex) {
// die(ex, -1);
// }
//
// public static void die(final Exception ex, final int exitStatus) {
// if (StackTrace) {
// ex.printStackTrace();
// }
// System.err.println("" + ex);
// System.exit(exitStatus);
// }
//
// public static void die(final String msg) {
// die(msg, -1);
// }
//
// public static void die(final String msg, int exitStatus) {
// System.err.println("Fatal error: " + msg);
// if (StackTrace) {
// Thread.dumpStack();
// }
// System.exit(exitStatus);
// }
//
// // run command and return {result, exit status}
// public static String[] execute(String[] cmd) {
// debug("Executing: " + Arrays.asList(cmd).toString());
//
// StringBuffer output = new StringBuffer();
// Integer status = null;
//
// InputStream in = null;
// try {
// Process child = Runtime.getRuntime().exec(cmd);
//
// BufferedReader stdInput = new BufferedReader(new InputStreamReader(child.getInputStream()));
//
// String s;
// while ((s = stdInput.readLine()) != null) {
// output.append(s).append('\n');
// }
//
// status = child.waitFor();
//
// debug("Exit status: " + status, 2);
// } catch (Exception ex) {
// error("Run command failed.\n" + ex);
// } finally {
// IOUtils.closeQuietly(in);
// }
//
// return new String[] { output.toString(), String.valueOf(status) };
// }
//
// public static boolean deleteBestEffort(File path, String whatIsIt) {
// return deleteBestEffort(path, whatIsIt, 3, false);
// }
//
// public static boolean deleteBestEffort(File path, String whatIsIt, int maxTries) {
// return deleteBestEffort(path, whatIsIt, maxTries, false);
// }
//
// public static boolean deleteBestEffort(File path, String whatIsIt, int maxTries, boolean quiet) {
// System.gc();
//
// int tries = 0;
// while (!FileUtils.deleteQuietly(path) && (tries < maxTries)) {
// System.gc();
// tries++;
//
// if (!quiet) {
// warn("Unable to delete " + whatIsIt + ": " + path + ". Trying again ...");
// }
//
// try {
// Thread.sleep(3000);
// } catch (InterruptedException ex) {
// }
// }
//
// return !path.exists();
// }
// }
| import java.util.ArrayList;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.cf.resequencer.Console; |
public void setBeforeOP(String findName) {
BeforeOPStr = findName;
}
public void setInsideOP(String findName) {
InsideOPStr = findName;
}
public void setReplaceWhat(String replaceWhat) {
ReplaceWhat = replaceWhat;
}
public void setType(String type) {
if (type.equalsIgnoreCase("match")) {
OpType = OpTypes.MATCH;
} else if (type.equalsIgnoreCase("find")) {
OpType = OpTypes.FIND;
} else if (type.equalsIgnoreCase("insert")) {
OpType = OpTypes.INSERT;
} else if (type.equalsIgnoreCase("replace")) {
OpType = OpTypes.REPLACE;
}
}
public void setLimit(int limit) {
OpLimit = limit;
}
public void buildDependentList() { | // Path: src/main/java/org/cf/resequencer/Console.java
// public class Console {
// private static final boolean StackTrace = false;
// public static int VerboseLevel;
// public static String LogFile = "console.log";
//
// public static void msgln() {
// System.out.println();
// }
//
// public static void msgln(final String msg) {
// System.out.println(msg);
// }
//
// public static void msg(final String msg) {
// System.out.print(msg);
// }
//
// public static void debug(final String msg) {
// if (VerboseLevel > 0) {
// System.out.println(msg);
// }
// }
//
// public static void debug(final String msg, final int verboseLevel) {
// if (verboseLevel <= VerboseLevel) {
// debug(msg);
// }
// }
//
// public static void warn(final String msg) {
// System.err.println("Warning: " + msg);
// if (StackTrace) {
// Thread.dumpStack();
// }
// }
//
// public static void error(final String msg) {
// System.err.println("Error: " + msg);
// if (StackTrace) {
// Thread.dumpStack();
// }
// }
//
// public static void die(final Exception ex) {
// die(ex, -1);
// }
//
// public static void die(final Exception ex, final int exitStatus) {
// if (StackTrace) {
// ex.printStackTrace();
// }
// System.err.println("" + ex);
// System.exit(exitStatus);
// }
//
// public static void die(final String msg) {
// die(msg, -1);
// }
//
// public static void die(final String msg, int exitStatus) {
// System.err.println("Fatal error: " + msg);
// if (StackTrace) {
// Thread.dumpStack();
// }
// System.exit(exitStatus);
// }
//
// // run command and return {result, exit status}
// public static String[] execute(String[] cmd) {
// debug("Executing: " + Arrays.asList(cmd).toString());
//
// StringBuffer output = new StringBuffer();
// Integer status = null;
//
// InputStream in = null;
// try {
// Process child = Runtime.getRuntime().exec(cmd);
//
// BufferedReader stdInput = new BufferedReader(new InputStreamReader(child.getInputStream()));
//
// String s;
// while ((s = stdInput.readLine()) != null) {
// output.append(s).append('\n');
// }
//
// status = child.waitFor();
//
// debug("Exit status: " + status, 2);
// } catch (Exception ex) {
// error("Run command failed.\n" + ex);
// } finally {
// IOUtils.closeQuietly(in);
// }
//
// return new String[] { output.toString(), String.valueOf(status) };
// }
//
// public static boolean deleteBestEffort(File path, String whatIsIt) {
// return deleteBestEffort(path, whatIsIt, 3, false);
// }
//
// public static boolean deleteBestEffort(File path, String whatIsIt, int maxTries) {
// return deleteBestEffort(path, whatIsIt, maxTries, false);
// }
//
// public static boolean deleteBestEffort(File path, String whatIsIt, int maxTries, boolean quiet) {
// System.gc();
//
// int tries = 0;
// while (!FileUtils.deleteQuietly(path) && (tries < maxTries)) {
// System.gc();
// tries++;
//
// if (!quiet) {
// warn("Unable to delete " + whatIsIt + ": " + path + ". Trying again ...");
// }
//
// try {
// Thread.sleep(3000);
// } catch (InterruptedException ex) {
// }
// }
//
// return !path.exists();
// }
// }
// Path: src/main/java/org/cf/resequencer/patch/Operation.java
import java.util.ArrayList;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.cf.resequencer.Console;
public void setBeforeOP(String findName) {
BeforeOPStr = findName;
}
public void setInsideOP(String findName) {
InsideOPStr = findName;
}
public void setReplaceWhat(String replaceWhat) {
ReplaceWhat = replaceWhat;
}
public void setType(String type) {
if (type.equalsIgnoreCase("match")) {
OpType = OpTypes.MATCH;
} else if (type.equalsIgnoreCase("find")) {
OpType = OpTypes.FIND;
} else if (type.equalsIgnoreCase("insert")) {
OpType = OpTypes.INSERT;
} else if (type.equalsIgnoreCase("replace")) {
OpType = OpTypes.REPLACE;
}
}
public void setLimit(int limit) {
OpLimit = limit;
}
public void buildDependentList() { | Console.debug("Building dependent operation list for operation " + RegionName + ".", 2); |
CalebFenton/resequencer | src/main/java/org/cf/resequencer/patch/SmaliFile.java | // Path: src/main/java/org/cf/resequencer/Console.java
// public class Console {
// private static final boolean StackTrace = false;
// public static int VerboseLevel;
// public static String LogFile = "console.log";
//
// public static void msgln() {
// System.out.println();
// }
//
// public static void msgln(final String msg) {
// System.out.println(msg);
// }
//
// public static void msg(final String msg) {
// System.out.print(msg);
// }
//
// public static void debug(final String msg) {
// if (VerboseLevel > 0) {
// System.out.println(msg);
// }
// }
//
// public static void debug(final String msg, final int verboseLevel) {
// if (verboseLevel <= VerboseLevel) {
// debug(msg);
// }
// }
//
// public static void warn(final String msg) {
// System.err.println("Warning: " + msg);
// if (StackTrace) {
// Thread.dumpStack();
// }
// }
//
// public static void error(final String msg) {
// System.err.println("Error: " + msg);
// if (StackTrace) {
// Thread.dumpStack();
// }
// }
//
// public static void die(final Exception ex) {
// die(ex, -1);
// }
//
// public static void die(final Exception ex, final int exitStatus) {
// if (StackTrace) {
// ex.printStackTrace();
// }
// System.err.println("" + ex);
// System.exit(exitStatus);
// }
//
// public static void die(final String msg) {
// die(msg, -1);
// }
//
// public static void die(final String msg, int exitStatus) {
// System.err.println("Fatal error: " + msg);
// if (StackTrace) {
// Thread.dumpStack();
// }
// System.exit(exitStatus);
// }
//
// // run command and return {result, exit status}
// public static String[] execute(String[] cmd) {
// debug("Executing: " + Arrays.asList(cmd).toString());
//
// StringBuffer output = new StringBuffer();
// Integer status = null;
//
// InputStream in = null;
// try {
// Process child = Runtime.getRuntime().exec(cmd);
//
// BufferedReader stdInput = new BufferedReader(new InputStreamReader(child.getInputStream()));
//
// String s;
// while ((s = stdInput.readLine()) != null) {
// output.append(s).append('\n');
// }
//
// status = child.waitFor();
//
// debug("Exit status: " + status, 2);
// } catch (Exception ex) {
// error("Run command failed.\n" + ex);
// } finally {
// IOUtils.closeQuietly(in);
// }
//
// return new String[] { output.toString(), String.valueOf(status) };
// }
//
// public static boolean deleteBestEffort(File path, String whatIsIt) {
// return deleteBestEffort(path, whatIsIt, 3, false);
// }
//
// public static boolean deleteBestEffort(File path, String whatIsIt, int maxTries) {
// return deleteBestEffort(path, whatIsIt, maxTries, false);
// }
//
// public static boolean deleteBestEffort(File path, String whatIsIt, int maxTries, boolean quiet) {
// System.gc();
//
// int tries = 0;
// while (!FileUtils.deleteQuietly(path) && (tries < maxTries)) {
// System.gc();
// tries++;
//
// if (!quiet) {
// warn("Unable to delete " + whatIsIt + ": " + path + ". Trying again ...");
// }
//
// try {
// Thread.sleep(3000);
// } catch (InterruptedException ex) {
// }
// }
//
// return !path.exists();
// }
// }
| import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.util.HashMap;
import java.util.Map;
import java.util.List;
import java.util.SortedSet;
import java.util.TreeSet;
import java.util.regex.Pattern;
import org.apache.commons.io.FileUtils;
import org.apache.commons.io.IOUtils;
import org.cf.resequencer.Console; | */
public String FileLines;
/**
* Clones of fingerprints matched against this file. Keys are fingerprint names.
*/
public Map<String, Fingerprint> Fingerprints;
/**
* Offsets for regions. Keys are region names.
*/
public Map<String, Integer[]> RegionOffsetList;
/**
* List of code modifications to perform
*/
public SortedSet<CodeModification> CodeModifications;
/**
* Notify the user if this file is matched?
*/
public boolean Notify;
public SmaliFile() {
Fingerprints = new HashMap<String, Fingerprint>();
RegionOffsetList = new HashMap<String, Integer[]>();
CodeModifications = new TreeSet<CodeModification>();
Notify = true;
}
public SmaliFile(File smaliFile) {
this();
if (!smaliFile.exists()) { | // Path: src/main/java/org/cf/resequencer/Console.java
// public class Console {
// private static final boolean StackTrace = false;
// public static int VerboseLevel;
// public static String LogFile = "console.log";
//
// public static void msgln() {
// System.out.println();
// }
//
// public static void msgln(final String msg) {
// System.out.println(msg);
// }
//
// public static void msg(final String msg) {
// System.out.print(msg);
// }
//
// public static void debug(final String msg) {
// if (VerboseLevel > 0) {
// System.out.println(msg);
// }
// }
//
// public static void debug(final String msg, final int verboseLevel) {
// if (verboseLevel <= VerboseLevel) {
// debug(msg);
// }
// }
//
// public static void warn(final String msg) {
// System.err.println("Warning: " + msg);
// if (StackTrace) {
// Thread.dumpStack();
// }
// }
//
// public static void error(final String msg) {
// System.err.println("Error: " + msg);
// if (StackTrace) {
// Thread.dumpStack();
// }
// }
//
// public static void die(final Exception ex) {
// die(ex, -1);
// }
//
// public static void die(final Exception ex, final int exitStatus) {
// if (StackTrace) {
// ex.printStackTrace();
// }
// System.err.println("" + ex);
// System.exit(exitStatus);
// }
//
// public static void die(final String msg) {
// die(msg, -1);
// }
//
// public static void die(final String msg, int exitStatus) {
// System.err.println("Fatal error: " + msg);
// if (StackTrace) {
// Thread.dumpStack();
// }
// System.exit(exitStatus);
// }
//
// // run command and return {result, exit status}
// public static String[] execute(String[] cmd) {
// debug("Executing: " + Arrays.asList(cmd).toString());
//
// StringBuffer output = new StringBuffer();
// Integer status = null;
//
// InputStream in = null;
// try {
// Process child = Runtime.getRuntime().exec(cmd);
//
// BufferedReader stdInput = new BufferedReader(new InputStreamReader(child.getInputStream()));
//
// String s;
// while ((s = stdInput.readLine()) != null) {
// output.append(s).append('\n');
// }
//
// status = child.waitFor();
//
// debug("Exit status: " + status, 2);
// } catch (Exception ex) {
// error("Run command failed.\n" + ex);
// } finally {
// IOUtils.closeQuietly(in);
// }
//
// return new String[] { output.toString(), String.valueOf(status) };
// }
//
// public static boolean deleteBestEffort(File path, String whatIsIt) {
// return deleteBestEffort(path, whatIsIt, 3, false);
// }
//
// public static boolean deleteBestEffort(File path, String whatIsIt, int maxTries) {
// return deleteBestEffort(path, whatIsIt, maxTries, false);
// }
//
// public static boolean deleteBestEffort(File path, String whatIsIt, int maxTries, boolean quiet) {
// System.gc();
//
// int tries = 0;
// while (!FileUtils.deleteQuietly(path) && (tries < maxTries)) {
// System.gc();
// tries++;
//
// if (!quiet) {
// warn("Unable to delete " + whatIsIt + ": " + path + ". Trying again ...");
// }
//
// try {
// Thread.sleep(3000);
// } catch (InterruptedException ex) {
// }
// }
//
// return !path.exists();
// }
// }
// Path: src/main/java/org/cf/resequencer/patch/SmaliFile.java
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.util.HashMap;
import java.util.Map;
import java.util.List;
import java.util.SortedSet;
import java.util.TreeSet;
import java.util.regex.Pattern;
import org.apache.commons.io.FileUtils;
import org.apache.commons.io.IOUtils;
import org.cf.resequencer.Console;
*/
public String FileLines;
/**
* Clones of fingerprints matched against this file. Keys are fingerprint names.
*/
public Map<String, Fingerprint> Fingerprints;
/**
* Offsets for regions. Keys are region names.
*/
public Map<String, Integer[]> RegionOffsetList;
/**
* List of code modifications to perform
*/
public SortedSet<CodeModification> CodeModifications;
/**
* Notify the user if this file is matched?
*/
public boolean Notify;
public SmaliFile() {
Fingerprints = new HashMap<String, Fingerprint>();
RegionOffsetList = new HashMap<String, Integer[]>();
CodeModifications = new TreeSet<CodeModification>();
Notify = true;
}
public SmaliFile(File smaliFile) {
this();
if (!smaliFile.exists()) { | Console.die("Smali file does not exist: " + smaliFile + ".", -1); |
CalebFenton/resequencer | src/main/java/org/cf/resequencer/patch/Fingerprint.java | // Path: src/main/java/org/cf/resequencer/Console.java
// public class Console {
// private static final boolean StackTrace = false;
// public static int VerboseLevel;
// public static String LogFile = "console.log";
//
// public static void msgln() {
// System.out.println();
// }
//
// public static void msgln(final String msg) {
// System.out.println(msg);
// }
//
// public static void msg(final String msg) {
// System.out.print(msg);
// }
//
// public static void debug(final String msg) {
// if (VerboseLevel > 0) {
// System.out.println(msg);
// }
// }
//
// public static void debug(final String msg, final int verboseLevel) {
// if (verboseLevel <= VerboseLevel) {
// debug(msg);
// }
// }
//
// public static void warn(final String msg) {
// System.err.println("Warning: " + msg);
// if (StackTrace) {
// Thread.dumpStack();
// }
// }
//
// public static void error(final String msg) {
// System.err.println("Error: " + msg);
// if (StackTrace) {
// Thread.dumpStack();
// }
// }
//
// public static void die(final Exception ex) {
// die(ex, -1);
// }
//
// public static void die(final Exception ex, final int exitStatus) {
// if (StackTrace) {
// ex.printStackTrace();
// }
// System.err.println("" + ex);
// System.exit(exitStatus);
// }
//
// public static void die(final String msg) {
// die(msg, -1);
// }
//
// public static void die(final String msg, int exitStatus) {
// System.err.println("Fatal error: " + msg);
// if (StackTrace) {
// Thread.dumpStack();
// }
// System.exit(exitStatus);
// }
//
// // run command and return {result, exit status}
// public static String[] execute(String[] cmd) {
// debug("Executing: " + Arrays.asList(cmd).toString());
//
// StringBuffer output = new StringBuffer();
// Integer status = null;
//
// InputStream in = null;
// try {
// Process child = Runtime.getRuntime().exec(cmd);
//
// BufferedReader stdInput = new BufferedReader(new InputStreamReader(child.getInputStream()));
//
// String s;
// while ((s = stdInput.readLine()) != null) {
// output.append(s).append('\n');
// }
//
// status = child.waitFor();
//
// debug("Exit status: " + status, 2);
// } catch (Exception ex) {
// error("Run command failed.\n" + ex);
// } finally {
// IOUtils.closeQuietly(in);
// }
//
// return new String[] { output.toString(), String.valueOf(status) };
// }
//
// public static boolean deleteBestEffort(File path, String whatIsIt) {
// return deleteBestEffort(path, whatIsIt, 3, false);
// }
//
// public static boolean deleteBestEffort(File path, String whatIsIt, int maxTries) {
// return deleteBestEffort(path, whatIsIt, maxTries, false);
// }
//
// public static boolean deleteBestEffort(File path, String whatIsIt, int maxTries, boolean quiet) {
// System.gc();
//
// int tries = 0;
// while (!FileUtils.deleteQuietly(path) && (tries < maxTries)) {
// System.gc();
// tries++;
//
// if (!quiet) {
// warn("Unable to delete " + whatIsIt + ": " + path + ". Trying again ...");
// }
//
// try {
// Thread.sleep(3000);
// } catch (InterruptedException ex) {
// }
// }
//
// return !path.exists();
// }
// }
| import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Set;
import org.cf.resequencer.Console; | }
return fpClone;
}
@Override
public String toString() {
return FingerprintName;
}
public void addIncompatible(String fpName) {
IncompatibleFingerprints.add(fpName);
}
public void addRequired(String fpName) {
RequiredFingerprints.add(fpName);
}
public void addRegion(Region region) {
Regions.put(region.hashCode(), region);
}
public void addDeletePath(String path) {
DeletePaths.add(path);
}
public boolean match(SmaliFile smaliFile) {
List<Region> addRegions = new ArrayList<Region>();
Region region;
| // Path: src/main/java/org/cf/resequencer/Console.java
// public class Console {
// private static final boolean StackTrace = false;
// public static int VerboseLevel;
// public static String LogFile = "console.log";
//
// public static void msgln() {
// System.out.println();
// }
//
// public static void msgln(final String msg) {
// System.out.println(msg);
// }
//
// public static void msg(final String msg) {
// System.out.print(msg);
// }
//
// public static void debug(final String msg) {
// if (VerboseLevel > 0) {
// System.out.println(msg);
// }
// }
//
// public static void debug(final String msg, final int verboseLevel) {
// if (verboseLevel <= VerboseLevel) {
// debug(msg);
// }
// }
//
// public static void warn(final String msg) {
// System.err.println("Warning: " + msg);
// if (StackTrace) {
// Thread.dumpStack();
// }
// }
//
// public static void error(final String msg) {
// System.err.println("Error: " + msg);
// if (StackTrace) {
// Thread.dumpStack();
// }
// }
//
// public static void die(final Exception ex) {
// die(ex, -1);
// }
//
// public static void die(final Exception ex, final int exitStatus) {
// if (StackTrace) {
// ex.printStackTrace();
// }
// System.err.println("" + ex);
// System.exit(exitStatus);
// }
//
// public static void die(final String msg) {
// die(msg, -1);
// }
//
// public static void die(final String msg, int exitStatus) {
// System.err.println("Fatal error: " + msg);
// if (StackTrace) {
// Thread.dumpStack();
// }
// System.exit(exitStatus);
// }
//
// // run command and return {result, exit status}
// public static String[] execute(String[] cmd) {
// debug("Executing: " + Arrays.asList(cmd).toString());
//
// StringBuffer output = new StringBuffer();
// Integer status = null;
//
// InputStream in = null;
// try {
// Process child = Runtime.getRuntime().exec(cmd);
//
// BufferedReader stdInput = new BufferedReader(new InputStreamReader(child.getInputStream()));
//
// String s;
// while ((s = stdInput.readLine()) != null) {
// output.append(s).append('\n');
// }
//
// status = child.waitFor();
//
// debug("Exit status: " + status, 2);
// } catch (Exception ex) {
// error("Run command failed.\n" + ex);
// } finally {
// IOUtils.closeQuietly(in);
// }
//
// return new String[] { output.toString(), String.valueOf(status) };
// }
//
// public static boolean deleteBestEffort(File path, String whatIsIt) {
// return deleteBestEffort(path, whatIsIt, 3, false);
// }
//
// public static boolean deleteBestEffort(File path, String whatIsIt, int maxTries) {
// return deleteBestEffort(path, whatIsIt, maxTries, false);
// }
//
// public static boolean deleteBestEffort(File path, String whatIsIt, int maxTries, boolean quiet) {
// System.gc();
//
// int tries = 0;
// while (!FileUtils.deleteQuietly(path) && (tries < maxTries)) {
// System.gc();
// tries++;
//
// if (!quiet) {
// warn("Unable to delete " + whatIsIt + ": " + path + ". Trying again ...");
// }
//
// try {
// Thread.sleep(3000);
// } catch (InterruptedException ex) {
// }
// }
//
// return !path.exists();
// }
// }
// Path: src/main/java/org/cf/resequencer/patch/Fingerprint.java
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Set;
import org.cf.resequencer.Console;
}
return fpClone;
}
@Override
public String toString() {
return FingerprintName;
}
public void addIncompatible(String fpName) {
IncompatibleFingerprints.add(fpName);
}
public void addRequired(String fpName) {
RequiredFingerprints.add(fpName);
}
public void addRegion(Region region) {
Regions.put(region.hashCode(), region);
}
public void addDeletePath(String path) {
DeletePaths.add(path);
}
public boolean match(SmaliFile smaliFile) {
List<Region> addRegions = new ArrayList<Region>();
Region region;
| Console.debug("Searching for " + FingerprintName + " in " + smaliFile, 2); |
CalebFenton/resequencer | src/main/java/org/cf/resequencer/patch/Splicer.java | // Path: src/main/java/org/cf/resequencer/Console.java
// public class Console {
// private static final boolean StackTrace = false;
// public static int VerboseLevel;
// public static String LogFile = "console.log";
//
// public static void msgln() {
// System.out.println();
// }
//
// public static void msgln(final String msg) {
// System.out.println(msg);
// }
//
// public static void msg(final String msg) {
// System.out.print(msg);
// }
//
// public static void debug(final String msg) {
// if (VerboseLevel > 0) {
// System.out.println(msg);
// }
// }
//
// public static void debug(final String msg, final int verboseLevel) {
// if (verboseLevel <= VerboseLevel) {
// debug(msg);
// }
// }
//
// public static void warn(final String msg) {
// System.err.println("Warning: " + msg);
// if (StackTrace) {
// Thread.dumpStack();
// }
// }
//
// public static void error(final String msg) {
// System.err.println("Error: " + msg);
// if (StackTrace) {
// Thread.dumpStack();
// }
// }
//
// public static void die(final Exception ex) {
// die(ex, -1);
// }
//
// public static void die(final Exception ex, final int exitStatus) {
// if (StackTrace) {
// ex.printStackTrace();
// }
// System.err.println("" + ex);
// System.exit(exitStatus);
// }
//
// public static void die(final String msg) {
// die(msg, -1);
// }
//
// public static void die(final String msg, int exitStatus) {
// System.err.println("Fatal error: " + msg);
// if (StackTrace) {
// Thread.dumpStack();
// }
// System.exit(exitStatus);
// }
//
// // run command and return {result, exit status}
// public static String[] execute(String[] cmd) {
// debug("Executing: " + Arrays.asList(cmd).toString());
//
// StringBuffer output = new StringBuffer();
// Integer status = null;
//
// InputStream in = null;
// try {
// Process child = Runtime.getRuntime().exec(cmd);
//
// BufferedReader stdInput = new BufferedReader(new InputStreamReader(child.getInputStream()));
//
// String s;
// while ((s = stdInput.readLine()) != null) {
// output.append(s).append('\n');
// }
//
// status = child.waitFor();
//
// debug("Exit status: " + status, 2);
// } catch (Exception ex) {
// error("Run command failed.\n" + ex);
// } finally {
// IOUtils.closeQuietly(in);
// }
//
// return new String[] { output.toString(), String.valueOf(status) };
// }
//
// public static boolean deleteBestEffort(File path, String whatIsIt) {
// return deleteBestEffort(path, whatIsIt, 3, false);
// }
//
// public static boolean deleteBestEffort(File path, String whatIsIt, int maxTries) {
// return deleteBestEffort(path, whatIsIt, maxTries, false);
// }
//
// public static boolean deleteBestEffort(File path, String whatIsIt, int maxTries, boolean quiet) {
// System.gc();
//
// int tries = 0;
// while (!FileUtils.deleteQuietly(path) && (tries < maxTries)) {
// System.gc();
// tries++;
//
// if (!quiet) {
// warn("Unable to delete " + whatIsIt + ": " + path + ". Trying again ...");
// }
//
// try {
// Thread.sleep(3000);
// } catch (InterruptedException ex) {
// }
// }
//
// return !path.exists();
// }
// }
| import java.io.File;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import org.cf.resequencer.Console; | String out = " - " + stringIntegerEntry.getKey();
// also show number of times it was applied
if (stringIntegerEntry.getValue() > 1) {
out += " (" + stringIntegerEntry.getValue() + ")";
}
System.out.println(out);
}
} else {
System.out.println(" failure!");
}
}
}
System.out.println();
return true;
}
private void performDeleteOps() {
Set<String> delPaths = new HashSet<String>();
for (SmaliFile sf : SmaliFileMatches) {
for (String fpName : sf.Fingerprints.keySet()) {
Fingerprint fp = sf.Fingerprints.get(fpName);
delPaths.addAll(fp.DeletePaths);
}
}
for (String path : delPaths) {
File delMe = new File(SmaliDir + File.separator + path);
if (delMe.exists()) { | // Path: src/main/java/org/cf/resequencer/Console.java
// public class Console {
// private static final boolean StackTrace = false;
// public static int VerboseLevel;
// public static String LogFile = "console.log";
//
// public static void msgln() {
// System.out.println();
// }
//
// public static void msgln(final String msg) {
// System.out.println(msg);
// }
//
// public static void msg(final String msg) {
// System.out.print(msg);
// }
//
// public static void debug(final String msg) {
// if (VerboseLevel > 0) {
// System.out.println(msg);
// }
// }
//
// public static void debug(final String msg, final int verboseLevel) {
// if (verboseLevel <= VerboseLevel) {
// debug(msg);
// }
// }
//
// public static void warn(final String msg) {
// System.err.println("Warning: " + msg);
// if (StackTrace) {
// Thread.dumpStack();
// }
// }
//
// public static void error(final String msg) {
// System.err.println("Error: " + msg);
// if (StackTrace) {
// Thread.dumpStack();
// }
// }
//
// public static void die(final Exception ex) {
// die(ex, -1);
// }
//
// public static void die(final Exception ex, final int exitStatus) {
// if (StackTrace) {
// ex.printStackTrace();
// }
// System.err.println("" + ex);
// System.exit(exitStatus);
// }
//
// public static void die(final String msg) {
// die(msg, -1);
// }
//
// public static void die(final String msg, int exitStatus) {
// System.err.println("Fatal error: " + msg);
// if (StackTrace) {
// Thread.dumpStack();
// }
// System.exit(exitStatus);
// }
//
// // run command and return {result, exit status}
// public static String[] execute(String[] cmd) {
// debug("Executing: " + Arrays.asList(cmd).toString());
//
// StringBuffer output = new StringBuffer();
// Integer status = null;
//
// InputStream in = null;
// try {
// Process child = Runtime.getRuntime().exec(cmd);
//
// BufferedReader stdInput = new BufferedReader(new InputStreamReader(child.getInputStream()));
//
// String s;
// while ((s = stdInput.readLine()) != null) {
// output.append(s).append('\n');
// }
//
// status = child.waitFor();
//
// debug("Exit status: " + status, 2);
// } catch (Exception ex) {
// error("Run command failed.\n" + ex);
// } finally {
// IOUtils.closeQuietly(in);
// }
//
// return new String[] { output.toString(), String.valueOf(status) };
// }
//
// public static boolean deleteBestEffort(File path, String whatIsIt) {
// return deleteBestEffort(path, whatIsIt, 3, false);
// }
//
// public static boolean deleteBestEffort(File path, String whatIsIt, int maxTries) {
// return deleteBestEffort(path, whatIsIt, maxTries, false);
// }
//
// public static boolean deleteBestEffort(File path, String whatIsIt, int maxTries, boolean quiet) {
// System.gc();
//
// int tries = 0;
// while (!FileUtils.deleteQuietly(path) && (tries < maxTries)) {
// System.gc();
// tries++;
//
// if (!quiet) {
// warn("Unable to delete " + whatIsIt + ": " + path + ". Trying again ...");
// }
//
// try {
// Thread.sleep(3000);
// } catch (InterruptedException ex) {
// }
// }
//
// return !path.exists();
// }
// }
// Path: src/main/java/org/cf/resequencer/patch/Splicer.java
import java.io.File;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import org.cf.resequencer.Console;
String out = " - " + stringIntegerEntry.getKey();
// also show number of times it was applied
if (stringIntegerEntry.getValue() > 1) {
out += " (" + stringIntegerEntry.getValue() + ")";
}
System.out.println(out);
}
} else {
System.out.println(" failure!");
}
}
}
System.out.println();
return true;
}
private void performDeleteOps() {
Set<String> delPaths = new HashSet<String>();
for (SmaliFile sf : SmaliFileMatches) {
for (String fpName : sf.Fingerprints.keySet()) {
Fingerprint fp = sf.Fingerprints.get(fpName);
delPaths.addAll(fp.DeletePaths);
}
}
for (String path : delPaths) {
File delMe = new File(SmaliDir + File.separator + path);
if (delMe.exists()) { | if (!Console.deleteBestEffort(delMe, "deletePath")) { |
CalebFenton/resequencer | src/main/java/org/cf/resequencer/sequence/AppInfo.java | // Path: src/main/java/org/cf/resequencer/Console.java
// public class Console {
// private static final boolean StackTrace = false;
// public static int VerboseLevel;
// public static String LogFile = "console.log";
//
// public static void msgln() {
// System.out.println();
// }
//
// public static void msgln(final String msg) {
// System.out.println(msg);
// }
//
// public static void msg(final String msg) {
// System.out.print(msg);
// }
//
// public static void debug(final String msg) {
// if (VerboseLevel > 0) {
// System.out.println(msg);
// }
// }
//
// public static void debug(final String msg, final int verboseLevel) {
// if (verboseLevel <= VerboseLevel) {
// debug(msg);
// }
// }
//
// public static void warn(final String msg) {
// System.err.println("Warning: " + msg);
// if (StackTrace) {
// Thread.dumpStack();
// }
// }
//
// public static void error(final String msg) {
// System.err.println("Error: " + msg);
// if (StackTrace) {
// Thread.dumpStack();
// }
// }
//
// public static void die(final Exception ex) {
// die(ex, -1);
// }
//
// public static void die(final Exception ex, final int exitStatus) {
// if (StackTrace) {
// ex.printStackTrace();
// }
// System.err.println("" + ex);
// System.exit(exitStatus);
// }
//
// public static void die(final String msg) {
// die(msg, -1);
// }
//
// public static void die(final String msg, int exitStatus) {
// System.err.println("Fatal error: " + msg);
// if (StackTrace) {
// Thread.dumpStack();
// }
// System.exit(exitStatus);
// }
//
// // run command and return {result, exit status}
// public static String[] execute(String[] cmd) {
// debug("Executing: " + Arrays.asList(cmd).toString());
//
// StringBuffer output = new StringBuffer();
// Integer status = null;
//
// InputStream in = null;
// try {
// Process child = Runtime.getRuntime().exec(cmd);
//
// BufferedReader stdInput = new BufferedReader(new InputStreamReader(child.getInputStream()));
//
// String s;
// while ((s = stdInput.readLine()) != null) {
// output.append(s).append('\n');
// }
//
// status = child.waitFor();
//
// debug("Exit status: " + status, 2);
// } catch (Exception ex) {
// error("Run command failed.\n" + ex);
// } finally {
// IOUtils.closeQuietly(in);
// }
//
// return new String[] { output.toString(), String.valueOf(status) };
// }
//
// public static boolean deleteBestEffort(File path, String whatIsIt) {
// return deleteBestEffort(path, whatIsIt, 3, false);
// }
//
// public static boolean deleteBestEffort(File path, String whatIsIt, int maxTries) {
// return deleteBestEffort(path, whatIsIt, maxTries, false);
// }
//
// public static boolean deleteBestEffort(File path, String whatIsIt, int maxTries, boolean quiet) {
// System.gc();
//
// int tries = 0;
// while (!FileUtils.deleteQuietly(path) && (tries < maxTries)) {
// System.gc();
// tries++;
//
// if (!quiet) {
// warn("Unable to delete " + whatIsIt + ": " + path + ". Trying again ...");
// }
//
// try {
// Thread.sleep(3000);
// } catch (InterruptedException ex) {
// }
// }
//
// return !path.exists();
// }
// }
| import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.lang.ref.WeakReference;
import java.security.cert.Certificate;
import java.security.cert.CertificateEncodingException;
import java.util.Enumeration;
import java.util.jar.JarEntry;
import java.util.jar.JarFile;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.zip.ZipEntry;
import java.util.zip.ZipFile;
import org.cf.resequencer.Console; | public long DexChecksumAdler32;
public long ZipClassesDexCrc;
public long ZipClassesDexSize;
public long ZipClassesDexCompressedSize;
public Certificate[] Certificates;
public long ApkFileSize;
public long ApkLastModified;
public long ClassesDexFileSize;
public long ClassesDexLastModified;
public int CertsLoaded;
private String mApkPath, mAaptPath;
private static final Object mSync = new Object();
private WeakReference<byte[]> mReadBuffer;
AppInfo(String apkPath, String aaptPath) {
mApkPath = apkPath;
mAaptPath = aaptPath;
loadApkProperties();
}
private void loadApkProperties() {
loadApkAaptProps();
loadApkCertProps();
loadApkFileProps();
loadApkZipEntryProps();
loadApkChecksums();
}
private void loadApkAaptProps() { | // Path: src/main/java/org/cf/resequencer/Console.java
// public class Console {
// private static final boolean StackTrace = false;
// public static int VerboseLevel;
// public static String LogFile = "console.log";
//
// public static void msgln() {
// System.out.println();
// }
//
// public static void msgln(final String msg) {
// System.out.println(msg);
// }
//
// public static void msg(final String msg) {
// System.out.print(msg);
// }
//
// public static void debug(final String msg) {
// if (VerboseLevel > 0) {
// System.out.println(msg);
// }
// }
//
// public static void debug(final String msg, final int verboseLevel) {
// if (verboseLevel <= VerboseLevel) {
// debug(msg);
// }
// }
//
// public static void warn(final String msg) {
// System.err.println("Warning: " + msg);
// if (StackTrace) {
// Thread.dumpStack();
// }
// }
//
// public static void error(final String msg) {
// System.err.println("Error: " + msg);
// if (StackTrace) {
// Thread.dumpStack();
// }
// }
//
// public static void die(final Exception ex) {
// die(ex, -1);
// }
//
// public static void die(final Exception ex, final int exitStatus) {
// if (StackTrace) {
// ex.printStackTrace();
// }
// System.err.println("" + ex);
// System.exit(exitStatus);
// }
//
// public static void die(final String msg) {
// die(msg, -1);
// }
//
// public static void die(final String msg, int exitStatus) {
// System.err.println("Fatal error: " + msg);
// if (StackTrace) {
// Thread.dumpStack();
// }
// System.exit(exitStatus);
// }
//
// // run command and return {result, exit status}
// public static String[] execute(String[] cmd) {
// debug("Executing: " + Arrays.asList(cmd).toString());
//
// StringBuffer output = new StringBuffer();
// Integer status = null;
//
// InputStream in = null;
// try {
// Process child = Runtime.getRuntime().exec(cmd);
//
// BufferedReader stdInput = new BufferedReader(new InputStreamReader(child.getInputStream()));
//
// String s;
// while ((s = stdInput.readLine()) != null) {
// output.append(s).append('\n');
// }
//
// status = child.waitFor();
//
// debug("Exit status: " + status, 2);
// } catch (Exception ex) {
// error("Run command failed.\n" + ex);
// } finally {
// IOUtils.closeQuietly(in);
// }
//
// return new String[] { output.toString(), String.valueOf(status) };
// }
//
// public static boolean deleteBestEffort(File path, String whatIsIt) {
// return deleteBestEffort(path, whatIsIt, 3, false);
// }
//
// public static boolean deleteBestEffort(File path, String whatIsIt, int maxTries) {
// return deleteBestEffort(path, whatIsIt, maxTries, false);
// }
//
// public static boolean deleteBestEffort(File path, String whatIsIt, int maxTries, boolean quiet) {
// System.gc();
//
// int tries = 0;
// while (!FileUtils.deleteQuietly(path) && (tries < maxTries)) {
// System.gc();
// tries++;
//
// if (!quiet) {
// warn("Unable to delete " + whatIsIt + ": " + path + ". Trying again ...");
// }
//
// try {
// Thread.sleep(3000);
// } catch (InterruptedException ex) {
// }
// }
//
// return !path.exists();
// }
// }
// Path: src/main/java/org/cf/resequencer/sequence/AppInfo.java
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.lang.ref.WeakReference;
import java.security.cert.Certificate;
import java.security.cert.CertificateEncodingException;
import java.util.Enumeration;
import java.util.jar.JarEntry;
import java.util.jar.JarFile;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.zip.ZipEntry;
import java.util.zip.ZipFile;
import org.cf.resequencer.Console;
public long DexChecksumAdler32;
public long ZipClassesDexCrc;
public long ZipClassesDexSize;
public long ZipClassesDexCompressedSize;
public Certificate[] Certificates;
public long ApkFileSize;
public long ApkLastModified;
public long ClassesDexFileSize;
public long ClassesDexLastModified;
public int CertsLoaded;
private String mApkPath, mAaptPath;
private static final Object mSync = new Object();
private WeakReference<byte[]> mReadBuffer;
AppInfo(String apkPath, String aaptPath) {
mApkPath = apkPath;
mAaptPath = aaptPath;
loadApkProperties();
}
private void loadApkProperties() {
loadApkAaptProps();
loadApkCertProps();
loadApkFileProps();
loadApkZipEntryProps();
loadApkChecksums();
}
private void loadApkAaptProps() { | String[] info = Console.execute(new String[] { mAaptPath, "d", "badging", mApkPath }); |
CalebFenton/resequencer | src/main/java/org/cf/resequencer/sequence/SmaliFileFinder.java | // Path: src/main/java/org/cf/resequencer/Console.java
// public class Console {
// private static final boolean StackTrace = false;
// public static int VerboseLevel;
// public static String LogFile = "console.log";
//
// public static void msgln() {
// System.out.println();
// }
//
// public static void msgln(final String msg) {
// System.out.println(msg);
// }
//
// public static void msg(final String msg) {
// System.out.print(msg);
// }
//
// public static void debug(final String msg) {
// if (VerboseLevel > 0) {
// System.out.println(msg);
// }
// }
//
// public static void debug(final String msg, final int verboseLevel) {
// if (verboseLevel <= VerboseLevel) {
// debug(msg);
// }
// }
//
// public static void warn(final String msg) {
// System.err.println("Warning: " + msg);
// if (StackTrace) {
// Thread.dumpStack();
// }
// }
//
// public static void error(final String msg) {
// System.err.println("Error: " + msg);
// if (StackTrace) {
// Thread.dumpStack();
// }
// }
//
// public static void die(final Exception ex) {
// die(ex, -1);
// }
//
// public static void die(final Exception ex, final int exitStatus) {
// if (StackTrace) {
// ex.printStackTrace();
// }
// System.err.println("" + ex);
// System.exit(exitStatus);
// }
//
// public static void die(final String msg) {
// die(msg, -1);
// }
//
// public static void die(final String msg, int exitStatus) {
// System.err.println("Fatal error: " + msg);
// if (StackTrace) {
// Thread.dumpStack();
// }
// System.exit(exitStatus);
// }
//
// // run command and return {result, exit status}
// public static String[] execute(String[] cmd) {
// debug("Executing: " + Arrays.asList(cmd).toString());
//
// StringBuffer output = new StringBuffer();
// Integer status = null;
//
// InputStream in = null;
// try {
// Process child = Runtime.getRuntime().exec(cmd);
//
// BufferedReader stdInput = new BufferedReader(new InputStreamReader(child.getInputStream()));
//
// String s;
// while ((s = stdInput.readLine()) != null) {
// output.append(s).append('\n');
// }
//
// status = child.waitFor();
//
// debug("Exit status: " + status, 2);
// } catch (Exception ex) {
// error("Run command failed.\n" + ex);
// } finally {
// IOUtils.closeQuietly(in);
// }
//
// return new String[] { output.toString(), String.valueOf(status) };
// }
//
// public static boolean deleteBestEffort(File path, String whatIsIt) {
// return deleteBestEffort(path, whatIsIt, 3, false);
// }
//
// public static boolean deleteBestEffort(File path, String whatIsIt, int maxTries) {
// return deleteBestEffort(path, whatIsIt, maxTries, false);
// }
//
// public static boolean deleteBestEffort(File path, String whatIsIt, int maxTries, boolean quiet) {
// System.gc();
//
// int tries = 0;
// while (!FileUtils.deleteQuietly(path) && (tries < maxTries)) {
// System.gc();
// tries++;
//
// if (!quiet) {
// warn("Unable to delete " + whatIsIt + ": " + path + ". Trying again ...");
// }
//
// try {
// Thread.sleep(3000);
// } catch (InterruptedException ex) {
// }
// }
//
// return !path.exists();
// }
// }
| import java.io.File;
import java.io.FilenameFilter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import org.cf.resequencer.Console; | /*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package org.cf.resequencer.sequence;
class SmaliFilenameFilter implements FilenameFilter {
@Override
public boolean accept(File dir, String name) {
return name.endsWith(".smali");
}
}
/**
*
* @author Caleb Fenton
*/
public class SmaliFileFinder {
public static File[] getSmailFiles(File dir) {
return getSmaliFiles(dir, true);
}
// returns the FULL path to smali files
public static File[] getSmaliFiles(File dir, boolean recurse) {
List<File> smaliFiles = new ArrayList<File>();
if (!dir.exists() || !dir.canRead()) { | // Path: src/main/java/org/cf/resequencer/Console.java
// public class Console {
// private static final boolean StackTrace = false;
// public static int VerboseLevel;
// public static String LogFile = "console.log";
//
// public static void msgln() {
// System.out.println();
// }
//
// public static void msgln(final String msg) {
// System.out.println(msg);
// }
//
// public static void msg(final String msg) {
// System.out.print(msg);
// }
//
// public static void debug(final String msg) {
// if (VerboseLevel > 0) {
// System.out.println(msg);
// }
// }
//
// public static void debug(final String msg, final int verboseLevel) {
// if (verboseLevel <= VerboseLevel) {
// debug(msg);
// }
// }
//
// public static void warn(final String msg) {
// System.err.println("Warning: " + msg);
// if (StackTrace) {
// Thread.dumpStack();
// }
// }
//
// public static void error(final String msg) {
// System.err.println("Error: " + msg);
// if (StackTrace) {
// Thread.dumpStack();
// }
// }
//
// public static void die(final Exception ex) {
// die(ex, -1);
// }
//
// public static void die(final Exception ex, final int exitStatus) {
// if (StackTrace) {
// ex.printStackTrace();
// }
// System.err.println("" + ex);
// System.exit(exitStatus);
// }
//
// public static void die(final String msg) {
// die(msg, -1);
// }
//
// public static void die(final String msg, int exitStatus) {
// System.err.println("Fatal error: " + msg);
// if (StackTrace) {
// Thread.dumpStack();
// }
// System.exit(exitStatus);
// }
//
// // run command and return {result, exit status}
// public static String[] execute(String[] cmd) {
// debug("Executing: " + Arrays.asList(cmd).toString());
//
// StringBuffer output = new StringBuffer();
// Integer status = null;
//
// InputStream in = null;
// try {
// Process child = Runtime.getRuntime().exec(cmd);
//
// BufferedReader stdInput = new BufferedReader(new InputStreamReader(child.getInputStream()));
//
// String s;
// while ((s = stdInput.readLine()) != null) {
// output.append(s).append('\n');
// }
//
// status = child.waitFor();
//
// debug("Exit status: " + status, 2);
// } catch (Exception ex) {
// error("Run command failed.\n" + ex);
// } finally {
// IOUtils.closeQuietly(in);
// }
//
// return new String[] { output.toString(), String.valueOf(status) };
// }
//
// public static boolean deleteBestEffort(File path, String whatIsIt) {
// return deleteBestEffort(path, whatIsIt, 3, false);
// }
//
// public static boolean deleteBestEffort(File path, String whatIsIt, int maxTries) {
// return deleteBestEffort(path, whatIsIt, maxTries, false);
// }
//
// public static boolean deleteBestEffort(File path, String whatIsIt, int maxTries, boolean quiet) {
// System.gc();
//
// int tries = 0;
// while (!FileUtils.deleteQuietly(path) && (tries < maxTries)) {
// System.gc();
// tries++;
//
// if (!quiet) {
// warn("Unable to delete " + whatIsIt + ": " + path + ". Trying again ...");
// }
//
// try {
// Thread.sleep(3000);
// } catch (InterruptedException ex) {
// }
// }
//
// return !path.exists();
// }
// }
// Path: src/main/java/org/cf/resequencer/sequence/SmaliFileFinder.java
import java.io.File;
import java.io.FilenameFilter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import org.cf.resequencer.Console;
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package org.cf.resequencer.sequence;
class SmaliFilenameFilter implements FilenameFilter {
@Override
public boolean accept(File dir, String name) {
return name.endsWith(".smali");
}
}
/**
*
* @author Caleb Fenton
*/
public class SmaliFileFinder {
public static File[] getSmailFiles(File dir) {
return getSmaliFiles(dir, true);
}
// returns the FULL path to smali files
public static File[] getSmaliFiles(File dir, boolean recurse) {
List<File> smaliFiles = new ArrayList<File>();
if (!dir.exists() || !dir.canRead()) { | Console.warn("Smali dir " + dir + " does not exist or is not accessible."); |
CalebFenton/resequencer | src/main/java/org/cf/resequencer/sequence/ApkFile.java | // Path: src/main/java/org/cf/resequencer/Console.java
// public class Console {
// private static final boolean StackTrace = false;
// public static int VerboseLevel;
// public static String LogFile = "console.log";
//
// public static void msgln() {
// System.out.println();
// }
//
// public static void msgln(final String msg) {
// System.out.println(msg);
// }
//
// public static void msg(final String msg) {
// System.out.print(msg);
// }
//
// public static void debug(final String msg) {
// if (VerboseLevel > 0) {
// System.out.println(msg);
// }
// }
//
// public static void debug(final String msg, final int verboseLevel) {
// if (verboseLevel <= VerboseLevel) {
// debug(msg);
// }
// }
//
// public static void warn(final String msg) {
// System.err.println("Warning: " + msg);
// if (StackTrace) {
// Thread.dumpStack();
// }
// }
//
// public static void error(final String msg) {
// System.err.println("Error: " + msg);
// if (StackTrace) {
// Thread.dumpStack();
// }
// }
//
// public static void die(final Exception ex) {
// die(ex, -1);
// }
//
// public static void die(final Exception ex, final int exitStatus) {
// if (StackTrace) {
// ex.printStackTrace();
// }
// System.err.println("" + ex);
// System.exit(exitStatus);
// }
//
// public static void die(final String msg) {
// die(msg, -1);
// }
//
// public static void die(final String msg, int exitStatus) {
// System.err.println("Fatal error: " + msg);
// if (StackTrace) {
// Thread.dumpStack();
// }
// System.exit(exitStatus);
// }
//
// // run command and return {result, exit status}
// public static String[] execute(String[] cmd) {
// debug("Executing: " + Arrays.asList(cmd).toString());
//
// StringBuffer output = new StringBuffer();
// Integer status = null;
//
// InputStream in = null;
// try {
// Process child = Runtime.getRuntime().exec(cmd);
//
// BufferedReader stdInput = new BufferedReader(new InputStreamReader(child.getInputStream()));
//
// String s;
// while ((s = stdInput.readLine()) != null) {
// output.append(s).append('\n');
// }
//
// status = child.waitFor();
//
// debug("Exit status: " + status, 2);
// } catch (Exception ex) {
// error("Run command failed.\n" + ex);
// } finally {
// IOUtils.closeQuietly(in);
// }
//
// return new String[] { output.toString(), String.valueOf(status) };
// }
//
// public static boolean deleteBestEffort(File path, String whatIsIt) {
// return deleteBestEffort(path, whatIsIt, 3, false);
// }
//
// public static boolean deleteBestEffort(File path, String whatIsIt, int maxTries) {
// return deleteBestEffort(path, whatIsIt, maxTries, false);
// }
//
// public static boolean deleteBestEffort(File path, String whatIsIt, int maxTries, boolean quiet) {
// System.gc();
//
// int tries = 0;
// while (!FileUtils.deleteQuietly(path) && (tries < maxTries)) {
// System.gc();
// tries++;
//
// if (!quiet) {
// warn("Unable to delete " + whatIsIt + ": " + path + ". Trying again ...");
// }
//
// try {
// Thread.sleep(3000);
// } catch (InterruptedException ex) {
// }
// }
//
// return !path.exists();
// }
// }
| import java.io.File;
import java.io.FileInputStream;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.List;
import java.util.logging.ConsoleHandler;
import java.util.logging.Handler;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import org.apache.commons.io.FileUtils;
import org.cf.resequencer.Console;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import brut.androlib.Androlib;
import brut.androlib.ApkDecoder;
import brut.androlib.ApkOptions; | * Path to Apk file.
*/
public void apkSetApk(final String apkPath) {
ApkPath = apkPath;
}
/**
* Sets path to Aapt binary.
*
* @param aaptPath
* Path to Aapt binary.
*/
public void apkSetAaptPath(final String aaptPath) {
mAaptPath = aaptPath;
}
/**
* Sets path to Zipalign binary.
*
* @param zaPath
*/
public void apkSetZipalignPath(final String zaPath) {
mZipalignPath = zaPath;
}
/**
* Load Apk info such as certificates, signatures, etc. Requires Aapt.
*/
public void apkLoadAppInfo() {
if (mAaptPath.isEmpty()) { | // Path: src/main/java/org/cf/resequencer/Console.java
// public class Console {
// private static final boolean StackTrace = false;
// public static int VerboseLevel;
// public static String LogFile = "console.log";
//
// public static void msgln() {
// System.out.println();
// }
//
// public static void msgln(final String msg) {
// System.out.println(msg);
// }
//
// public static void msg(final String msg) {
// System.out.print(msg);
// }
//
// public static void debug(final String msg) {
// if (VerboseLevel > 0) {
// System.out.println(msg);
// }
// }
//
// public static void debug(final String msg, final int verboseLevel) {
// if (verboseLevel <= VerboseLevel) {
// debug(msg);
// }
// }
//
// public static void warn(final String msg) {
// System.err.println("Warning: " + msg);
// if (StackTrace) {
// Thread.dumpStack();
// }
// }
//
// public static void error(final String msg) {
// System.err.println("Error: " + msg);
// if (StackTrace) {
// Thread.dumpStack();
// }
// }
//
// public static void die(final Exception ex) {
// die(ex, -1);
// }
//
// public static void die(final Exception ex, final int exitStatus) {
// if (StackTrace) {
// ex.printStackTrace();
// }
// System.err.println("" + ex);
// System.exit(exitStatus);
// }
//
// public static void die(final String msg) {
// die(msg, -1);
// }
//
// public static void die(final String msg, int exitStatus) {
// System.err.println("Fatal error: " + msg);
// if (StackTrace) {
// Thread.dumpStack();
// }
// System.exit(exitStatus);
// }
//
// // run command and return {result, exit status}
// public static String[] execute(String[] cmd) {
// debug("Executing: " + Arrays.asList(cmd).toString());
//
// StringBuffer output = new StringBuffer();
// Integer status = null;
//
// InputStream in = null;
// try {
// Process child = Runtime.getRuntime().exec(cmd);
//
// BufferedReader stdInput = new BufferedReader(new InputStreamReader(child.getInputStream()));
//
// String s;
// while ((s = stdInput.readLine()) != null) {
// output.append(s).append('\n');
// }
//
// status = child.waitFor();
//
// debug("Exit status: " + status, 2);
// } catch (Exception ex) {
// error("Run command failed.\n" + ex);
// } finally {
// IOUtils.closeQuietly(in);
// }
//
// return new String[] { output.toString(), String.valueOf(status) };
// }
//
// public static boolean deleteBestEffort(File path, String whatIsIt) {
// return deleteBestEffort(path, whatIsIt, 3, false);
// }
//
// public static boolean deleteBestEffort(File path, String whatIsIt, int maxTries) {
// return deleteBestEffort(path, whatIsIt, maxTries, false);
// }
//
// public static boolean deleteBestEffort(File path, String whatIsIt, int maxTries, boolean quiet) {
// System.gc();
//
// int tries = 0;
// while (!FileUtils.deleteQuietly(path) && (tries < maxTries)) {
// System.gc();
// tries++;
//
// if (!quiet) {
// warn("Unable to delete " + whatIsIt + ": " + path + ". Trying again ...");
// }
//
// try {
// Thread.sleep(3000);
// } catch (InterruptedException ex) {
// }
// }
//
// return !path.exists();
// }
// }
// Path: src/main/java/org/cf/resequencer/sequence/ApkFile.java
import java.io.File;
import java.io.FileInputStream;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.List;
import java.util.logging.ConsoleHandler;
import java.util.logging.Handler;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import org.apache.commons.io.FileUtils;
import org.cf.resequencer.Console;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import brut.androlib.Androlib;
import brut.androlib.ApkDecoder;
import brut.androlib.ApkOptions;
* Path to Apk file.
*/
public void apkSetApk(final String apkPath) {
ApkPath = apkPath;
}
/**
* Sets path to Aapt binary.
*
* @param aaptPath
* Path to Aapt binary.
*/
public void apkSetAaptPath(final String aaptPath) {
mAaptPath = aaptPath;
}
/**
* Sets path to Zipalign binary.
*
* @param zaPath
*/
public void apkSetZipalignPath(final String zaPath) {
mZipalignPath = zaPath;
}
/**
* Load Apk info such as certificates, signatures, etc. Requires Aapt.
*/
public void apkLoadAppInfo() {
if (mAaptPath.isEmpty()) { | Console.warn("Aapt path is empty, unable to get app info."); |
CalebFenton/resequencer | src/main/java/org/cf/resequencer/patch/SmaliHinter.java | // Path: src/main/java/org/cf/resequencer/Console.java
// public class Console {
// private static final boolean StackTrace = false;
// public static int VerboseLevel;
// public static String LogFile = "console.log";
//
// public static void msgln() {
// System.out.println();
// }
//
// public static void msgln(final String msg) {
// System.out.println(msg);
// }
//
// public static void msg(final String msg) {
// System.out.print(msg);
// }
//
// public static void debug(final String msg) {
// if (VerboseLevel > 0) {
// System.out.println(msg);
// }
// }
//
// public static void debug(final String msg, final int verboseLevel) {
// if (verboseLevel <= VerboseLevel) {
// debug(msg);
// }
// }
//
// public static void warn(final String msg) {
// System.err.println("Warning: " + msg);
// if (StackTrace) {
// Thread.dumpStack();
// }
// }
//
// public static void error(final String msg) {
// System.err.println("Error: " + msg);
// if (StackTrace) {
// Thread.dumpStack();
// }
// }
//
// public static void die(final Exception ex) {
// die(ex, -1);
// }
//
// public static void die(final Exception ex, final int exitStatus) {
// if (StackTrace) {
// ex.printStackTrace();
// }
// System.err.println("" + ex);
// System.exit(exitStatus);
// }
//
// public static void die(final String msg) {
// die(msg, -1);
// }
//
// public static void die(final String msg, int exitStatus) {
// System.err.println("Fatal error: " + msg);
// if (StackTrace) {
// Thread.dumpStack();
// }
// System.exit(exitStatus);
// }
//
// // run command and return {result, exit status}
// public static String[] execute(String[] cmd) {
// debug("Executing: " + Arrays.asList(cmd).toString());
//
// StringBuffer output = new StringBuffer();
// Integer status = null;
//
// InputStream in = null;
// try {
// Process child = Runtime.getRuntime().exec(cmd);
//
// BufferedReader stdInput = new BufferedReader(new InputStreamReader(child.getInputStream()));
//
// String s;
// while ((s = stdInput.readLine()) != null) {
// output.append(s).append('\n');
// }
//
// status = child.waitFor();
//
// debug("Exit status: " + status, 2);
// } catch (Exception ex) {
// error("Run command failed.\n" + ex);
// } finally {
// IOUtils.closeQuietly(in);
// }
//
// return new String[] { output.toString(), String.valueOf(status) };
// }
//
// public static boolean deleteBestEffort(File path, String whatIsIt) {
// return deleteBestEffort(path, whatIsIt, 3, false);
// }
//
// public static boolean deleteBestEffort(File path, String whatIsIt, int maxTries) {
// return deleteBestEffort(path, whatIsIt, maxTries, false);
// }
//
// public static boolean deleteBestEffort(File path, String whatIsIt, int maxTries, boolean quiet) {
// System.gc();
//
// int tries = 0;
// while (!FileUtils.deleteQuietly(path) && (tries < maxTries)) {
// System.gc();
// tries++;
//
// if (!quiet) {
// warn("Unable to delete " + whatIsIt + ": " + path + ". Trying again ...");
// }
//
// try {
// Thread.sleep(3000);
// } catch (InterruptedException ex) {
// }
// }
//
// return !path.exists();
// }
// }
//
// Path: src/main/java/org/cf/resequencer/sequence/ResourceItem.java
// public class ResourceItem implements Comparable {
// public String Type;
// public String Name;
// public long ID;
// public String Value;
//
// ResourceItem(String type, String name, String id) {
// Type = type;
// Name = name;
// if (id.startsWith("0x")) {
// id = id.replaceFirst("0x", "");
// }
// ID = Long.parseLong(id, 16);
// }
//
// @Override
// public String toString() {
// return Type + " res(" + Name + " / " + ID + ") = " + (Value == null ? "null" : "'" + Value + "'");
// }
//
// public void setValue(String val) {
// val = val.replace("\n", "\\n");
// val = val.replace("\r", "\\r");
// Value = val;
// }
//
// public int compareTo(Object o) {
// return (int) (this.ID - ((ResourceItem) o).ID);
// }
// }
| import java.io.File;
import java.util.ArrayList;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.apache.commons.lang3.StringEscapeUtils;
import org.cf.resequencer.Console;
import org.cf.resequencer.sequence.ResourceItem;
import com.memetix.mst.detect.Detect;
import com.memetix.mst.language.Language;
import com.memetix.mst.translate.Translate; | package org.cf.resequencer.patch;
/**
*
* @author Caleb Fenton
*/
public class SmaliHinter {
public static long HintsAdded;
public static boolean ShouldTranslate;
private static int TranslateBatchSize = 25;
static private String[] LineArray;
public static void enableTranslations() {
// Microsoft Bing API key
// the developers use this key: 0B4B2CAA973775DBE72569A29C1A08DA55C88441
// lolololol but we wont use it because we're nice
String key = "";
// key = "0B4B2CAA973775DBE72569A29C1A08DA55C88441";
Translate.setKey(key);
Detect.setKey(key);
ShouldTranslate = true;
}
/**
*
* @param sf
*/
public static void generateHints(SmaliFile sf) {
generateHints(sf, null);
}
/**
*
* @param sf
* @param appRes
*/ | // Path: src/main/java/org/cf/resequencer/Console.java
// public class Console {
// private static final boolean StackTrace = false;
// public static int VerboseLevel;
// public static String LogFile = "console.log";
//
// public static void msgln() {
// System.out.println();
// }
//
// public static void msgln(final String msg) {
// System.out.println(msg);
// }
//
// public static void msg(final String msg) {
// System.out.print(msg);
// }
//
// public static void debug(final String msg) {
// if (VerboseLevel > 0) {
// System.out.println(msg);
// }
// }
//
// public static void debug(final String msg, final int verboseLevel) {
// if (verboseLevel <= VerboseLevel) {
// debug(msg);
// }
// }
//
// public static void warn(final String msg) {
// System.err.println("Warning: " + msg);
// if (StackTrace) {
// Thread.dumpStack();
// }
// }
//
// public static void error(final String msg) {
// System.err.println("Error: " + msg);
// if (StackTrace) {
// Thread.dumpStack();
// }
// }
//
// public static void die(final Exception ex) {
// die(ex, -1);
// }
//
// public static void die(final Exception ex, final int exitStatus) {
// if (StackTrace) {
// ex.printStackTrace();
// }
// System.err.println("" + ex);
// System.exit(exitStatus);
// }
//
// public static void die(final String msg) {
// die(msg, -1);
// }
//
// public static void die(final String msg, int exitStatus) {
// System.err.println("Fatal error: " + msg);
// if (StackTrace) {
// Thread.dumpStack();
// }
// System.exit(exitStatus);
// }
//
// // run command and return {result, exit status}
// public static String[] execute(String[] cmd) {
// debug("Executing: " + Arrays.asList(cmd).toString());
//
// StringBuffer output = new StringBuffer();
// Integer status = null;
//
// InputStream in = null;
// try {
// Process child = Runtime.getRuntime().exec(cmd);
//
// BufferedReader stdInput = new BufferedReader(new InputStreamReader(child.getInputStream()));
//
// String s;
// while ((s = stdInput.readLine()) != null) {
// output.append(s).append('\n');
// }
//
// status = child.waitFor();
//
// debug("Exit status: " + status, 2);
// } catch (Exception ex) {
// error("Run command failed.\n" + ex);
// } finally {
// IOUtils.closeQuietly(in);
// }
//
// return new String[] { output.toString(), String.valueOf(status) };
// }
//
// public static boolean deleteBestEffort(File path, String whatIsIt) {
// return deleteBestEffort(path, whatIsIt, 3, false);
// }
//
// public static boolean deleteBestEffort(File path, String whatIsIt, int maxTries) {
// return deleteBestEffort(path, whatIsIt, maxTries, false);
// }
//
// public static boolean deleteBestEffort(File path, String whatIsIt, int maxTries, boolean quiet) {
// System.gc();
//
// int tries = 0;
// while (!FileUtils.deleteQuietly(path) && (tries < maxTries)) {
// System.gc();
// tries++;
//
// if (!quiet) {
// warn("Unable to delete " + whatIsIt + ": " + path + ". Trying again ...");
// }
//
// try {
// Thread.sleep(3000);
// } catch (InterruptedException ex) {
// }
// }
//
// return !path.exists();
// }
// }
//
// Path: src/main/java/org/cf/resequencer/sequence/ResourceItem.java
// public class ResourceItem implements Comparable {
// public String Type;
// public String Name;
// public long ID;
// public String Value;
//
// ResourceItem(String type, String name, String id) {
// Type = type;
// Name = name;
// if (id.startsWith("0x")) {
// id = id.replaceFirst("0x", "");
// }
// ID = Long.parseLong(id, 16);
// }
//
// @Override
// public String toString() {
// return Type + " res(" + Name + " / " + ID + ") = " + (Value == null ? "null" : "'" + Value + "'");
// }
//
// public void setValue(String val) {
// val = val.replace("\n", "\\n");
// val = val.replace("\r", "\\r");
// Value = val;
// }
//
// public int compareTo(Object o) {
// return (int) (this.ID - ((ResourceItem) o).ID);
// }
// }
// Path: src/main/java/org/cf/resequencer/patch/SmaliHinter.java
import java.io.File;
import java.util.ArrayList;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.apache.commons.lang3.StringEscapeUtils;
import org.cf.resequencer.Console;
import org.cf.resequencer.sequence.ResourceItem;
import com.memetix.mst.detect.Detect;
import com.memetix.mst.language.Language;
import com.memetix.mst.translate.Translate;
package org.cf.resequencer.patch;
/**
*
* @author Caleb Fenton
*/
public class SmaliHinter {
public static long HintsAdded;
public static boolean ShouldTranslate;
private static int TranslateBatchSize = 25;
static private String[] LineArray;
public static void enableTranslations() {
// Microsoft Bing API key
// the developers use this key: 0B4B2CAA973775DBE72569A29C1A08DA55C88441
// lolololol but we wont use it because we're nice
String key = "";
// key = "0B4B2CAA973775DBE72569A29C1A08DA55C88441";
Translate.setKey(key);
Detect.setKey(key);
ShouldTranslate = true;
}
/**
*
* @param sf
*/
public static void generateHints(SmaliFile sf) {
generateHints(sf, null);
}
/**
*
* @param sf
* @param appRes
*/ | public static void generateHints(SmaliFile sf, List<ResourceItem> appRes) { |
CalebFenton/resequencer | src/main/java/org/cf/resequencer/patch/Region.java | // Path: src/main/java/org/cf/resequencer/Console.java
// public class Console {
// private static final boolean StackTrace = false;
// public static int VerboseLevel;
// public static String LogFile = "console.log";
//
// public static void msgln() {
// System.out.println();
// }
//
// public static void msgln(final String msg) {
// System.out.println(msg);
// }
//
// public static void msg(final String msg) {
// System.out.print(msg);
// }
//
// public static void debug(final String msg) {
// if (VerboseLevel > 0) {
// System.out.println(msg);
// }
// }
//
// public static void debug(final String msg, final int verboseLevel) {
// if (verboseLevel <= VerboseLevel) {
// debug(msg);
// }
// }
//
// public static void warn(final String msg) {
// System.err.println("Warning: " + msg);
// if (StackTrace) {
// Thread.dumpStack();
// }
// }
//
// public static void error(final String msg) {
// System.err.println("Error: " + msg);
// if (StackTrace) {
// Thread.dumpStack();
// }
// }
//
// public static void die(final Exception ex) {
// die(ex, -1);
// }
//
// public static void die(final Exception ex, final int exitStatus) {
// if (StackTrace) {
// ex.printStackTrace();
// }
// System.err.println("" + ex);
// System.exit(exitStatus);
// }
//
// public static void die(final String msg) {
// die(msg, -1);
// }
//
// public static void die(final String msg, int exitStatus) {
// System.err.println("Fatal error: " + msg);
// if (StackTrace) {
// Thread.dumpStack();
// }
// System.exit(exitStatus);
// }
//
// // run command and return {result, exit status}
// public static String[] execute(String[] cmd) {
// debug("Executing: " + Arrays.asList(cmd).toString());
//
// StringBuffer output = new StringBuffer();
// Integer status = null;
//
// InputStream in = null;
// try {
// Process child = Runtime.getRuntime().exec(cmd);
//
// BufferedReader stdInput = new BufferedReader(new InputStreamReader(child.getInputStream()));
//
// String s;
// while ((s = stdInput.readLine()) != null) {
// output.append(s).append('\n');
// }
//
// status = child.waitFor();
//
// debug("Exit status: " + status, 2);
// } catch (Exception ex) {
// error("Run command failed.\n" + ex);
// } finally {
// IOUtils.closeQuietly(in);
// }
//
// return new String[] { output.toString(), String.valueOf(status) };
// }
//
// public static boolean deleteBestEffort(File path, String whatIsIt) {
// return deleteBestEffort(path, whatIsIt, 3, false);
// }
//
// public static boolean deleteBestEffort(File path, String whatIsIt, int maxTries) {
// return deleteBestEffort(path, whatIsIt, maxTries, false);
// }
//
// public static boolean deleteBestEffort(File path, String whatIsIt, int maxTries, boolean quiet) {
// System.gc();
//
// int tries = 0;
// while (!FileUtils.deleteQuietly(path) && (tries < maxTries)) {
// System.gc();
// tries++;
//
// if (!quiet) {
// warn("Unable to delete " + whatIsIt + ": " + path + ". Trying again ...");
// }
//
// try {
// Thread.sleep(3000);
// } catch (InterruptedException ex) {
// }
// }
//
// return !path.exists();
// }
// }
| import java.util.ArrayList;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.cf.resequencer.Console; |
return rfClone;
}
@Override
public String toString() {
return RegionName;
}
// If region start and end are both blank, assume entire file as range
// setup this region's offsets with the first region it matches to
// it will try to match every possible region first
// we don't store multiple offsets here because at a higher level
// we just clone the region instance for every matched region
public boolean match(SmaliFile smaliFile, int startSearch) {
int start = startSearch;
boolean foundMatch = false;
// findRegion() will setup Start and EndOffsets
while (findRegion(smaliFile, start)) {
// System.out.println(smaliFile + " " + RegionName + " " + start + " " + EndOffset + " " +
// smaliFile.FileLines.length());
foundMatch = true;
start = EndOffset + 1;
for (Operation op : OperationList) {
if (op.getType() == Operation.OpTypes.MATCH) {
evaluateOperationAttributes(op);
if (!performMatchOperation(op)) { | // Path: src/main/java/org/cf/resequencer/Console.java
// public class Console {
// private static final boolean StackTrace = false;
// public static int VerboseLevel;
// public static String LogFile = "console.log";
//
// public static void msgln() {
// System.out.println();
// }
//
// public static void msgln(final String msg) {
// System.out.println(msg);
// }
//
// public static void msg(final String msg) {
// System.out.print(msg);
// }
//
// public static void debug(final String msg) {
// if (VerboseLevel > 0) {
// System.out.println(msg);
// }
// }
//
// public static void debug(final String msg, final int verboseLevel) {
// if (verboseLevel <= VerboseLevel) {
// debug(msg);
// }
// }
//
// public static void warn(final String msg) {
// System.err.println("Warning: " + msg);
// if (StackTrace) {
// Thread.dumpStack();
// }
// }
//
// public static void error(final String msg) {
// System.err.println("Error: " + msg);
// if (StackTrace) {
// Thread.dumpStack();
// }
// }
//
// public static void die(final Exception ex) {
// die(ex, -1);
// }
//
// public static void die(final Exception ex, final int exitStatus) {
// if (StackTrace) {
// ex.printStackTrace();
// }
// System.err.println("" + ex);
// System.exit(exitStatus);
// }
//
// public static void die(final String msg) {
// die(msg, -1);
// }
//
// public static void die(final String msg, int exitStatus) {
// System.err.println("Fatal error: " + msg);
// if (StackTrace) {
// Thread.dumpStack();
// }
// System.exit(exitStatus);
// }
//
// // run command and return {result, exit status}
// public static String[] execute(String[] cmd) {
// debug("Executing: " + Arrays.asList(cmd).toString());
//
// StringBuffer output = new StringBuffer();
// Integer status = null;
//
// InputStream in = null;
// try {
// Process child = Runtime.getRuntime().exec(cmd);
//
// BufferedReader stdInput = new BufferedReader(new InputStreamReader(child.getInputStream()));
//
// String s;
// while ((s = stdInput.readLine()) != null) {
// output.append(s).append('\n');
// }
//
// status = child.waitFor();
//
// debug("Exit status: " + status, 2);
// } catch (Exception ex) {
// error("Run command failed.\n" + ex);
// } finally {
// IOUtils.closeQuietly(in);
// }
//
// return new String[] { output.toString(), String.valueOf(status) };
// }
//
// public static boolean deleteBestEffort(File path, String whatIsIt) {
// return deleteBestEffort(path, whatIsIt, 3, false);
// }
//
// public static boolean deleteBestEffort(File path, String whatIsIt, int maxTries) {
// return deleteBestEffort(path, whatIsIt, maxTries, false);
// }
//
// public static boolean deleteBestEffort(File path, String whatIsIt, int maxTries, boolean quiet) {
// System.gc();
//
// int tries = 0;
// while (!FileUtils.deleteQuietly(path) && (tries < maxTries)) {
// System.gc();
// tries++;
//
// if (!quiet) {
// warn("Unable to delete " + whatIsIt + ": " + path + ". Trying again ...");
// }
//
// try {
// Thread.sleep(3000);
// } catch (InterruptedException ex) {
// }
// }
//
// return !path.exists();
// }
// }
// Path: src/main/java/org/cf/resequencer/patch/Region.java
import java.util.ArrayList;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.cf.resequencer.Console;
return rfClone;
}
@Override
public String toString() {
return RegionName;
}
// If region start and end are both blank, assume entire file as range
// setup this region's offsets with the first region it matches to
// it will try to match every possible region first
// we don't store multiple offsets here because at a higher level
// we just clone the region instance for every matched region
public boolean match(SmaliFile smaliFile, int startSearch) {
int start = startSearch;
boolean foundMatch = false;
// findRegion() will setup Start and EndOffsets
while (findRegion(smaliFile, start)) {
// System.out.println(smaliFile + " " + RegionName + " " + start + " " + EndOffset + " " +
// smaliFile.FileLines.length());
foundMatch = true;
start = EndOffset + 1;
for (Operation op : OperationList) {
if (op.getType() == Operation.OpTypes.MATCH) {
evaluateOperationAttributes(op);
if (!performMatchOperation(op)) { | Console.debug(" " + op + " did not match in " + smaliFile.FileName, 2); |
CalebFenton/resequencer | src/main/java/org/cf/resequencer/patch/SmaliMatcher.java | // Path: src/main/java/org/cf/resequencer/Console.java
// public class Console {
// private static final boolean StackTrace = false;
// public static int VerboseLevel;
// public static String LogFile = "console.log";
//
// public static void msgln() {
// System.out.println();
// }
//
// public static void msgln(final String msg) {
// System.out.println(msg);
// }
//
// public static void msg(final String msg) {
// System.out.print(msg);
// }
//
// public static void debug(final String msg) {
// if (VerboseLevel > 0) {
// System.out.println(msg);
// }
// }
//
// public static void debug(final String msg, final int verboseLevel) {
// if (verboseLevel <= VerboseLevel) {
// debug(msg);
// }
// }
//
// public static void warn(final String msg) {
// System.err.println("Warning: " + msg);
// if (StackTrace) {
// Thread.dumpStack();
// }
// }
//
// public static void error(final String msg) {
// System.err.println("Error: " + msg);
// if (StackTrace) {
// Thread.dumpStack();
// }
// }
//
// public static void die(final Exception ex) {
// die(ex, -1);
// }
//
// public static void die(final Exception ex, final int exitStatus) {
// if (StackTrace) {
// ex.printStackTrace();
// }
// System.err.println("" + ex);
// System.exit(exitStatus);
// }
//
// public static void die(final String msg) {
// die(msg, -1);
// }
//
// public static void die(final String msg, int exitStatus) {
// System.err.println("Fatal error: " + msg);
// if (StackTrace) {
// Thread.dumpStack();
// }
// System.exit(exitStatus);
// }
//
// // run command and return {result, exit status}
// public static String[] execute(String[] cmd) {
// debug("Executing: " + Arrays.asList(cmd).toString());
//
// StringBuffer output = new StringBuffer();
// Integer status = null;
//
// InputStream in = null;
// try {
// Process child = Runtime.getRuntime().exec(cmd);
//
// BufferedReader stdInput = new BufferedReader(new InputStreamReader(child.getInputStream()));
//
// String s;
// while ((s = stdInput.readLine()) != null) {
// output.append(s).append('\n');
// }
//
// status = child.waitFor();
//
// debug("Exit status: " + status, 2);
// } catch (Exception ex) {
// error("Run command failed.\n" + ex);
// } finally {
// IOUtils.closeQuietly(in);
// }
//
// return new String[] { output.toString(), String.valueOf(status) };
// }
//
// public static boolean deleteBestEffort(File path, String whatIsIt) {
// return deleteBestEffort(path, whatIsIt, 3, false);
// }
//
// public static boolean deleteBestEffort(File path, String whatIsIt, int maxTries) {
// return deleteBestEffort(path, whatIsIt, maxTries, false);
// }
//
// public static boolean deleteBestEffort(File path, String whatIsIt, int maxTries, boolean quiet) {
// System.gc();
//
// int tries = 0;
// while (!FileUtils.deleteQuietly(path) && (tries < maxTries)) {
// System.gc();
// tries++;
//
// if (!quiet) {
// warn("Unable to delete " + whatIsIt + ": " + path + ". Trying again ...");
// }
//
// try {
// Thread.sleep(3000);
// } catch (InterruptedException ex) {
// }
// }
//
// return !path.exists();
// }
// }
| import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import org.cf.resequencer.Console; | package org.cf.resequencer.patch;
/**
* Handles matching fingerprints with smali files.
*
* @author Caleb Fenton
*/
public class SmaliMatcher {
private final SmaliFile[] SmaliFileList;
private FingerprintReader myFPReader;
private ArrayList<SmaliFile> SmaliFileMatches;
private final int ProgressIncrement = 100;
/**
*
* @param smaliFiles
* array of paths to smali files
* @param reader
* instance of FingerprintReader
*/
public SmaliMatcher(SmaliFile[] smaliFiles, FingerprintReader reader) {
SmaliFileList = smaliFiles;
SmaliFileMatches = new ArrayList<SmaliFile>();
myFPReader = reader;
removeDisabledFingerprints();
}
/**
* Performs region and match operations.
*
* @return SmaliFiles with matched regions stored inside.
*/
public List<SmaliFile> performMatching() {
System.out.print(" Matching " + SmaliFileList.length + " files against " + myFPReader.Fingerprints.size()
+ " fingerprints ");
int count = 1;
for (SmaliFile sf : SmaliFileList) {
for (String fpName : myFPReader.Fingerprints.keySet()) {
Fingerprint fp = myFPReader.Fingerprints.get(fpName);
if (fp.FindOnce && wasFingerprintFound(fp.toString())) { | // Path: src/main/java/org/cf/resequencer/Console.java
// public class Console {
// private static final boolean StackTrace = false;
// public static int VerboseLevel;
// public static String LogFile = "console.log";
//
// public static void msgln() {
// System.out.println();
// }
//
// public static void msgln(final String msg) {
// System.out.println(msg);
// }
//
// public static void msg(final String msg) {
// System.out.print(msg);
// }
//
// public static void debug(final String msg) {
// if (VerboseLevel > 0) {
// System.out.println(msg);
// }
// }
//
// public static void debug(final String msg, final int verboseLevel) {
// if (verboseLevel <= VerboseLevel) {
// debug(msg);
// }
// }
//
// public static void warn(final String msg) {
// System.err.println("Warning: " + msg);
// if (StackTrace) {
// Thread.dumpStack();
// }
// }
//
// public static void error(final String msg) {
// System.err.println("Error: " + msg);
// if (StackTrace) {
// Thread.dumpStack();
// }
// }
//
// public static void die(final Exception ex) {
// die(ex, -1);
// }
//
// public static void die(final Exception ex, final int exitStatus) {
// if (StackTrace) {
// ex.printStackTrace();
// }
// System.err.println("" + ex);
// System.exit(exitStatus);
// }
//
// public static void die(final String msg) {
// die(msg, -1);
// }
//
// public static void die(final String msg, int exitStatus) {
// System.err.println("Fatal error: " + msg);
// if (StackTrace) {
// Thread.dumpStack();
// }
// System.exit(exitStatus);
// }
//
// // run command and return {result, exit status}
// public static String[] execute(String[] cmd) {
// debug("Executing: " + Arrays.asList(cmd).toString());
//
// StringBuffer output = new StringBuffer();
// Integer status = null;
//
// InputStream in = null;
// try {
// Process child = Runtime.getRuntime().exec(cmd);
//
// BufferedReader stdInput = new BufferedReader(new InputStreamReader(child.getInputStream()));
//
// String s;
// while ((s = stdInput.readLine()) != null) {
// output.append(s).append('\n');
// }
//
// status = child.waitFor();
//
// debug("Exit status: " + status, 2);
// } catch (Exception ex) {
// error("Run command failed.\n" + ex);
// } finally {
// IOUtils.closeQuietly(in);
// }
//
// return new String[] { output.toString(), String.valueOf(status) };
// }
//
// public static boolean deleteBestEffort(File path, String whatIsIt) {
// return deleteBestEffort(path, whatIsIt, 3, false);
// }
//
// public static boolean deleteBestEffort(File path, String whatIsIt, int maxTries) {
// return deleteBestEffort(path, whatIsIt, maxTries, false);
// }
//
// public static boolean deleteBestEffort(File path, String whatIsIt, int maxTries, boolean quiet) {
// System.gc();
//
// int tries = 0;
// while (!FileUtils.deleteQuietly(path) && (tries < maxTries)) {
// System.gc();
// tries++;
//
// if (!quiet) {
// warn("Unable to delete " + whatIsIt + ": " + path + ". Trying again ...");
// }
//
// try {
// Thread.sleep(3000);
// } catch (InterruptedException ex) {
// }
// }
//
// return !path.exists();
// }
// }
// Path: src/main/java/org/cf/resequencer/patch/SmaliMatcher.java
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import org.cf.resequencer.Console;
package org.cf.resequencer.patch;
/**
* Handles matching fingerprints with smali files.
*
* @author Caleb Fenton
*/
public class SmaliMatcher {
private final SmaliFile[] SmaliFileList;
private FingerprintReader myFPReader;
private ArrayList<SmaliFile> SmaliFileMatches;
private final int ProgressIncrement = 100;
/**
*
* @param smaliFiles
* array of paths to smali files
* @param reader
* instance of FingerprintReader
*/
public SmaliMatcher(SmaliFile[] smaliFiles, FingerprintReader reader) {
SmaliFileList = smaliFiles;
SmaliFileMatches = new ArrayList<SmaliFile>();
myFPReader = reader;
removeDisabledFingerprints();
}
/**
* Performs region and match operations.
*
* @return SmaliFiles with matched regions stored inside.
*/
public List<SmaliFile> performMatching() {
System.out.print(" Matching " + SmaliFileList.length + " files against " + myFPReader.Fingerprints.size()
+ " fingerprints ");
int count = 1;
for (SmaliFile sf : SmaliFileList) {
for (String fpName : myFPReader.Fingerprints.keySet()) {
Fingerprint fp = myFPReader.Fingerprints.get(fpName);
if (fp.FindOnce && wasFingerprintFound(fp.toString())) { | Console.debug(" Skipping " + fp + " because it's already been found.", 3); |
CalebFenton/resequencer | src/main/java/org/cf/resequencer/sequence/DexFile.java | // Path: src/main/java/org/cf/resequencer/Console.java
// public class Console {
// private static final boolean StackTrace = false;
// public static int VerboseLevel;
// public static String LogFile = "console.log";
//
// public static void msgln() {
// System.out.println();
// }
//
// public static void msgln(final String msg) {
// System.out.println(msg);
// }
//
// public static void msg(final String msg) {
// System.out.print(msg);
// }
//
// public static void debug(final String msg) {
// if (VerboseLevel > 0) {
// System.out.println(msg);
// }
// }
//
// public static void debug(final String msg, final int verboseLevel) {
// if (verboseLevel <= VerboseLevel) {
// debug(msg);
// }
// }
//
// public static void warn(final String msg) {
// System.err.println("Warning: " + msg);
// if (StackTrace) {
// Thread.dumpStack();
// }
// }
//
// public static void error(final String msg) {
// System.err.println("Error: " + msg);
// if (StackTrace) {
// Thread.dumpStack();
// }
// }
//
// public static void die(final Exception ex) {
// die(ex, -1);
// }
//
// public static void die(final Exception ex, final int exitStatus) {
// if (StackTrace) {
// ex.printStackTrace();
// }
// System.err.println("" + ex);
// System.exit(exitStatus);
// }
//
// public static void die(final String msg) {
// die(msg, -1);
// }
//
// public static void die(final String msg, int exitStatus) {
// System.err.println("Fatal error: " + msg);
// if (StackTrace) {
// Thread.dumpStack();
// }
// System.exit(exitStatus);
// }
//
// // run command and return {result, exit status}
// public static String[] execute(String[] cmd) {
// debug("Executing: " + Arrays.asList(cmd).toString());
//
// StringBuffer output = new StringBuffer();
// Integer status = null;
//
// InputStream in = null;
// try {
// Process child = Runtime.getRuntime().exec(cmd);
//
// BufferedReader stdInput = new BufferedReader(new InputStreamReader(child.getInputStream()));
//
// String s;
// while ((s = stdInput.readLine()) != null) {
// output.append(s).append('\n');
// }
//
// status = child.waitFor();
//
// debug("Exit status: " + status, 2);
// } catch (Exception ex) {
// error("Run command failed.\n" + ex);
// } finally {
// IOUtils.closeQuietly(in);
// }
//
// return new String[] { output.toString(), String.valueOf(status) };
// }
//
// public static boolean deleteBestEffort(File path, String whatIsIt) {
// return deleteBestEffort(path, whatIsIt, 3, false);
// }
//
// public static boolean deleteBestEffort(File path, String whatIsIt, int maxTries) {
// return deleteBestEffort(path, whatIsIt, maxTries, false);
// }
//
// public static boolean deleteBestEffort(File path, String whatIsIt, int maxTries, boolean quiet) {
// System.gc();
//
// int tries = 0;
// while (!FileUtils.deleteQuietly(path) && (tries < maxTries)) {
// System.gc();
// tries++;
//
// if (!quiet) {
// warn("Unable to delete " + whatIsIt + ": " + path + ". Trying again ...");
// }
//
// try {
// Thread.sleep(3000);
// } catch (InterruptedException ex) {
// }
// }
//
// return !path.exists();
// }
// }
| import java.io.File;
import java.io.IOException;
import java.security.DigestException;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.Arrays;
import java.util.Random;
import java.util.zip.Adler32;
import org.apache.commons.io.FileUtils;
import org.cf.resequencer.Console; | package org.cf.resequencer.sequence;
/**
*
* @author Caleb Fenton
*/
public class DexFile {
private static final int OFF_LINK_SIZE = 44;
private static final int OFF_LINK_OFF = 48;
private static final int INT_SIZE = 4;
private static final byte[] InvalidRef = new byte[] { 0x4e, 0x01, 0x01, 0x01, 0x00, 0x00 // aput-bool p0, p0, p0;
// nop
};
private byte[] DexBytes;
protected File DexFile;
DexFile(File dexFile) throws IOException {
DexFile = dexFile;
DexBytes = FileUtils.readFileToByteArray(dexFile);
}
/*
* Do whatever we can to the dex file to prevent decompilers from working.
*/
public void dexLock() {
/*
* byte[] header = new byte[0x70]; System.arraycopy(DexBytes, 0, header, 0, 0x70);
* System.out.println(StringUtils.toHexString(header)); for ( int i = 0; i < header.length; i++ ) {
* System.out.print(header[i] + " "); }
*
* for ( int i = 0; i < 0x70; i++ ) { System.out.print(DexBytes[i] +" "); } System.exit(0);
*/
Random rng = new Random();
byte[] val = new byte[4];
// 40-43 = endian tag (ignore for now)
System.arraycopy(DexBytes, OFF_LINK_SIZE, val, 0, INT_SIZE); | // Path: src/main/java/org/cf/resequencer/Console.java
// public class Console {
// private static final boolean StackTrace = false;
// public static int VerboseLevel;
// public static String LogFile = "console.log";
//
// public static void msgln() {
// System.out.println();
// }
//
// public static void msgln(final String msg) {
// System.out.println(msg);
// }
//
// public static void msg(final String msg) {
// System.out.print(msg);
// }
//
// public static void debug(final String msg) {
// if (VerboseLevel > 0) {
// System.out.println(msg);
// }
// }
//
// public static void debug(final String msg, final int verboseLevel) {
// if (verboseLevel <= VerboseLevel) {
// debug(msg);
// }
// }
//
// public static void warn(final String msg) {
// System.err.println("Warning: " + msg);
// if (StackTrace) {
// Thread.dumpStack();
// }
// }
//
// public static void error(final String msg) {
// System.err.println("Error: " + msg);
// if (StackTrace) {
// Thread.dumpStack();
// }
// }
//
// public static void die(final Exception ex) {
// die(ex, -1);
// }
//
// public static void die(final Exception ex, final int exitStatus) {
// if (StackTrace) {
// ex.printStackTrace();
// }
// System.err.println("" + ex);
// System.exit(exitStatus);
// }
//
// public static void die(final String msg) {
// die(msg, -1);
// }
//
// public static void die(final String msg, int exitStatus) {
// System.err.println("Fatal error: " + msg);
// if (StackTrace) {
// Thread.dumpStack();
// }
// System.exit(exitStatus);
// }
//
// // run command and return {result, exit status}
// public static String[] execute(String[] cmd) {
// debug("Executing: " + Arrays.asList(cmd).toString());
//
// StringBuffer output = new StringBuffer();
// Integer status = null;
//
// InputStream in = null;
// try {
// Process child = Runtime.getRuntime().exec(cmd);
//
// BufferedReader stdInput = new BufferedReader(new InputStreamReader(child.getInputStream()));
//
// String s;
// while ((s = stdInput.readLine()) != null) {
// output.append(s).append('\n');
// }
//
// status = child.waitFor();
//
// debug("Exit status: " + status, 2);
// } catch (Exception ex) {
// error("Run command failed.\n" + ex);
// } finally {
// IOUtils.closeQuietly(in);
// }
//
// return new String[] { output.toString(), String.valueOf(status) };
// }
//
// public static boolean deleteBestEffort(File path, String whatIsIt) {
// return deleteBestEffort(path, whatIsIt, 3, false);
// }
//
// public static boolean deleteBestEffort(File path, String whatIsIt, int maxTries) {
// return deleteBestEffort(path, whatIsIt, maxTries, false);
// }
//
// public static boolean deleteBestEffort(File path, String whatIsIt, int maxTries, boolean quiet) {
// System.gc();
//
// int tries = 0;
// while (!FileUtils.deleteQuietly(path) && (tries < maxTries)) {
// System.gc();
// tries++;
//
// if (!quiet) {
// warn("Unable to delete " + whatIsIt + ": " + path + ". Trying again ...");
// }
//
// try {
// Thread.sleep(3000);
// } catch (InterruptedException ex) {
// }
// }
//
// return !path.exists();
// }
// }
// Path: src/main/java/org/cf/resequencer/sequence/DexFile.java
import java.io.File;
import java.io.IOException;
import java.security.DigestException;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.Arrays;
import java.util.Random;
import java.util.zip.Adler32;
import org.apache.commons.io.FileUtils;
import org.cf.resequencer.Console;
package org.cf.resequencer.sequence;
/**
*
* @author Caleb Fenton
*/
public class DexFile {
private static final int OFF_LINK_SIZE = 44;
private static final int OFF_LINK_OFF = 48;
private static final int INT_SIZE = 4;
private static final byte[] InvalidRef = new byte[] { 0x4e, 0x01, 0x01, 0x01, 0x00, 0x00 // aput-bool p0, p0, p0;
// nop
};
private byte[] DexBytes;
protected File DexFile;
DexFile(File dexFile) throws IOException {
DexFile = dexFile;
DexBytes = FileUtils.readFileToByteArray(dexFile);
}
/*
* Do whatever we can to the dex file to prevent decompilers from working.
*/
public void dexLock() {
/*
* byte[] header = new byte[0x70]; System.arraycopy(DexBytes, 0, header, 0, 0x70);
* System.out.println(StringUtils.toHexString(header)); for ( int i = 0; i < header.length; i++ ) {
* System.out.print(header[i] + " "); }
*
* for ( int i = 0; i < 0x70; i++ ) { System.out.print(DexBytes[i] +" "); } System.exit(0);
*/
Random rng = new Random();
byte[] val = new byte[4];
// 40-43 = endian tag (ignore for now)
System.arraycopy(DexBytes, OFF_LINK_SIZE, val, 0, INT_SIZE); | Console.debug("DexLock - link size: " + StringUtils.toHexString(val)); |
CalebFenton/resequencer | src/main/java/org/cf/resequencer/sequence/CryptoUtils.java | // Path: src/main/java/org/cf/resequencer/Console.java
// public class Console {
// private static final boolean StackTrace = false;
// public static int VerboseLevel;
// public static String LogFile = "console.log";
//
// public static void msgln() {
// System.out.println();
// }
//
// public static void msgln(final String msg) {
// System.out.println(msg);
// }
//
// public static void msg(final String msg) {
// System.out.print(msg);
// }
//
// public static void debug(final String msg) {
// if (VerboseLevel > 0) {
// System.out.println(msg);
// }
// }
//
// public static void debug(final String msg, final int verboseLevel) {
// if (verboseLevel <= VerboseLevel) {
// debug(msg);
// }
// }
//
// public static void warn(final String msg) {
// System.err.println("Warning: " + msg);
// if (StackTrace) {
// Thread.dumpStack();
// }
// }
//
// public static void error(final String msg) {
// System.err.println("Error: " + msg);
// if (StackTrace) {
// Thread.dumpStack();
// }
// }
//
// public static void die(final Exception ex) {
// die(ex, -1);
// }
//
// public static void die(final Exception ex, final int exitStatus) {
// if (StackTrace) {
// ex.printStackTrace();
// }
// System.err.println("" + ex);
// System.exit(exitStatus);
// }
//
// public static void die(final String msg) {
// die(msg, -1);
// }
//
// public static void die(final String msg, int exitStatus) {
// System.err.println("Fatal error: " + msg);
// if (StackTrace) {
// Thread.dumpStack();
// }
// System.exit(exitStatus);
// }
//
// // run command and return {result, exit status}
// public static String[] execute(String[] cmd) {
// debug("Executing: " + Arrays.asList(cmd).toString());
//
// StringBuffer output = new StringBuffer();
// Integer status = null;
//
// InputStream in = null;
// try {
// Process child = Runtime.getRuntime().exec(cmd);
//
// BufferedReader stdInput = new BufferedReader(new InputStreamReader(child.getInputStream()));
//
// String s;
// while ((s = stdInput.readLine()) != null) {
// output.append(s).append('\n');
// }
//
// status = child.waitFor();
//
// debug("Exit status: " + status, 2);
// } catch (Exception ex) {
// error("Run command failed.\n" + ex);
// } finally {
// IOUtils.closeQuietly(in);
// }
//
// return new String[] { output.toString(), String.valueOf(status) };
// }
//
// public static boolean deleteBestEffort(File path, String whatIsIt) {
// return deleteBestEffort(path, whatIsIt, 3, false);
// }
//
// public static boolean deleteBestEffort(File path, String whatIsIt, int maxTries) {
// return deleteBestEffort(path, whatIsIt, maxTries, false);
// }
//
// public static boolean deleteBestEffort(File path, String whatIsIt, int maxTries, boolean quiet) {
// System.gc();
//
// int tries = 0;
// while (!FileUtils.deleteQuietly(path) && (tries < maxTries)) {
// System.gc();
// tries++;
//
// if (!quiet) {
// warn("Unable to delete " + whatIsIt + ": " + path + ". Trying again ...");
// }
//
// try {
// Thread.sleep(3000);
// } catch (InterruptedException ex) {
// }
// }
//
// return !path.exists();
// }
// }
| import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.math.BigInteger;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.zip.Adler32;
import java.util.zip.CRC32;
import java.util.zip.CheckedInputStream;
import org.cf.resequencer.Console; | }
public static long getAdler32Chksum(String path) throws FileNotFoundException, IOException {
byte[] bytes = new byte[0xFFFF];
FileInputStream fis = new FileInputStream(path);
Adler32 chkAdler32 = new Adler32();
CheckedInputStream cis = new CheckedInputStream(fis, chkAdler32);
while (cis.read(bytes) >= 0) {
;
}
fis.close();
return chkAdler32.getValue();
}
public static String getMD5Sum(String path) throws FileNotFoundException, NoSuchAlgorithmException {
MessageDigest digest = MessageDigest.getInstance("MD5");
InputStream is = new FileInputStream(new File(path));
byte[] buffer = new byte[0xFFFF];
int read = 0;
try {
while ((read = is.read(buffer)) > 0) {
digest.update(buffer, 0, read);
}
byte[] md5sum = digest.digest();
BigInteger bigInt = new BigInteger(1, md5sum);
return bigInt.toString(16);
} catch (IOException e) { | // Path: src/main/java/org/cf/resequencer/Console.java
// public class Console {
// private static final boolean StackTrace = false;
// public static int VerboseLevel;
// public static String LogFile = "console.log";
//
// public static void msgln() {
// System.out.println();
// }
//
// public static void msgln(final String msg) {
// System.out.println(msg);
// }
//
// public static void msg(final String msg) {
// System.out.print(msg);
// }
//
// public static void debug(final String msg) {
// if (VerboseLevel > 0) {
// System.out.println(msg);
// }
// }
//
// public static void debug(final String msg, final int verboseLevel) {
// if (verboseLevel <= VerboseLevel) {
// debug(msg);
// }
// }
//
// public static void warn(final String msg) {
// System.err.println("Warning: " + msg);
// if (StackTrace) {
// Thread.dumpStack();
// }
// }
//
// public static void error(final String msg) {
// System.err.println("Error: " + msg);
// if (StackTrace) {
// Thread.dumpStack();
// }
// }
//
// public static void die(final Exception ex) {
// die(ex, -1);
// }
//
// public static void die(final Exception ex, final int exitStatus) {
// if (StackTrace) {
// ex.printStackTrace();
// }
// System.err.println("" + ex);
// System.exit(exitStatus);
// }
//
// public static void die(final String msg) {
// die(msg, -1);
// }
//
// public static void die(final String msg, int exitStatus) {
// System.err.println("Fatal error: " + msg);
// if (StackTrace) {
// Thread.dumpStack();
// }
// System.exit(exitStatus);
// }
//
// // run command and return {result, exit status}
// public static String[] execute(String[] cmd) {
// debug("Executing: " + Arrays.asList(cmd).toString());
//
// StringBuffer output = new StringBuffer();
// Integer status = null;
//
// InputStream in = null;
// try {
// Process child = Runtime.getRuntime().exec(cmd);
//
// BufferedReader stdInput = new BufferedReader(new InputStreamReader(child.getInputStream()));
//
// String s;
// while ((s = stdInput.readLine()) != null) {
// output.append(s).append('\n');
// }
//
// status = child.waitFor();
//
// debug("Exit status: " + status, 2);
// } catch (Exception ex) {
// error("Run command failed.\n" + ex);
// } finally {
// IOUtils.closeQuietly(in);
// }
//
// return new String[] { output.toString(), String.valueOf(status) };
// }
//
// public static boolean deleteBestEffort(File path, String whatIsIt) {
// return deleteBestEffort(path, whatIsIt, 3, false);
// }
//
// public static boolean deleteBestEffort(File path, String whatIsIt, int maxTries) {
// return deleteBestEffort(path, whatIsIt, maxTries, false);
// }
//
// public static boolean deleteBestEffort(File path, String whatIsIt, int maxTries, boolean quiet) {
// System.gc();
//
// int tries = 0;
// while (!FileUtils.deleteQuietly(path) && (tries < maxTries)) {
// System.gc();
// tries++;
//
// if (!quiet) {
// warn("Unable to delete " + whatIsIt + ": " + path + ". Trying again ...");
// }
//
// try {
// Thread.sleep(3000);
// } catch (InterruptedException ex) {
// }
// }
//
// return !path.exists();
// }
// }
// Path: src/main/java/org/cf/resequencer/sequence/CryptoUtils.java
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.math.BigInteger;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.zip.Adler32;
import java.util.zip.CRC32;
import java.util.zip.CheckedInputStream;
import org.cf.resequencer.Console;
}
public static long getAdler32Chksum(String path) throws FileNotFoundException, IOException {
byte[] bytes = new byte[0xFFFF];
FileInputStream fis = new FileInputStream(path);
Adler32 chkAdler32 = new Adler32();
CheckedInputStream cis = new CheckedInputStream(fis, chkAdler32);
while (cis.read(bytes) >= 0) {
;
}
fis.close();
return chkAdler32.getValue();
}
public static String getMD5Sum(String path) throws FileNotFoundException, NoSuchAlgorithmException {
MessageDigest digest = MessageDigest.getInstance("MD5");
InputStream is = new FileInputStream(new File(path));
byte[] buffer = new byte[0xFFFF];
int read = 0;
try {
while ((read = is.read(buffer)) > 0) {
digest.update(buffer, 0, read);
}
byte[] md5sum = digest.digest();
BigInteger bigInt = new BigInteger(1, md5sum);
return bigInt.toString(16);
} catch (IOException e) { | Console.warn("Unable to process " + path + " for MD5Sum.\n" + e); |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.