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 |
|---|---|---|---|---|---|---|
codecentric/conference-app | app/src/main/java/de/codecentric/controller/NewsController.java | // Path: app/src/main/java/de/codecentric/dao/NewsDao.java
// public interface NewsDao {
//
// List<News> getAllNews();
//
// void saveNews(News n);
// }
//
// Path: app/src/main/java/de/codecentric/domain/News.java
// @Entity(name = "news")
// @NamedQueries({ @NamedQuery(name = "findAllNews", query = "from news")})
// public class News {
//
// @Id
// @GeneratedValue(strategy = GenerationType.IDENTITY)
// private long id;
//
// @Column(length = 2048)
// private String text;
//
// public News() {
// // JPA default constructor
// }
//
// public String getText() {
// return text;
// }
//
// public void setText(String text) {
// this.text = text;
// }
// }
//
// Path: app/src/main/java/de/codecentric/model/NewsFormData.java
// public class NewsFormData {
//
// private String text;
//
// public String getText() {
// return text;
// }
//
// public void setText(String text) {
// this.text = text;
// }
//
// }
| import de.codecentric.dao.NewsDao;
import de.codecentric.domain.News;
import de.codecentric.model.NewsFormData;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.servlet.ModelAndView;
import java.util.Map; | package de.codecentric.controller;
@Controller
@RequestMapping("/admin/news")
public class NewsController {
@Autowired
private NewsDao newsDao;
@ModelAttribute("newsFormData") | // Path: app/src/main/java/de/codecentric/dao/NewsDao.java
// public interface NewsDao {
//
// List<News> getAllNews();
//
// void saveNews(News n);
// }
//
// Path: app/src/main/java/de/codecentric/domain/News.java
// @Entity(name = "news")
// @NamedQueries({ @NamedQuery(name = "findAllNews", query = "from news")})
// public class News {
//
// @Id
// @GeneratedValue(strategy = GenerationType.IDENTITY)
// private long id;
//
// @Column(length = 2048)
// private String text;
//
// public News() {
// // JPA default constructor
// }
//
// public String getText() {
// return text;
// }
//
// public void setText(String text) {
// this.text = text;
// }
// }
//
// Path: app/src/main/java/de/codecentric/model/NewsFormData.java
// public class NewsFormData {
//
// private String text;
//
// public String getText() {
// return text;
// }
//
// public void setText(String text) {
// this.text = text;
// }
//
// }
// Path: app/src/main/java/de/codecentric/controller/NewsController.java
import de.codecentric.dao.NewsDao;
import de.codecentric.domain.News;
import de.codecentric.model.NewsFormData;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.servlet.ModelAndView;
import java.util.Map;
package de.codecentric.controller;
@Controller
@RequestMapping("/admin/news")
public class NewsController {
@Autowired
private NewsDao newsDao;
@ModelAttribute("newsFormData") | public NewsFormData getNewsFormData() { |
codecentric/conference-app | app/src/main/java/de/codecentric/controller/NewsController.java | // Path: app/src/main/java/de/codecentric/dao/NewsDao.java
// public interface NewsDao {
//
// List<News> getAllNews();
//
// void saveNews(News n);
// }
//
// Path: app/src/main/java/de/codecentric/domain/News.java
// @Entity(name = "news")
// @NamedQueries({ @NamedQuery(name = "findAllNews", query = "from news")})
// public class News {
//
// @Id
// @GeneratedValue(strategy = GenerationType.IDENTITY)
// private long id;
//
// @Column(length = 2048)
// private String text;
//
// public News() {
// // JPA default constructor
// }
//
// public String getText() {
// return text;
// }
//
// public void setText(String text) {
// this.text = text;
// }
// }
//
// Path: app/src/main/java/de/codecentric/model/NewsFormData.java
// public class NewsFormData {
//
// private String text;
//
// public String getText() {
// return text;
// }
//
// public void setText(String text) {
// this.text = text;
// }
//
// }
| import de.codecentric.dao.NewsDao;
import de.codecentric.domain.News;
import de.codecentric.model.NewsFormData;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.servlet.ModelAndView;
import java.util.Map; | package de.codecentric.controller;
@Controller
@RequestMapping("/admin/news")
public class NewsController {
@Autowired
private NewsDao newsDao;
@ModelAttribute("newsFormData")
public NewsFormData getNewsFormData() {
return new NewsFormData();
}
@RequestMapping(method = RequestMethod.GET)
public String getNews(Map<String, Object> modelMap) {
modelMap.put("newsList", newsDao.getAllNews());
return "createNews";
}
@RequestMapping(method = RequestMethod.POST)
public ModelAndView saveNews(ModelMap modelMap, @ModelAttribute("newsFormData") NewsFormData formData) {
modelMap.put("newsFormData", formData);
| // Path: app/src/main/java/de/codecentric/dao/NewsDao.java
// public interface NewsDao {
//
// List<News> getAllNews();
//
// void saveNews(News n);
// }
//
// Path: app/src/main/java/de/codecentric/domain/News.java
// @Entity(name = "news")
// @NamedQueries({ @NamedQuery(name = "findAllNews", query = "from news")})
// public class News {
//
// @Id
// @GeneratedValue(strategy = GenerationType.IDENTITY)
// private long id;
//
// @Column(length = 2048)
// private String text;
//
// public News() {
// // JPA default constructor
// }
//
// public String getText() {
// return text;
// }
//
// public void setText(String text) {
// this.text = text;
// }
// }
//
// Path: app/src/main/java/de/codecentric/model/NewsFormData.java
// public class NewsFormData {
//
// private String text;
//
// public String getText() {
// return text;
// }
//
// public void setText(String text) {
// this.text = text;
// }
//
// }
// Path: app/src/main/java/de/codecentric/controller/NewsController.java
import de.codecentric.dao.NewsDao;
import de.codecentric.domain.News;
import de.codecentric.model.NewsFormData;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.servlet.ModelAndView;
import java.util.Map;
package de.codecentric.controller;
@Controller
@RequestMapping("/admin/news")
public class NewsController {
@Autowired
private NewsDao newsDao;
@ModelAttribute("newsFormData")
public NewsFormData getNewsFormData() {
return new NewsFormData();
}
@RequestMapping(method = RequestMethod.GET)
public String getNews(Map<String, Object> modelMap) {
modelMap.put("newsList", newsDao.getAllNews());
return "createNews";
}
@RequestMapping(method = RequestMethod.POST)
public ModelAndView saveNews(ModelMap modelMap, @ModelAttribute("newsFormData") NewsFormData formData) {
modelMap.put("newsFormData", formData);
| News news = new News(); |
codecentric/conference-app | app/src/main/java/de/codecentric/validate/impl/NameValidatorImpl.java | // Path: app/src/main/java/de/codecentric/util/TwitterLinkCreator.java
// public class TwitterLinkCreator {
//
// public static final Pattern TWITTER_NAME_PATTERN = Pattern.compile("@[a-zA-Z0-9_]+");
//
// public static String process(String result) {
// Matcher m = TWITTER_NAME_PATTERN.matcher(result);
//
// while (m.find()) {
// final String name = m.group();
// result = result.replaceFirst(name, "<a href=\"http://twitter.com/" + name.substring(1) + "\">" + name + "</a>");
// }
//
// return result;
// }
// }
//
// Path: app/src/main/java/de/codecentric/validate/NameValidator.java
// public interface NameValidator {
//
// public boolean isValid(String speaker);
//
// }
| import de.codecentric.util.TwitterLinkCreator;
import de.codecentric.validate.NameValidator; | package de.codecentric.validate.impl;
/**
* Created by adi on 8/21/14.
*/
public class NameValidatorImpl implements NameValidator {
@Override
public boolean isValid(String speaker) {
if (speaker.isEmpty()) {
return false;
}
| // Path: app/src/main/java/de/codecentric/util/TwitterLinkCreator.java
// public class TwitterLinkCreator {
//
// public static final Pattern TWITTER_NAME_PATTERN = Pattern.compile("@[a-zA-Z0-9_]+");
//
// public static String process(String result) {
// Matcher m = TWITTER_NAME_PATTERN.matcher(result);
//
// while (m.find()) {
// final String name = m.group();
// result = result.replaceFirst(name, "<a href=\"http://twitter.com/" + name.substring(1) + "\">" + name + "</a>");
// }
//
// return result;
// }
// }
//
// Path: app/src/main/java/de/codecentric/validate/NameValidator.java
// public interface NameValidator {
//
// public boolean isValid(String speaker);
//
// }
// Path: app/src/main/java/de/codecentric/validate/impl/NameValidatorImpl.java
import de.codecentric.util.TwitterLinkCreator;
import de.codecentric.validate.NameValidator;
package de.codecentric.validate.impl;
/**
* Created by adi on 8/21/14.
*/
public class NameValidatorImpl implements NameValidator {
@Override
public boolean isValid(String speaker) {
if (speaker.isEmpty()) {
return false;
}
| return TwitterLinkCreator.TWITTER_NAME_PATTERN.matcher(speaker).matches(); |
codecentric/conference-app | app/src/test/java/de/codecentric/util/TwitterLinkCreatorTest.java | // Path: app/src/main/java/de/codecentric/util/TwitterLinkCreator.java
// public class TwitterLinkCreator {
//
// public static final Pattern TWITTER_NAME_PATTERN = Pattern.compile("@[a-zA-Z0-9_]+");
//
// public static String process(String result) {
// Matcher m = TWITTER_NAME_PATTERN.matcher(result);
//
// while (m.find()) {
// final String name = m.group();
// result = result.replaceFirst(name, "<a href=\"http://twitter.com/" + name.substring(1) + "\">" + name + "</a>");
// }
//
// return result;
// }
// }
| import static org.junit.Assert.assertEquals;
import org.junit.Before;
import org.junit.Test;
import de.codecentric.util.TwitterLinkCreator; | package de.codecentric.util;
public class TwitterLinkCreatorTest {
String twitterLink;
@Before
public void setup() {
twitterLink = "http://twitter.com/";
}
@Test
public void shouldProcessSingleTwitterName() {
String validTwitterName = "@foobar";
String linkWithOneTwitterName = "<a href=\"" + twitterLink + "foobar\">@foobar</a>";
| // Path: app/src/main/java/de/codecentric/util/TwitterLinkCreator.java
// public class TwitterLinkCreator {
//
// public static final Pattern TWITTER_NAME_PATTERN = Pattern.compile("@[a-zA-Z0-9_]+");
//
// public static String process(String result) {
// Matcher m = TWITTER_NAME_PATTERN.matcher(result);
//
// while (m.find()) {
// final String name = m.group();
// result = result.replaceFirst(name, "<a href=\"http://twitter.com/" + name.substring(1) + "\">" + name + "</a>");
// }
//
// return result;
// }
// }
// Path: app/src/test/java/de/codecentric/util/TwitterLinkCreatorTest.java
import static org.junit.Assert.assertEquals;
import org.junit.Before;
import org.junit.Test;
import de.codecentric.util.TwitterLinkCreator;
package de.codecentric.util;
public class TwitterLinkCreatorTest {
String twitterLink;
@Before
public void setup() {
twitterLink = "http://twitter.com/";
}
@Test
public void shouldProcessSingleTwitterName() {
String validTwitterName = "@foobar";
String linkWithOneTwitterName = "<a href=\"" + twitterLink + "foobar\">@foobar</a>";
| String result = TwitterLinkCreator.process(validTwitterName); |
codecentric/conference-app | app/src/test/java/de/codecentric/controller/EditSessionControllerTest.java | // Path: app/src/main/java/de/codecentric/controller/EditSessionController.java
// @Controller
// public class EditSessionController {
//
// private static final Logger LOGGER = Logger.getLogger(EditSessionController.class);
//
// @Autowired
// private SessionDao sessionDao;
//
// @Autowired
// private TimeslotDao timeslotDao;
//
// public EditSessionController() {
// super();
// }
//
// public EditSessionController(SessionDao sessionDao, TimeslotDao timeslotDao) {
// this();
// this.sessionDao = sessionDao;
// this.timeslotDao = timeslotDao;
// }
//
// @RequestMapping(value = "/createSession", method = RequestMethod.GET)
// public ModelAndView createSession(ModelMap modelMap, HttpServletRequest request) {
// modelMap.put("timeslots", timeslotDao.getTimeslots("Fri"));
// modelMap.put("days", timeslotDao.getConferenceDays());
//
// OpenSpaceFormData data = new OpenSpaceFormData();
// data.setStart(request.getParameter("start"));
// data.setEnd(request.getParameter("end"));
// data.setLocation(request.getParameter("location"));
// data.setDate(request.getParameter("day"));
// modelMap.put("sessionDataFormData", data);
// modelMap.put("newSession", true);
//
// return new ModelAndView("editSession", modelMap);
// }
//
// @RequestMapping(value = "/editSession", method = RequestMethod.GET)
// public void setupForm(ModelMap modelMap, HttpServletRequest request) {
//
// modelMap.put("sessionDataFormData", new OpenSpaceFormData());
// modelMap.put("timeslots", timeslotDao.getTimeslots("Fri"));
// modelMap.put("days", timeslotDao.getConferenceDays());
// modelMap.put("newSession", false);
//
// String sessionId = request.getParameter("sessionId");
//
// if (sessionId != null) {
// try {
// Session session = sessionDao.getSessionById(sessionId);
// String descriptionWithoutBrTags = Html.brTagsToLineBreaks(session.getDescription());
// session.setDescription(descriptionWithoutBrTags);
// modelMap.put("session", session);
// modelMap.put("sessionDataFormData", new OpenSpaceFormData(session));
// modelMap.put("sessionId", sessionId);
// } catch (Exception e) {
// LOGGER.error("To change body of catch statement use File | Settings | File Templates.", e);
// }
// }
//
// }
//
// @RequestMapping(value = "/editSession", method = RequestMethod.POST)
// public ModelAndView processSubmit(HttpServletRequest request, ModelMap modelMap, @ModelAttribute("sessionDataFormData") OpenSpaceFormData formData, BindingResult result) {
//
// modelMap.put("sessionDataFormData", formData);
//
// if (result.hasErrors()) {
// System.out.println("Validation errors ocurred.");
// return new ModelAndView("editSession");
// }
//
// String sessionId = request.getParameter("sessionId");
// if (sessionId != null) {
// try {
// Session session = sessionDao.getSessionById(sessionId);
// session.setAuthor(Html.escapeHtml(formData.getSpeaker()));
// session.setTitle(Html.escapeHtml(formData.getTitle()));
// session.setDescription(Html.lineBreaksToBrTags(Html.escapeHtml(formData.getDescription())));
// sessionDao.saveSession(session);
//
// return new ModelAndView("redirect:allSessions");
// } catch (Exception e) {
// // do nothing!
// }
// } else {
// // save the data
// Session session = new Session(formData.getDate(), formData.getStart(), formData.getLocation(), formData.getTitle(), formData.getSpeaker(), formData.getDescription());
// session.setEnd(formData.getEnd());
// session.setType(SessionType.openspace);
// sessionDao.saveSession(session);
// }
//
// return new ModelAndView("redirect:allSessions");
// }
//
// @RequestMapping(value = "/timeslotsPerDay", method = RequestMethod.GET)
// public @ResponseBody Map<String, String> getTimeslotForDay(@RequestParam("day") String day) {
//
// List<Timeslot> timeslots = timeslotDao.getTimeslots(day);
// Map<String, String> timeslotsProjected = new HashMap<String, String>();
//
// for (Timeslot timeslot : timeslots) {
// timeslotsProjected.put(timeslot.getStart(), timeslot.toString());
// }
//
// return timeslotsProjected;
// }
//
// }
//
// Path: app/src/main/java/de/codecentric/dao/SessionDao.java
// public interface SessionDao {
//
// List<Session> getAllSessions();
//
// List<String> getListOfConferenceDays();
//
// List<Session> getAllStaticSessions();
//
// /* returns all sessions for a specific date */
// List<Session> getSessionsByDate(String date);
//
// Session saveSession(Session session);
//
// Session getSessionById(String id);
//
// List<Session> getStaticSessionsByDate(String shortName);
//
// List<Session> getCurrentSessions();
//
// List<Session> getAllSessionsByAuthor(String author);
//
// List<Session> getAllSessionsByDate(String now);
//
// List<Session> getAllSessionsByDateAndType(String date, SessionType... type);
//
// List<Session> getAllSessionsByAuthorOrTitleOrDescription(String searchTerm);
//
// }
| import static org.junit.Assert.assertEquals;
import java.util.Map;
import org.junit.Before;
import org.junit.Test;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import de.codecentric.controller.EditSessionController;
import de.codecentric.dao.SessionDao; | package de.codecentric.controller;
public class EditSessionControllerTest {
@Mock | // Path: app/src/main/java/de/codecentric/controller/EditSessionController.java
// @Controller
// public class EditSessionController {
//
// private static final Logger LOGGER = Logger.getLogger(EditSessionController.class);
//
// @Autowired
// private SessionDao sessionDao;
//
// @Autowired
// private TimeslotDao timeslotDao;
//
// public EditSessionController() {
// super();
// }
//
// public EditSessionController(SessionDao sessionDao, TimeslotDao timeslotDao) {
// this();
// this.sessionDao = sessionDao;
// this.timeslotDao = timeslotDao;
// }
//
// @RequestMapping(value = "/createSession", method = RequestMethod.GET)
// public ModelAndView createSession(ModelMap modelMap, HttpServletRequest request) {
// modelMap.put("timeslots", timeslotDao.getTimeslots("Fri"));
// modelMap.put("days", timeslotDao.getConferenceDays());
//
// OpenSpaceFormData data = new OpenSpaceFormData();
// data.setStart(request.getParameter("start"));
// data.setEnd(request.getParameter("end"));
// data.setLocation(request.getParameter("location"));
// data.setDate(request.getParameter("day"));
// modelMap.put("sessionDataFormData", data);
// modelMap.put("newSession", true);
//
// return new ModelAndView("editSession", modelMap);
// }
//
// @RequestMapping(value = "/editSession", method = RequestMethod.GET)
// public void setupForm(ModelMap modelMap, HttpServletRequest request) {
//
// modelMap.put("sessionDataFormData", new OpenSpaceFormData());
// modelMap.put("timeslots", timeslotDao.getTimeslots("Fri"));
// modelMap.put("days", timeslotDao.getConferenceDays());
// modelMap.put("newSession", false);
//
// String sessionId = request.getParameter("sessionId");
//
// if (sessionId != null) {
// try {
// Session session = sessionDao.getSessionById(sessionId);
// String descriptionWithoutBrTags = Html.brTagsToLineBreaks(session.getDescription());
// session.setDescription(descriptionWithoutBrTags);
// modelMap.put("session", session);
// modelMap.put("sessionDataFormData", new OpenSpaceFormData(session));
// modelMap.put("sessionId", sessionId);
// } catch (Exception e) {
// LOGGER.error("To change body of catch statement use File | Settings | File Templates.", e);
// }
// }
//
// }
//
// @RequestMapping(value = "/editSession", method = RequestMethod.POST)
// public ModelAndView processSubmit(HttpServletRequest request, ModelMap modelMap, @ModelAttribute("sessionDataFormData") OpenSpaceFormData formData, BindingResult result) {
//
// modelMap.put("sessionDataFormData", formData);
//
// if (result.hasErrors()) {
// System.out.println("Validation errors ocurred.");
// return new ModelAndView("editSession");
// }
//
// String sessionId = request.getParameter("sessionId");
// if (sessionId != null) {
// try {
// Session session = sessionDao.getSessionById(sessionId);
// session.setAuthor(Html.escapeHtml(formData.getSpeaker()));
// session.setTitle(Html.escapeHtml(formData.getTitle()));
// session.setDescription(Html.lineBreaksToBrTags(Html.escapeHtml(formData.getDescription())));
// sessionDao.saveSession(session);
//
// return new ModelAndView("redirect:allSessions");
// } catch (Exception e) {
// // do nothing!
// }
// } else {
// // save the data
// Session session = new Session(formData.getDate(), formData.getStart(), formData.getLocation(), formData.getTitle(), formData.getSpeaker(), formData.getDescription());
// session.setEnd(formData.getEnd());
// session.setType(SessionType.openspace);
// sessionDao.saveSession(session);
// }
//
// return new ModelAndView("redirect:allSessions");
// }
//
// @RequestMapping(value = "/timeslotsPerDay", method = RequestMethod.GET)
// public @ResponseBody Map<String, String> getTimeslotForDay(@RequestParam("day") String day) {
//
// List<Timeslot> timeslots = timeslotDao.getTimeslots(day);
// Map<String, String> timeslotsProjected = new HashMap<String, String>();
//
// for (Timeslot timeslot : timeslots) {
// timeslotsProjected.put(timeslot.getStart(), timeslot.toString());
// }
//
// return timeslotsProjected;
// }
//
// }
//
// Path: app/src/main/java/de/codecentric/dao/SessionDao.java
// public interface SessionDao {
//
// List<Session> getAllSessions();
//
// List<String> getListOfConferenceDays();
//
// List<Session> getAllStaticSessions();
//
// /* returns all sessions for a specific date */
// List<Session> getSessionsByDate(String date);
//
// Session saveSession(Session session);
//
// Session getSessionById(String id);
//
// List<Session> getStaticSessionsByDate(String shortName);
//
// List<Session> getCurrentSessions();
//
// List<Session> getAllSessionsByAuthor(String author);
//
// List<Session> getAllSessionsByDate(String now);
//
// List<Session> getAllSessionsByDateAndType(String date, SessionType... type);
//
// List<Session> getAllSessionsByAuthorOrTitleOrDescription(String searchTerm);
//
// }
// Path: app/src/test/java/de/codecentric/controller/EditSessionControllerTest.java
import static org.junit.Assert.assertEquals;
import java.util.Map;
import org.junit.Before;
import org.junit.Test;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import de.codecentric.controller.EditSessionController;
import de.codecentric.dao.SessionDao;
package de.codecentric.controller;
public class EditSessionControllerTest {
@Mock | private SessionDao sessionDao; |
codecentric/conference-app | app/src/test/java/de/codecentric/controller/EditSessionControllerTest.java | // Path: app/src/main/java/de/codecentric/controller/EditSessionController.java
// @Controller
// public class EditSessionController {
//
// private static final Logger LOGGER = Logger.getLogger(EditSessionController.class);
//
// @Autowired
// private SessionDao sessionDao;
//
// @Autowired
// private TimeslotDao timeslotDao;
//
// public EditSessionController() {
// super();
// }
//
// public EditSessionController(SessionDao sessionDao, TimeslotDao timeslotDao) {
// this();
// this.sessionDao = sessionDao;
// this.timeslotDao = timeslotDao;
// }
//
// @RequestMapping(value = "/createSession", method = RequestMethod.GET)
// public ModelAndView createSession(ModelMap modelMap, HttpServletRequest request) {
// modelMap.put("timeslots", timeslotDao.getTimeslots("Fri"));
// modelMap.put("days", timeslotDao.getConferenceDays());
//
// OpenSpaceFormData data = new OpenSpaceFormData();
// data.setStart(request.getParameter("start"));
// data.setEnd(request.getParameter("end"));
// data.setLocation(request.getParameter("location"));
// data.setDate(request.getParameter("day"));
// modelMap.put("sessionDataFormData", data);
// modelMap.put("newSession", true);
//
// return new ModelAndView("editSession", modelMap);
// }
//
// @RequestMapping(value = "/editSession", method = RequestMethod.GET)
// public void setupForm(ModelMap modelMap, HttpServletRequest request) {
//
// modelMap.put("sessionDataFormData", new OpenSpaceFormData());
// modelMap.put("timeslots", timeslotDao.getTimeslots("Fri"));
// modelMap.put("days", timeslotDao.getConferenceDays());
// modelMap.put("newSession", false);
//
// String sessionId = request.getParameter("sessionId");
//
// if (sessionId != null) {
// try {
// Session session = sessionDao.getSessionById(sessionId);
// String descriptionWithoutBrTags = Html.brTagsToLineBreaks(session.getDescription());
// session.setDescription(descriptionWithoutBrTags);
// modelMap.put("session", session);
// modelMap.put("sessionDataFormData", new OpenSpaceFormData(session));
// modelMap.put("sessionId", sessionId);
// } catch (Exception e) {
// LOGGER.error("To change body of catch statement use File | Settings | File Templates.", e);
// }
// }
//
// }
//
// @RequestMapping(value = "/editSession", method = RequestMethod.POST)
// public ModelAndView processSubmit(HttpServletRequest request, ModelMap modelMap, @ModelAttribute("sessionDataFormData") OpenSpaceFormData formData, BindingResult result) {
//
// modelMap.put("sessionDataFormData", formData);
//
// if (result.hasErrors()) {
// System.out.println("Validation errors ocurred.");
// return new ModelAndView("editSession");
// }
//
// String sessionId = request.getParameter("sessionId");
// if (sessionId != null) {
// try {
// Session session = sessionDao.getSessionById(sessionId);
// session.setAuthor(Html.escapeHtml(formData.getSpeaker()));
// session.setTitle(Html.escapeHtml(formData.getTitle()));
// session.setDescription(Html.lineBreaksToBrTags(Html.escapeHtml(formData.getDescription())));
// sessionDao.saveSession(session);
//
// return new ModelAndView("redirect:allSessions");
// } catch (Exception e) {
// // do nothing!
// }
// } else {
// // save the data
// Session session = new Session(formData.getDate(), formData.getStart(), formData.getLocation(), formData.getTitle(), formData.getSpeaker(), formData.getDescription());
// session.setEnd(formData.getEnd());
// session.setType(SessionType.openspace);
// sessionDao.saveSession(session);
// }
//
// return new ModelAndView("redirect:allSessions");
// }
//
// @RequestMapping(value = "/timeslotsPerDay", method = RequestMethod.GET)
// public @ResponseBody Map<String, String> getTimeslotForDay(@RequestParam("day") String day) {
//
// List<Timeslot> timeslots = timeslotDao.getTimeslots(day);
// Map<String, String> timeslotsProjected = new HashMap<String, String>();
//
// for (Timeslot timeslot : timeslots) {
// timeslotsProjected.put(timeslot.getStart(), timeslot.toString());
// }
//
// return timeslotsProjected;
// }
//
// }
//
// Path: app/src/main/java/de/codecentric/dao/SessionDao.java
// public interface SessionDao {
//
// List<Session> getAllSessions();
//
// List<String> getListOfConferenceDays();
//
// List<Session> getAllStaticSessions();
//
// /* returns all sessions for a specific date */
// List<Session> getSessionsByDate(String date);
//
// Session saveSession(Session session);
//
// Session getSessionById(String id);
//
// List<Session> getStaticSessionsByDate(String shortName);
//
// List<Session> getCurrentSessions();
//
// List<Session> getAllSessionsByAuthor(String author);
//
// List<Session> getAllSessionsByDate(String now);
//
// List<Session> getAllSessionsByDateAndType(String date, SessionType... type);
//
// List<Session> getAllSessionsByAuthorOrTitleOrDescription(String searchTerm);
//
// }
| import static org.junit.Assert.assertEquals;
import java.util.Map;
import org.junit.Before;
import org.junit.Test;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import de.codecentric.controller.EditSessionController;
import de.codecentric.dao.SessionDao; | package de.codecentric.controller;
public class EditSessionControllerTest {
@Mock
private SessionDao sessionDao;
| // Path: app/src/main/java/de/codecentric/controller/EditSessionController.java
// @Controller
// public class EditSessionController {
//
// private static final Logger LOGGER = Logger.getLogger(EditSessionController.class);
//
// @Autowired
// private SessionDao sessionDao;
//
// @Autowired
// private TimeslotDao timeslotDao;
//
// public EditSessionController() {
// super();
// }
//
// public EditSessionController(SessionDao sessionDao, TimeslotDao timeslotDao) {
// this();
// this.sessionDao = sessionDao;
// this.timeslotDao = timeslotDao;
// }
//
// @RequestMapping(value = "/createSession", method = RequestMethod.GET)
// public ModelAndView createSession(ModelMap modelMap, HttpServletRequest request) {
// modelMap.put("timeslots", timeslotDao.getTimeslots("Fri"));
// modelMap.put("days", timeslotDao.getConferenceDays());
//
// OpenSpaceFormData data = new OpenSpaceFormData();
// data.setStart(request.getParameter("start"));
// data.setEnd(request.getParameter("end"));
// data.setLocation(request.getParameter("location"));
// data.setDate(request.getParameter("day"));
// modelMap.put("sessionDataFormData", data);
// modelMap.put("newSession", true);
//
// return new ModelAndView("editSession", modelMap);
// }
//
// @RequestMapping(value = "/editSession", method = RequestMethod.GET)
// public void setupForm(ModelMap modelMap, HttpServletRequest request) {
//
// modelMap.put("sessionDataFormData", new OpenSpaceFormData());
// modelMap.put("timeslots", timeslotDao.getTimeslots("Fri"));
// modelMap.put("days", timeslotDao.getConferenceDays());
// modelMap.put("newSession", false);
//
// String sessionId = request.getParameter("sessionId");
//
// if (sessionId != null) {
// try {
// Session session = sessionDao.getSessionById(sessionId);
// String descriptionWithoutBrTags = Html.brTagsToLineBreaks(session.getDescription());
// session.setDescription(descriptionWithoutBrTags);
// modelMap.put("session", session);
// modelMap.put("sessionDataFormData", new OpenSpaceFormData(session));
// modelMap.put("sessionId", sessionId);
// } catch (Exception e) {
// LOGGER.error("To change body of catch statement use File | Settings | File Templates.", e);
// }
// }
//
// }
//
// @RequestMapping(value = "/editSession", method = RequestMethod.POST)
// public ModelAndView processSubmit(HttpServletRequest request, ModelMap modelMap, @ModelAttribute("sessionDataFormData") OpenSpaceFormData formData, BindingResult result) {
//
// modelMap.put("sessionDataFormData", formData);
//
// if (result.hasErrors()) {
// System.out.println("Validation errors ocurred.");
// return new ModelAndView("editSession");
// }
//
// String sessionId = request.getParameter("sessionId");
// if (sessionId != null) {
// try {
// Session session = sessionDao.getSessionById(sessionId);
// session.setAuthor(Html.escapeHtml(formData.getSpeaker()));
// session.setTitle(Html.escapeHtml(formData.getTitle()));
// session.setDescription(Html.lineBreaksToBrTags(Html.escapeHtml(formData.getDescription())));
// sessionDao.saveSession(session);
//
// return new ModelAndView("redirect:allSessions");
// } catch (Exception e) {
// // do nothing!
// }
// } else {
// // save the data
// Session session = new Session(formData.getDate(), formData.getStart(), formData.getLocation(), formData.getTitle(), formData.getSpeaker(), formData.getDescription());
// session.setEnd(formData.getEnd());
// session.setType(SessionType.openspace);
// sessionDao.saveSession(session);
// }
//
// return new ModelAndView("redirect:allSessions");
// }
//
// @RequestMapping(value = "/timeslotsPerDay", method = RequestMethod.GET)
// public @ResponseBody Map<String, String> getTimeslotForDay(@RequestParam("day") String day) {
//
// List<Timeslot> timeslots = timeslotDao.getTimeslots(day);
// Map<String, String> timeslotsProjected = new HashMap<String, String>();
//
// for (Timeslot timeslot : timeslots) {
// timeslotsProjected.put(timeslot.getStart(), timeslot.toString());
// }
//
// return timeslotsProjected;
// }
//
// }
//
// Path: app/src/main/java/de/codecentric/dao/SessionDao.java
// public interface SessionDao {
//
// List<Session> getAllSessions();
//
// List<String> getListOfConferenceDays();
//
// List<Session> getAllStaticSessions();
//
// /* returns all sessions for a specific date */
// List<Session> getSessionsByDate(String date);
//
// Session saveSession(Session session);
//
// Session getSessionById(String id);
//
// List<Session> getStaticSessionsByDate(String shortName);
//
// List<Session> getCurrentSessions();
//
// List<Session> getAllSessionsByAuthor(String author);
//
// List<Session> getAllSessionsByDate(String now);
//
// List<Session> getAllSessionsByDateAndType(String date, SessionType... type);
//
// List<Session> getAllSessionsByAuthorOrTitleOrDescription(String searchTerm);
//
// }
// Path: app/src/test/java/de/codecentric/controller/EditSessionControllerTest.java
import static org.junit.Assert.assertEquals;
import java.util.Map;
import org.junit.Before;
import org.junit.Test;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import de.codecentric.controller.EditSessionController;
import de.codecentric.dao.SessionDao;
package de.codecentric.controller;
public class EditSessionControllerTest {
@Mock
private SessionDao sessionDao;
| private EditSessionController controller; |
codecentric/conference-app | app/src/test/java/de/codecentric/util/HtmlTest.java | // Path: app/src/main/java/de/codecentric/util/Html.java
// public class Html {
//
// public static String escapeHtml(String html) {
// return HtmlUtils.htmlEscape(html);
// }
//
// public static String unEscapeHtml(String html) {
// return HtmlUtils.htmlUnescape(html);
// }
//
// public static String lineBreaksToBrTags(String string) {
// return string == null ? null : string.replace("\n", "<br/>");
// }
//
// public static String brTagsToLineBreaks(String string) {
// return string == null ? null : string.replace("<br/>", "\n");
// }
//
// }
| import static org.junit.Assert.assertEquals;
import org.junit.Test;
import de.codecentric.util.Html; | package de.codecentric.util;
public class HtmlTest {
@Test
public void escapeHtmlLt() throws Exception { | // Path: app/src/main/java/de/codecentric/util/Html.java
// public class Html {
//
// public static String escapeHtml(String html) {
// return HtmlUtils.htmlEscape(html);
// }
//
// public static String unEscapeHtml(String html) {
// return HtmlUtils.htmlUnescape(html);
// }
//
// public static String lineBreaksToBrTags(String string) {
// return string == null ? null : string.replace("\n", "<br/>");
// }
//
// public static String brTagsToLineBreaks(String string) {
// return string == null ? null : string.replace("<br/>", "\n");
// }
//
// }
// Path: app/src/test/java/de/codecentric/util/HtmlTest.java
import static org.junit.Assert.assertEquals;
import org.junit.Test;
import de.codecentric.util.Html;
package de.codecentric.util;
public class HtmlTest {
@Test
public void escapeHtmlLt() throws Exception { | assertEquals("<", Html.escapeHtml("<")); |
codecentric/conference-app | app/src/test/java/de/codecentric/controller/FeedbackControllerTest.java | // Path: app/src/main/java/de/codecentric/Application.java
// @EnableAutoConfiguration
// @SpringBootApplication
// @ComponentScan
// @Import(ApplicationWebConfiguration.class)
// public class Application extends SpringBootServletInitializer {
//
// public static void main(String[] args) {
// SpringApplication.run(Application.class, args);
// }
//
// @Override
// protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
// return application.sources(Application.class);
// }
// }
//
// Path: app/src/main/java/de/codecentric/dao/FeedbackDao.java
// public interface FeedbackDao {
//
// public void save(Feedback feedback);
//
// public List<Feedback> getFeedbackList();
// }
//
// Path: app/src/main/java/de/codecentric/domain/Feedback.java
// @Entity(name = "feedback")
// @NamedQueries({ @NamedQuery(name = "findFeedback", query = "from feedback order by timestamp desc") })
// public class Feedback {
//
// @Id
// @GeneratedValue(strategy = GenerationType.AUTO)
// private long id;
//
// private String userName;
// @Lob
// private String feedbackComment;
//
// @Temporal(TemporalType.TIMESTAMP)
// private Date timestamp;
//
// public long getId() {
// return id;
// }
//
// public void setId(long id) {
// this.id = id;
// }
//
// public String getUserName() {
// return userName;
// }
//
// public void setUserName(String userName) {
// this.userName = userName;
// }
//
// public String getFeedbackComment() {
// return feedbackComment;
// }
//
// public void setFeedbackComment(String feedbackComment) {
// this.feedbackComment = feedbackComment;
// }
//
// public Date getTimestamp() {
// return timestamp;
// }
//
// public void setTimestamp(Date timestamp) {
// this.timestamp = timestamp;
// }
//
// }
//
// Path: app/src/main/java/de/codecentric/model/FeedbackFormData.java
// public class FeedbackFormData {
//
// private String id;
// private String name;
// private String feedbackContent;
//
// public String getFeedbackContent() {
// return feedbackContent;
// }
//
// public void setFeedbackContent(String feedbackContent) {
// this.feedbackContent = feedbackContent;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getId() {
// return id;
// }
//
// public void setId(String id) {
// this.id = id;
// }
//
// }
| import static org.hamcrest.Matchers.containsString;
import static org.mockito.Mockito.when;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.model;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.view;
import static org.springframework.test.web.servlet.setup.MockMvcBuilders.standaloneSetup;
import java.util.Arrays;
import java.util.List;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import org.springframework.boot.test.SpringApplicationConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.test.context.web.WebAppConfiguration;
import org.springframework.test.web.servlet.MockMvc;
import org.springframework.web.servlet.View;
import de.codecentric.Application;
import de.codecentric.dao.FeedbackDao;
import de.codecentric.domain.Feedback;
import de.codecentric.model.FeedbackFormData; | package de.codecentric.controller;
@RunWith(SpringJUnit4ClassRunner.class)
@SpringApplicationConfiguration(classes = { Application.class, FeedbackDao.class })
@WebAppConfiguration
public class FeedbackControllerTest {
@InjectMocks
FeedbackController controller;
@Mock
FeedbackDao feedbackDao;
@Mock
View mockView;
private MockMvc mockMvc;
@Before
public void setup() {
MockitoAnnotations.initMocks(this);
mockMvc = standaloneSetup(controller).setSingleView(mockView).build();
}
@Test
public void testGetFeedbackList() throws Exception { | // Path: app/src/main/java/de/codecentric/Application.java
// @EnableAutoConfiguration
// @SpringBootApplication
// @ComponentScan
// @Import(ApplicationWebConfiguration.class)
// public class Application extends SpringBootServletInitializer {
//
// public static void main(String[] args) {
// SpringApplication.run(Application.class, args);
// }
//
// @Override
// protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
// return application.sources(Application.class);
// }
// }
//
// Path: app/src/main/java/de/codecentric/dao/FeedbackDao.java
// public interface FeedbackDao {
//
// public void save(Feedback feedback);
//
// public List<Feedback> getFeedbackList();
// }
//
// Path: app/src/main/java/de/codecentric/domain/Feedback.java
// @Entity(name = "feedback")
// @NamedQueries({ @NamedQuery(name = "findFeedback", query = "from feedback order by timestamp desc") })
// public class Feedback {
//
// @Id
// @GeneratedValue(strategy = GenerationType.AUTO)
// private long id;
//
// private String userName;
// @Lob
// private String feedbackComment;
//
// @Temporal(TemporalType.TIMESTAMP)
// private Date timestamp;
//
// public long getId() {
// return id;
// }
//
// public void setId(long id) {
// this.id = id;
// }
//
// public String getUserName() {
// return userName;
// }
//
// public void setUserName(String userName) {
// this.userName = userName;
// }
//
// public String getFeedbackComment() {
// return feedbackComment;
// }
//
// public void setFeedbackComment(String feedbackComment) {
// this.feedbackComment = feedbackComment;
// }
//
// public Date getTimestamp() {
// return timestamp;
// }
//
// public void setTimestamp(Date timestamp) {
// this.timestamp = timestamp;
// }
//
// }
//
// Path: app/src/main/java/de/codecentric/model/FeedbackFormData.java
// public class FeedbackFormData {
//
// private String id;
// private String name;
// private String feedbackContent;
//
// public String getFeedbackContent() {
// return feedbackContent;
// }
//
// public void setFeedbackContent(String feedbackContent) {
// this.feedbackContent = feedbackContent;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getId() {
// return id;
// }
//
// public void setId(String id) {
// this.id = id;
// }
//
// }
// Path: app/src/test/java/de/codecentric/controller/FeedbackControllerTest.java
import static org.hamcrest.Matchers.containsString;
import static org.mockito.Mockito.when;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.model;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.view;
import static org.springframework.test.web.servlet.setup.MockMvcBuilders.standaloneSetup;
import java.util.Arrays;
import java.util.List;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import org.springframework.boot.test.SpringApplicationConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.test.context.web.WebAppConfiguration;
import org.springframework.test.web.servlet.MockMvc;
import org.springframework.web.servlet.View;
import de.codecentric.Application;
import de.codecentric.dao.FeedbackDao;
import de.codecentric.domain.Feedback;
import de.codecentric.model.FeedbackFormData;
package de.codecentric.controller;
@RunWith(SpringJUnit4ClassRunner.class)
@SpringApplicationConfiguration(classes = { Application.class, FeedbackDao.class })
@WebAppConfiguration
public class FeedbackControllerTest {
@InjectMocks
FeedbackController controller;
@Mock
FeedbackDao feedbackDao;
@Mock
View mockView;
private MockMvc mockMvc;
@Before
public void setup() {
MockitoAnnotations.initMocks(this);
mockMvc = standaloneSetup(controller).setSingleView(mockView).build();
}
@Test
public void testGetFeedbackList() throws Exception { | List<Feedback> feedbackList = Arrays.asList(new Feedback()); |
codecentric/conference-app | app/src/test/java/de/codecentric/controller/FeedbackControllerTest.java | // Path: app/src/main/java/de/codecentric/Application.java
// @EnableAutoConfiguration
// @SpringBootApplication
// @ComponentScan
// @Import(ApplicationWebConfiguration.class)
// public class Application extends SpringBootServletInitializer {
//
// public static void main(String[] args) {
// SpringApplication.run(Application.class, args);
// }
//
// @Override
// protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
// return application.sources(Application.class);
// }
// }
//
// Path: app/src/main/java/de/codecentric/dao/FeedbackDao.java
// public interface FeedbackDao {
//
// public void save(Feedback feedback);
//
// public List<Feedback> getFeedbackList();
// }
//
// Path: app/src/main/java/de/codecentric/domain/Feedback.java
// @Entity(name = "feedback")
// @NamedQueries({ @NamedQuery(name = "findFeedback", query = "from feedback order by timestamp desc") })
// public class Feedback {
//
// @Id
// @GeneratedValue(strategy = GenerationType.AUTO)
// private long id;
//
// private String userName;
// @Lob
// private String feedbackComment;
//
// @Temporal(TemporalType.TIMESTAMP)
// private Date timestamp;
//
// public long getId() {
// return id;
// }
//
// public void setId(long id) {
// this.id = id;
// }
//
// public String getUserName() {
// return userName;
// }
//
// public void setUserName(String userName) {
// this.userName = userName;
// }
//
// public String getFeedbackComment() {
// return feedbackComment;
// }
//
// public void setFeedbackComment(String feedbackComment) {
// this.feedbackComment = feedbackComment;
// }
//
// public Date getTimestamp() {
// return timestamp;
// }
//
// public void setTimestamp(Date timestamp) {
// this.timestamp = timestamp;
// }
//
// }
//
// Path: app/src/main/java/de/codecentric/model/FeedbackFormData.java
// public class FeedbackFormData {
//
// private String id;
// private String name;
// private String feedbackContent;
//
// public String getFeedbackContent() {
// return feedbackContent;
// }
//
// public void setFeedbackContent(String feedbackContent) {
// this.feedbackContent = feedbackContent;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getId() {
// return id;
// }
//
// public void setId(String id) {
// this.id = id;
// }
//
// }
| import static org.hamcrest.Matchers.containsString;
import static org.mockito.Mockito.when;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.model;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.view;
import static org.springframework.test.web.servlet.setup.MockMvcBuilders.standaloneSetup;
import java.util.Arrays;
import java.util.List;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import org.springframework.boot.test.SpringApplicationConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.test.context.web.WebAppConfiguration;
import org.springframework.test.web.servlet.MockMvc;
import org.springframework.web.servlet.View;
import de.codecentric.Application;
import de.codecentric.dao.FeedbackDao;
import de.codecentric.domain.Feedback;
import de.codecentric.model.FeedbackFormData; | package de.codecentric.controller;
@RunWith(SpringJUnit4ClassRunner.class)
@SpringApplicationConfiguration(classes = { Application.class, FeedbackDao.class })
@WebAppConfiguration
public class FeedbackControllerTest {
@InjectMocks
FeedbackController controller;
@Mock
FeedbackDao feedbackDao;
@Mock
View mockView;
private MockMvc mockMvc;
@Before
public void setup() {
MockitoAnnotations.initMocks(this);
mockMvc = standaloneSetup(controller).setSingleView(mockView).build();
}
@Test
public void testGetFeedbackList() throws Exception {
List<Feedback> feedbackList = Arrays.asList(new Feedback());
when(feedbackDao.getFeedbackList()).thenReturn(feedbackList);
mockMvc.perform(get("/feedback")).andExpect(status().isOk()).andExpect(model().attribute("feedbackList", feedbackList)).andExpect(view().name("feedback"));
}
@Test
public void testPostNewFeedback() throws Exception { | // Path: app/src/main/java/de/codecentric/Application.java
// @EnableAutoConfiguration
// @SpringBootApplication
// @ComponentScan
// @Import(ApplicationWebConfiguration.class)
// public class Application extends SpringBootServletInitializer {
//
// public static void main(String[] args) {
// SpringApplication.run(Application.class, args);
// }
//
// @Override
// protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
// return application.sources(Application.class);
// }
// }
//
// Path: app/src/main/java/de/codecentric/dao/FeedbackDao.java
// public interface FeedbackDao {
//
// public void save(Feedback feedback);
//
// public List<Feedback> getFeedbackList();
// }
//
// Path: app/src/main/java/de/codecentric/domain/Feedback.java
// @Entity(name = "feedback")
// @NamedQueries({ @NamedQuery(name = "findFeedback", query = "from feedback order by timestamp desc") })
// public class Feedback {
//
// @Id
// @GeneratedValue(strategy = GenerationType.AUTO)
// private long id;
//
// private String userName;
// @Lob
// private String feedbackComment;
//
// @Temporal(TemporalType.TIMESTAMP)
// private Date timestamp;
//
// public long getId() {
// return id;
// }
//
// public void setId(long id) {
// this.id = id;
// }
//
// public String getUserName() {
// return userName;
// }
//
// public void setUserName(String userName) {
// this.userName = userName;
// }
//
// public String getFeedbackComment() {
// return feedbackComment;
// }
//
// public void setFeedbackComment(String feedbackComment) {
// this.feedbackComment = feedbackComment;
// }
//
// public Date getTimestamp() {
// return timestamp;
// }
//
// public void setTimestamp(Date timestamp) {
// this.timestamp = timestamp;
// }
//
// }
//
// Path: app/src/main/java/de/codecentric/model/FeedbackFormData.java
// public class FeedbackFormData {
//
// private String id;
// private String name;
// private String feedbackContent;
//
// public String getFeedbackContent() {
// return feedbackContent;
// }
//
// public void setFeedbackContent(String feedbackContent) {
// this.feedbackContent = feedbackContent;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getId() {
// return id;
// }
//
// public void setId(String id) {
// this.id = id;
// }
//
// }
// Path: app/src/test/java/de/codecentric/controller/FeedbackControllerTest.java
import static org.hamcrest.Matchers.containsString;
import static org.mockito.Mockito.when;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.model;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.view;
import static org.springframework.test.web.servlet.setup.MockMvcBuilders.standaloneSetup;
import java.util.Arrays;
import java.util.List;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import org.springframework.boot.test.SpringApplicationConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.test.context.web.WebAppConfiguration;
import org.springframework.test.web.servlet.MockMvc;
import org.springframework.web.servlet.View;
import de.codecentric.Application;
import de.codecentric.dao.FeedbackDao;
import de.codecentric.domain.Feedback;
import de.codecentric.model.FeedbackFormData;
package de.codecentric.controller;
@RunWith(SpringJUnit4ClassRunner.class)
@SpringApplicationConfiguration(classes = { Application.class, FeedbackDao.class })
@WebAppConfiguration
public class FeedbackControllerTest {
@InjectMocks
FeedbackController controller;
@Mock
FeedbackDao feedbackDao;
@Mock
View mockView;
private MockMvc mockMvc;
@Before
public void setup() {
MockitoAnnotations.initMocks(this);
mockMvc = standaloneSetup(controller).setSingleView(mockView).build();
}
@Test
public void testGetFeedbackList() throws Exception {
List<Feedback> feedbackList = Arrays.asList(new Feedback());
when(feedbackDao.getFeedbackList()).thenReturn(feedbackList);
mockMvc.perform(get("/feedback")).andExpect(status().isOk()).andExpect(model().attribute("feedbackList", feedbackList)).andExpect(view().name("feedback"));
}
@Test
public void testPostNewFeedback() throws Exception { | FeedbackFormData formData = new FeedbackFormData(); |
codecentric/conference-app | app/src/main/java/de/codecentric/controller/DeveloperController.java | // Path: app/src/main/java/de/codecentric/dao/DeveloperRepository.java
// @Repository
// public interface DeveloperRepository extends CrudRepository<Developer, Long> {
// }
| import java.util.Map;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import de.codecentric.dao.DeveloperRepository;
| package de.codecentric.controller;
@Controller
@RequestMapping("/developer")
public class DeveloperController {
private static final Logger LOGGER = Logger.getLogger(DeveloperController.class);
@Autowired
| // Path: app/src/main/java/de/codecentric/dao/DeveloperRepository.java
// @Repository
// public interface DeveloperRepository extends CrudRepository<Developer, Long> {
// }
// Path: app/src/main/java/de/codecentric/controller/DeveloperController.java
import java.util.Map;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import de.codecentric.dao.DeveloperRepository;
package de.codecentric.controller;
@Controller
@RequestMapping("/developer")
public class DeveloperController {
private static final Logger LOGGER = Logger.getLogger(DeveloperController.class);
@Autowired
| private DeveloperRepository repository;
|
codecentric/conference-app | app/src/main/java/de/codecentric/dao/impl/JpaNewsDao.java | // Path: app/src/main/java/de/codecentric/dao/NewsDao.java
// public interface NewsDao {
//
// List<News> getAllNews();
//
// void saveNews(News n);
// }
//
// Path: app/src/main/java/de/codecentric/domain/News.java
// @Entity(name = "news")
// @NamedQueries({ @NamedQuery(name = "findAllNews", query = "from news")})
// public class News {
//
// @Id
// @GeneratedValue(strategy = GenerationType.IDENTITY)
// private long id;
//
// @Column(length = 2048)
// private String text;
//
// public News() {
// // JPA default constructor
// }
//
// public String getText() {
// return text;
// }
//
// public void setText(String text) {
// this.text = text;
// }
// }
| import de.codecentric.dao.NewsDao;
import de.codecentric.domain.News;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import java.util.List; | package de.codecentric.dao.impl;
@Repository("newsDao")
@Transactional | // Path: app/src/main/java/de/codecentric/dao/NewsDao.java
// public interface NewsDao {
//
// List<News> getAllNews();
//
// void saveNews(News n);
// }
//
// Path: app/src/main/java/de/codecentric/domain/News.java
// @Entity(name = "news")
// @NamedQueries({ @NamedQuery(name = "findAllNews", query = "from news")})
// public class News {
//
// @Id
// @GeneratedValue(strategy = GenerationType.IDENTITY)
// private long id;
//
// @Column(length = 2048)
// private String text;
//
// public News() {
// // JPA default constructor
// }
//
// public String getText() {
// return text;
// }
//
// public void setText(String text) {
// this.text = text;
// }
// }
// Path: app/src/main/java/de/codecentric/dao/impl/JpaNewsDao.java
import de.codecentric.dao.NewsDao;
import de.codecentric.domain.News;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import java.util.List;
package de.codecentric.dao.impl;
@Repository("newsDao")
@Transactional | public class JpaNewsDao implements NewsDao { |
codecentric/conference-app | app/src/main/java/de/codecentric/dao/impl/JpaNewsDao.java | // Path: app/src/main/java/de/codecentric/dao/NewsDao.java
// public interface NewsDao {
//
// List<News> getAllNews();
//
// void saveNews(News n);
// }
//
// Path: app/src/main/java/de/codecentric/domain/News.java
// @Entity(name = "news")
// @NamedQueries({ @NamedQuery(name = "findAllNews", query = "from news")})
// public class News {
//
// @Id
// @GeneratedValue(strategy = GenerationType.IDENTITY)
// private long id;
//
// @Column(length = 2048)
// private String text;
//
// public News() {
// // JPA default constructor
// }
//
// public String getText() {
// return text;
// }
//
// public void setText(String text) {
// this.text = text;
// }
// }
| import de.codecentric.dao.NewsDao;
import de.codecentric.domain.News;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import java.util.List; | package de.codecentric.dao.impl;
@Repository("newsDao")
@Transactional
public class JpaNewsDao implements NewsDao {
@PersistenceContext
private EntityManager em;
public JpaNewsDao() {
// default constructor
}
// Test constructor
public JpaNewsDao(EntityManager em) {
this.em = em;
}
| // Path: app/src/main/java/de/codecentric/dao/NewsDao.java
// public interface NewsDao {
//
// List<News> getAllNews();
//
// void saveNews(News n);
// }
//
// Path: app/src/main/java/de/codecentric/domain/News.java
// @Entity(name = "news")
// @NamedQueries({ @NamedQuery(name = "findAllNews", query = "from news")})
// public class News {
//
// @Id
// @GeneratedValue(strategy = GenerationType.IDENTITY)
// private long id;
//
// @Column(length = 2048)
// private String text;
//
// public News() {
// // JPA default constructor
// }
//
// public String getText() {
// return text;
// }
//
// public void setText(String text) {
// this.text = text;
// }
// }
// Path: app/src/main/java/de/codecentric/dao/impl/JpaNewsDao.java
import de.codecentric.dao.NewsDao;
import de.codecentric.domain.News;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import java.util.List;
package de.codecentric.dao.impl;
@Repository("newsDao")
@Transactional
public class JpaNewsDao implements NewsDao {
@PersistenceContext
private EntityManager em;
public JpaNewsDao() {
// default constructor
}
// Test constructor
public JpaNewsDao(EntityManager em) {
this.em = em;
}
| @Override public List<News> getAllNews() { |
codecentric/conference-app | app/src/test/java/de/codecentric/domain/JpaSessionDaoTest.java | // Path: app/src/main/java/de/codecentric/dao/impl/JpaSessionDao.java
// @Repository("sessionDao")
// @Transactional
// public class JpaSessionDao implements SessionDao {
//
// @PersistenceContext
// private EntityManager em;
//
// public JpaSessionDao() {
// }
//
// // test constructor
// public JpaSessionDao(EntityManager em) {
// this.em = em;
// }
//
// public List<Session> getSessionsByDate(String date) {
// return em.createNamedQuery("findSessionsForDate", Session.class).setParameter("date", date).getResultList();
// }
//
// public List<Session> getAllSessions() {
// return em.createNamedQuery("findAllSessions", Session.class).getResultList();
// }
//
// public Session saveSession(Session session) {
// return em.merge(session);
// }
//
// public Session getSessionById(String id) {
// return em.find(Session.class, Integer.parseInt(id));
// }
//
// public List<Session> getAllStaticSessions() {
// return em.createNamedQuery("findAllStaticSessions", Session.class).getResultList();
// }
//
// public List<Session> getAllSessionsByDateAndType(String date, SessionType... type) {
// return em.createNamedQuery("findSessionsForDate", Session.class).setParameter("date", date).setParameter("type", Arrays.asList(type)).getResultList();
// }
//
// public List<Session> getStaticSessionsByDate(String date) {
// return em.createNamedQuery("findStaticSessionsForDate", Session.class).setParameter("date", date).getResultList();
// }
//
// public List<Session> getCurrentSessions() {
// List<Session> todaySessions = getStaticSessionsByDate(getNowAsString());
// List<Session> currentSessions = new ArrayList<Session>();
// for (Session session : todaySessions) {
// if (session.isInProgress(Calendar.getInstance())) {
// currentSessions.add(session);
// }
// }
//
// return currentSessions;
// }
//
// public List<Session> getAllCurrentSessions() {
// List<Session> todaySessions = getAllSessionsByDate(getNowAsString());
// List<Session> currentSessions = new ArrayList<Session>();
// for (Session session : todaySessions) {
// if (session.isInNearProgress(DateTime.now())) {
// currentSessions.add(session);
// }
// }
//
// return currentSessions;
// }
//
// String getNowAsString() {
// SimpleDateFormat format = new SimpleDateFormat("dd.MM.yyyy");
// return format.format(new Date());
// }
//
// @Override
// public List<String> getListOfConferenceDays() {
// return em.createNamedQuery("findListOfConferenceDays", String.class).getResultList();
// }
//
// @Override
// public List<Session> getAllSessionsByDate(String now) {
// return em.createNamedQuery("findAllSessionsForDate", Session.class).setParameter("date", now).getResultList();
// }
//
// @Override
// public List<Session> getAllSessionsByAuthor(String author) {
// return em.createNamedQuery("findAllSessionsForAuthor", Session.class).setParameter("author", "%" + author + "%").getResultList();
// }
//
// @SuppressWarnings("unchecked")
// @Override
// public List<Session> getAllSessionsByAuthorOrTitleOrDescription(String searchTerm){
// String searchTermLike = "%" + searchTerm + "%";
// org.hibernate.Session session = (org.hibernate.Session) em.getDelegate();
//
// Criteria criteria = session.createCriteria(Session.class)
// .add(
// Restrictions.or(
// Restrictions.like("author",searchTermLike),
// Restrictions.like("title", searchTermLike),
// Restrictions.like("description" , searchTermLike)
// )
// ).addOrder(Order.asc("date"));
// return (List<Session>)criteria.list();
// }
//
// }
| import static org.mockito.Mockito.verify;
import javax.persistence.EntityManager;
import org.junit.Before;
import org.junit.Test;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import de.codecentric.dao.impl.JpaSessionDao; | package de.codecentric.domain;
public class JpaSessionDaoTest {
@Mock
private EntityManager emMock;
| // Path: app/src/main/java/de/codecentric/dao/impl/JpaSessionDao.java
// @Repository("sessionDao")
// @Transactional
// public class JpaSessionDao implements SessionDao {
//
// @PersistenceContext
// private EntityManager em;
//
// public JpaSessionDao() {
// }
//
// // test constructor
// public JpaSessionDao(EntityManager em) {
// this.em = em;
// }
//
// public List<Session> getSessionsByDate(String date) {
// return em.createNamedQuery("findSessionsForDate", Session.class).setParameter("date", date).getResultList();
// }
//
// public List<Session> getAllSessions() {
// return em.createNamedQuery("findAllSessions", Session.class).getResultList();
// }
//
// public Session saveSession(Session session) {
// return em.merge(session);
// }
//
// public Session getSessionById(String id) {
// return em.find(Session.class, Integer.parseInt(id));
// }
//
// public List<Session> getAllStaticSessions() {
// return em.createNamedQuery("findAllStaticSessions", Session.class).getResultList();
// }
//
// public List<Session> getAllSessionsByDateAndType(String date, SessionType... type) {
// return em.createNamedQuery("findSessionsForDate", Session.class).setParameter("date", date).setParameter("type", Arrays.asList(type)).getResultList();
// }
//
// public List<Session> getStaticSessionsByDate(String date) {
// return em.createNamedQuery("findStaticSessionsForDate", Session.class).setParameter("date", date).getResultList();
// }
//
// public List<Session> getCurrentSessions() {
// List<Session> todaySessions = getStaticSessionsByDate(getNowAsString());
// List<Session> currentSessions = new ArrayList<Session>();
// for (Session session : todaySessions) {
// if (session.isInProgress(Calendar.getInstance())) {
// currentSessions.add(session);
// }
// }
//
// return currentSessions;
// }
//
// public List<Session> getAllCurrentSessions() {
// List<Session> todaySessions = getAllSessionsByDate(getNowAsString());
// List<Session> currentSessions = new ArrayList<Session>();
// for (Session session : todaySessions) {
// if (session.isInNearProgress(DateTime.now())) {
// currentSessions.add(session);
// }
// }
//
// return currentSessions;
// }
//
// String getNowAsString() {
// SimpleDateFormat format = new SimpleDateFormat("dd.MM.yyyy");
// return format.format(new Date());
// }
//
// @Override
// public List<String> getListOfConferenceDays() {
// return em.createNamedQuery("findListOfConferenceDays", String.class).getResultList();
// }
//
// @Override
// public List<Session> getAllSessionsByDate(String now) {
// return em.createNamedQuery("findAllSessionsForDate", Session.class).setParameter("date", now).getResultList();
// }
//
// @Override
// public List<Session> getAllSessionsByAuthor(String author) {
// return em.createNamedQuery("findAllSessionsForAuthor", Session.class).setParameter("author", "%" + author + "%").getResultList();
// }
//
// @SuppressWarnings("unchecked")
// @Override
// public List<Session> getAllSessionsByAuthorOrTitleOrDescription(String searchTerm){
// String searchTermLike = "%" + searchTerm + "%";
// org.hibernate.Session session = (org.hibernate.Session) em.getDelegate();
//
// Criteria criteria = session.createCriteria(Session.class)
// .add(
// Restrictions.or(
// Restrictions.like("author",searchTermLike),
// Restrictions.like("title", searchTermLike),
// Restrictions.like("description" , searchTermLike)
// )
// ).addOrder(Order.asc("date"));
// return (List<Session>)criteria.list();
// }
//
// }
// Path: app/src/test/java/de/codecentric/domain/JpaSessionDaoTest.java
import static org.mockito.Mockito.verify;
import javax.persistence.EntityManager;
import org.junit.Before;
import org.junit.Test;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import de.codecentric.dao.impl.JpaSessionDao;
package de.codecentric.domain;
public class JpaSessionDaoTest {
@Mock
private EntityManager emMock;
| private JpaSessionDao dao; |
shooash/XHFW3 | app/src/main/java/com/zst/xposed/halo/floatingwindow3/prefs/ColorPicker.java | // Path: app/src/main/java/com/zst/xposed/halo/floatingwindow3/prefs/colorpicker/ColorSettingsDialog.java
// public class ColorSettingsDialog extends AlertDialog implements
// ColorPickerView.OnColorChangedListener {
//
// private ColorPickerView mColorPicker;
//
// private ColorPanelView mOldColor;
// private ColorPanelView mNewColor;
// private EditText mHexColor;
// private Button mHexButton;
//
// private LayoutInflater mInflater;
// private OnColorChangedListener mListener;
//
// public ColorSettingsDialog(Context context, int initialColor, final String defColor) {
// super(context);
// getWindow().setFormat(PixelFormat.RGBA_8888);
// // To fight color banding.
// setUp(initialColor, defColor);
// }
//
// private void setUp(int color, final String defColor) {
// mInflater = (LayoutInflater) getContext()
// .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
//
// View layout = mInflater.inflate(R.layout.dialog_colorpicker, null);
//
// mColorPicker = (ColorPickerView) layout.findViewById(R.id.color_picker_view);
// mOldColor = (ColorPanelView) layout.findViewById(R.id.old_color_panel);
// mNewColor = (ColorPanelView) layout.findViewById(R.id.new_color_panel);
// mHexColor = (EditText) layout.findViewById(R.id.current_hex_text);
//
// mColorPicker.setOnColorChangedListener(this);
// mOldColor.setColor(color);
// mColorPicker.setColor(color, true);
//
// mHexButton = (Button) layout.findViewById(R.id.color_apply);
// mHexButton.setOnClickListener(new View.OnClickListener(){
// @Override
// public void onClick(View v) {
// try{
// int color = Color.parseColor("#" + mHexColor.getText().toString());
// mColorPicker.setColor(color);
// colorChange(color);
// }catch(Exception e){
// mHexColor.setText("FFFFFF");
// }
// }
// });
//
// setView(layout);
// }
//
// @Override
// public void onColorChanged(int color) {
// colorChange(color);
// }
//
// private void colorChange(int color){
// mNewColor.setColor(color);
// mHexColor.setText(Integer.toHexString(color).toUpperCase(Locale.ENGLISH).substring(2));
// if (mListener != null) {
// mListener.onColorChanged(color);
// }
// }
//
// public void setAlphaSliderVisible(boolean visible) {
// mColorPicker.setAlphaSliderVisible(visible);
// }
//
// public String getColorString() {
// return Integer.toHexString(mColorPicker.getColor());
// }
//
// public int getColor() {
// return mColorPicker.getColor();
// }
//
// }
| import android.view.View;
import android.widget.ImageView;
import com.zst.xposed.halo.floatingwindow3.R;
import com.zst.xposed.halo.floatingwindow3.prefs.colorpicker.ColorSettingsDialog;
import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.SharedPreferences;
import android.content.res.Resources;
import android.graphics.Color;
import android.preference.Preference;
import android.preference.Preference.OnPreferenceClickListener;
import android.util.AttributeSet; | /*
* Copyright (C) 2013 XuiMod
* Copyright (C) 2012 The CyanogenMod Project
*
* 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 com.zst.xposed.halo.floatingwindow3.prefs;
public class ColorPicker extends Preference implements OnPreferenceClickListener {
SharedPreferences mPref;
ImageView mColorBox;
Resources mRes;
String mDefaultColor;
public ColorPicker(Context context, AttributeSet attrs) {
super(context, attrs);
mDefaultColor = attrs.getAttributeValue(null, "defaultValue");
}
@Override
protected void onBindView(View view) {
super.onBindView(view);
mColorBox = (ImageView) view.findViewById(android.R.id.icon);
mPref = getPreferenceManager().getSharedPreferences();
mRes = getContext().getResources();
setOnPreferenceClickListener(this);
refreshColorBox();
}
@Override
public boolean onPreferenceClick(Preference arg0) { | // Path: app/src/main/java/com/zst/xposed/halo/floatingwindow3/prefs/colorpicker/ColorSettingsDialog.java
// public class ColorSettingsDialog extends AlertDialog implements
// ColorPickerView.OnColorChangedListener {
//
// private ColorPickerView mColorPicker;
//
// private ColorPanelView mOldColor;
// private ColorPanelView mNewColor;
// private EditText mHexColor;
// private Button mHexButton;
//
// private LayoutInflater mInflater;
// private OnColorChangedListener mListener;
//
// public ColorSettingsDialog(Context context, int initialColor, final String defColor) {
// super(context);
// getWindow().setFormat(PixelFormat.RGBA_8888);
// // To fight color banding.
// setUp(initialColor, defColor);
// }
//
// private void setUp(int color, final String defColor) {
// mInflater = (LayoutInflater) getContext()
// .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
//
// View layout = mInflater.inflate(R.layout.dialog_colorpicker, null);
//
// mColorPicker = (ColorPickerView) layout.findViewById(R.id.color_picker_view);
// mOldColor = (ColorPanelView) layout.findViewById(R.id.old_color_panel);
// mNewColor = (ColorPanelView) layout.findViewById(R.id.new_color_panel);
// mHexColor = (EditText) layout.findViewById(R.id.current_hex_text);
//
// mColorPicker.setOnColorChangedListener(this);
// mOldColor.setColor(color);
// mColorPicker.setColor(color, true);
//
// mHexButton = (Button) layout.findViewById(R.id.color_apply);
// mHexButton.setOnClickListener(new View.OnClickListener(){
// @Override
// public void onClick(View v) {
// try{
// int color = Color.parseColor("#" + mHexColor.getText().toString());
// mColorPicker.setColor(color);
// colorChange(color);
// }catch(Exception e){
// mHexColor.setText("FFFFFF");
// }
// }
// });
//
// setView(layout);
// }
//
// @Override
// public void onColorChanged(int color) {
// colorChange(color);
// }
//
// private void colorChange(int color){
// mNewColor.setColor(color);
// mHexColor.setText(Integer.toHexString(color).toUpperCase(Locale.ENGLISH).substring(2));
// if (mListener != null) {
// mListener.onColorChanged(color);
// }
// }
//
// public void setAlphaSliderVisible(boolean visible) {
// mColorPicker.setAlphaSliderVisible(visible);
// }
//
// public String getColorString() {
// return Integer.toHexString(mColorPicker.getColor());
// }
//
// public int getColor() {
// return mColorPicker.getColor();
// }
//
// }
// Path: app/src/main/java/com/zst/xposed/halo/floatingwindow3/prefs/ColorPicker.java
import android.view.View;
import android.widget.ImageView;
import com.zst.xposed.halo.floatingwindow3.R;
import com.zst.xposed.halo.floatingwindow3.prefs.colorpicker.ColorSettingsDialog;
import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.SharedPreferences;
import android.content.res.Resources;
import android.graphics.Color;
import android.preference.Preference;
import android.preference.Preference.OnPreferenceClickListener;
import android.util.AttributeSet;
/*
* Copyright (C) 2013 XuiMod
* Copyright (C) 2012 The CyanogenMod Project
*
* 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 com.zst.xposed.halo.floatingwindow3.prefs;
public class ColorPicker extends Preference implements OnPreferenceClickListener {
SharedPreferences mPref;
ImageView mColorBox;
Resources mRes;
String mDefaultColor;
public ColorPicker(Context context, AttributeSet attrs) {
super(context, attrs);
mDefaultColor = attrs.getAttributeValue(null, "defaultValue");
}
@Override
protected void onBindView(View view) {
super.onBindView(view);
mColorBox = (ImageView) view.findViewById(android.R.id.icon);
mPref = getPreferenceManager().getSharedPreferences();
mRes = getContext().getResources();
setOnPreferenceClickListener(this);
refreshColorBox();
}
@Override
public boolean onPreferenceClick(Preference arg0) { | final ColorSettingsDialog d = new ColorSettingsDialog(getContext(), getColor(), mDefaultColor); |
kimkevin/AndroidStarterKit | ask-remote-module/src/main/java/com/androidstarterkit/module/ui/adapter/RecyclerViewAdapter.java | // Path: ask-remote-module/src/main/java/com/androidstarterkit/module/data/AndroidPlatform.java
// public class AndroidPlatform {
// private static final String FILE_PATH = "https://raw.githubusercontent.com/kimkevin/AndroidStarterKit/master/assets/";
// private static final String EXTENSION_NAME = ".png";
//
// private String name;
// private String verCode;
// private int apiLevel;
// private String logoUrl;
//
// public AndroidPlatform(String name, String verCode, int apiLevel) {
// this.name = name;
// this.verCode = verCode;
// this.apiLevel = apiLevel;
// this.logoUrl = FILE_PATH + name + EXTENSION_NAME;
// }
//
// public String getName() {
// return name.toUpperCase() + " " + apiLevel;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getVerCode() {
// return "Android " + verCode;
// }
//
// public void setVerCode(String version) {
// this.verCode = version;
// }
//
// public int getApiLevel() {
// return apiLevel;
// }
//
// public void setApiLevel(int apiLevel) {
// this.apiLevel = apiLevel;
// }
//
// public String getLogoUrl() {
// return logoUrl;
// }
//
// public void setLogoUrl(String logoUrl) {
// this.logoUrl = logoUrl;
// }
// }
| import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;
import com.androidstarterkit.module.data.AndroidPlatform;
import com.androidstarterkit.module.R;
import com.bumptech.glide.Glide;
import java.util.List; | package com.androidstarterkit.module.ui.adapter;
public class RecyclerViewAdapter extends RecyclerView.Adapter<RecyclerViewAdapter.ViewHolder> {
private Context context; | // Path: ask-remote-module/src/main/java/com/androidstarterkit/module/data/AndroidPlatform.java
// public class AndroidPlatform {
// private static final String FILE_PATH = "https://raw.githubusercontent.com/kimkevin/AndroidStarterKit/master/assets/";
// private static final String EXTENSION_NAME = ".png";
//
// private String name;
// private String verCode;
// private int apiLevel;
// private String logoUrl;
//
// public AndroidPlatform(String name, String verCode, int apiLevel) {
// this.name = name;
// this.verCode = verCode;
// this.apiLevel = apiLevel;
// this.logoUrl = FILE_PATH + name + EXTENSION_NAME;
// }
//
// public String getName() {
// return name.toUpperCase() + " " + apiLevel;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getVerCode() {
// return "Android " + verCode;
// }
//
// public void setVerCode(String version) {
// this.verCode = version;
// }
//
// public int getApiLevel() {
// return apiLevel;
// }
//
// public void setApiLevel(int apiLevel) {
// this.apiLevel = apiLevel;
// }
//
// public String getLogoUrl() {
// return logoUrl;
// }
//
// public void setLogoUrl(String logoUrl) {
// this.logoUrl = logoUrl;
// }
// }
// Path: ask-remote-module/src/main/java/com/androidstarterkit/module/ui/adapter/RecyclerViewAdapter.java
import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;
import com.androidstarterkit.module.data.AndroidPlatform;
import com.androidstarterkit.module.R;
import com.bumptech.glide.Glide;
import java.util.List;
package com.androidstarterkit.module.ui.adapter;
public class RecyclerViewAdapter extends RecyclerView.Adapter<RecyclerViewAdapter.ViewHolder> {
private Context context; | private List<AndroidPlatform> platforms; |
kimkevin/AndroidStarterKit | ask-remote-module/src/main/java/com/androidstarterkit/module/sample/activity/ScrollViewActivity.java | // Path: ask-remote-module/src/main/java/com/androidstarterkit/module/ui/view/ScrollViewFragment.java
// public class ScrollViewFragment extends Fragment {
// private static final String ARG_POSITION = "position";
//
// public static ScrollViewFragment newInstance(int position) {
// ScrollViewFragment fragment = new ScrollViewFragment();
// Bundle args = new Bundle();
// args.putInt(ARG_POSITION, position);
// fragment.setArguments(args);
// return fragment;
// }
//
// @Override
// public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
// View view = inflater.inflate(R.layout.fragment_main, null);
// TextView posTxt = (TextView) view.findViewById(R.id.pos_txt);
// posTxt.setText("Hello, this's a ScrollView");
// return view;
// }
// }
| import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import com.androidstarterkit.module.R;
import com.androidstarterkit.module.ui.view.ScrollViewFragment; | package com.androidstarterkit.module.sample.activity;
public class ScrollViewActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_sample_main);
if (savedInstanceState == null) {
getSupportFragmentManager()
.beginTransaction() | // Path: ask-remote-module/src/main/java/com/androidstarterkit/module/ui/view/ScrollViewFragment.java
// public class ScrollViewFragment extends Fragment {
// private static final String ARG_POSITION = "position";
//
// public static ScrollViewFragment newInstance(int position) {
// ScrollViewFragment fragment = new ScrollViewFragment();
// Bundle args = new Bundle();
// args.putInt(ARG_POSITION, position);
// fragment.setArguments(args);
// return fragment;
// }
//
// @Override
// public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
// View view = inflater.inflate(R.layout.fragment_main, null);
// TextView posTxt = (TextView) view.findViewById(R.id.pos_txt);
// posTxt.setText("Hello, this's a ScrollView");
// return view;
// }
// }
// Path: ask-remote-module/src/main/java/com/androidstarterkit/module/sample/activity/ScrollViewActivity.java
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import com.androidstarterkit.module.R;
import com.androidstarterkit.module.ui.view.ScrollViewFragment;
package com.androidstarterkit.module.sample.activity;
public class ScrollViewActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_sample_main);
if (savedInstanceState == null) {
getSupportFragmentManager()
.beginTransaction() | .add(R.id.container, new ScrollViewFragment()) |
kimkevin/AndroidStarterKit | ask-remote-module/src/main/java/com/androidstarterkit/module/ui/adapter/MainBaseAdapter.java | // Path: ask-remote-module/src/main/java/com/androidstarterkit/module/sample/activity/GridViewActivity.java
// public class GridViewActivity extends AppCompatActivity {
// @Override
// protected void onCreate(Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
//
// setContentView(R.layout.activity_sample_main);
//
// if (savedInstanceState == null) {
// getSupportFragmentManager()
// .beginTransaction()
// .add(R.id.container, new GridViewFragment())
// .commit();
// }
// }
// }
//
// Path: ask-remote-module/src/main/java/com/androidstarterkit/module/sample/activity/ListViewActivity.java
// public class ListViewActivity extends AppCompatActivity{
// @Override
// protected void onCreate(Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
//
// setContentView(R.layout.activity_sample_main);
//
// if (savedInstanceState == null) {
// getSupportFragmentManager()
// .beginTransaction()
// .add(R.id.container, new ListViewFragment())
// .commit();
// }
// }
// }
//
// Path: ask-remote-module/src/main/java/com/androidstarterkit/module/sample/activity/RecyclerViewActivity.java
// public class RecyclerViewActivity extends AppCompatActivity {
// @Override
// protected void onCreate(Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
//
// setContentView(R.layout.activity_sample_main);
//
// if (savedInstanceState == null) {
// getSupportFragmentManager()
// .beginTransaction()
// .add(R.id.container, new RecyclerViewFragment())
// .commit();
// }
// }
// }
//
// Path: ask-remote-module/src/main/java/com/androidstarterkit/module/sample/activity/ScrollViewActivity.java
// public class ScrollViewActivity extends AppCompatActivity {
//
// @Override
// protected void onCreate(Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
//
// setContentView(R.layout.activity_sample_main);
//
// if (savedInstanceState == null) {
// getSupportFragmentManager()
// .beginTransaction()
// .add(R.id.container, new ScrollViewFragment())
// .commit();
// }
// }
// }
//
// Path: ask-remote-module/src/main/java/com/androidstarterkit/module/sample/activity/SlidingIconTabActivity.java
// public class SlidingIconTabActivity extends AppCompatActivity {
//
// @Override
// protected void onCreate(Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
//
// getSupportActionBar().setElevation(0);
// setContentView(R.layout.activity_sample_main);
//
// if (savedInstanceState == null) {
// getSupportFragmentManager()
// .beginTransaction()
// .add(R.id.container, new SlidingIconTabFragment())
// .commit();
// }
// }
// }
//
// Path: ask-remote-module/src/main/java/com/androidstarterkit/module/sample/activity/SlidingTabActivity.java
// public class SlidingTabActivity extends AppCompatActivity {
//
// @Override
// protected void onCreate(Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
//
// getSupportActionBar().setElevation(0);
// setContentView(R.layout.activity_sample_main);
//
// if (savedInstanceState == null) {
// getSupportFragmentManager()
// .beginTransaction()
// .add(R.id.container, new SlidingTabFragment())
// .commit();
// }
// }
// }
//
// Path: ask-remote-module/src/main/java/com/androidstarterkit/module/sample/SampleType.java
// public enum SampleType {
// ScrollView, GridView, RecyclerView, ListView, SlidingTabLayout, SlidingIconTabLayout
// }
| import android.content.Context;
import android.content.Intent;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;
import com.androidstarterkit.module.sample.activity.GridViewActivity;
import com.androidstarterkit.module.sample.activity.ListViewActivity;
import com.androidstarterkit.module.R;
import com.androidstarterkit.module.sample.activity.RecyclerViewActivity;
import com.androidstarterkit.module.sample.activity.ScrollViewActivity;
import com.androidstarterkit.module.sample.activity.SlidingIconTabActivity;
import com.androidstarterkit.module.sample.activity.SlidingTabActivity;
import com.androidstarterkit.module.sample.SampleType;
import java.util.List; | package com.androidstarterkit.module.ui.adapter;
public class MainBaseAdapter extends BaseAdapter {
private Context context; | // Path: ask-remote-module/src/main/java/com/androidstarterkit/module/sample/activity/GridViewActivity.java
// public class GridViewActivity extends AppCompatActivity {
// @Override
// protected void onCreate(Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
//
// setContentView(R.layout.activity_sample_main);
//
// if (savedInstanceState == null) {
// getSupportFragmentManager()
// .beginTransaction()
// .add(R.id.container, new GridViewFragment())
// .commit();
// }
// }
// }
//
// Path: ask-remote-module/src/main/java/com/androidstarterkit/module/sample/activity/ListViewActivity.java
// public class ListViewActivity extends AppCompatActivity{
// @Override
// protected void onCreate(Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
//
// setContentView(R.layout.activity_sample_main);
//
// if (savedInstanceState == null) {
// getSupportFragmentManager()
// .beginTransaction()
// .add(R.id.container, new ListViewFragment())
// .commit();
// }
// }
// }
//
// Path: ask-remote-module/src/main/java/com/androidstarterkit/module/sample/activity/RecyclerViewActivity.java
// public class RecyclerViewActivity extends AppCompatActivity {
// @Override
// protected void onCreate(Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
//
// setContentView(R.layout.activity_sample_main);
//
// if (savedInstanceState == null) {
// getSupportFragmentManager()
// .beginTransaction()
// .add(R.id.container, new RecyclerViewFragment())
// .commit();
// }
// }
// }
//
// Path: ask-remote-module/src/main/java/com/androidstarterkit/module/sample/activity/ScrollViewActivity.java
// public class ScrollViewActivity extends AppCompatActivity {
//
// @Override
// protected void onCreate(Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
//
// setContentView(R.layout.activity_sample_main);
//
// if (savedInstanceState == null) {
// getSupportFragmentManager()
// .beginTransaction()
// .add(R.id.container, new ScrollViewFragment())
// .commit();
// }
// }
// }
//
// Path: ask-remote-module/src/main/java/com/androidstarterkit/module/sample/activity/SlidingIconTabActivity.java
// public class SlidingIconTabActivity extends AppCompatActivity {
//
// @Override
// protected void onCreate(Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
//
// getSupportActionBar().setElevation(0);
// setContentView(R.layout.activity_sample_main);
//
// if (savedInstanceState == null) {
// getSupportFragmentManager()
// .beginTransaction()
// .add(R.id.container, new SlidingIconTabFragment())
// .commit();
// }
// }
// }
//
// Path: ask-remote-module/src/main/java/com/androidstarterkit/module/sample/activity/SlidingTabActivity.java
// public class SlidingTabActivity extends AppCompatActivity {
//
// @Override
// protected void onCreate(Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
//
// getSupportActionBar().setElevation(0);
// setContentView(R.layout.activity_sample_main);
//
// if (savedInstanceState == null) {
// getSupportFragmentManager()
// .beginTransaction()
// .add(R.id.container, new SlidingTabFragment())
// .commit();
// }
// }
// }
//
// Path: ask-remote-module/src/main/java/com/androidstarterkit/module/sample/SampleType.java
// public enum SampleType {
// ScrollView, GridView, RecyclerView, ListView, SlidingTabLayout, SlidingIconTabLayout
// }
// Path: ask-remote-module/src/main/java/com/androidstarterkit/module/ui/adapter/MainBaseAdapter.java
import android.content.Context;
import android.content.Intent;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;
import com.androidstarterkit.module.sample.activity.GridViewActivity;
import com.androidstarterkit.module.sample.activity.ListViewActivity;
import com.androidstarterkit.module.R;
import com.androidstarterkit.module.sample.activity.RecyclerViewActivity;
import com.androidstarterkit.module.sample.activity.ScrollViewActivity;
import com.androidstarterkit.module.sample.activity.SlidingIconTabActivity;
import com.androidstarterkit.module.sample.activity.SlidingTabActivity;
import com.androidstarterkit.module.sample.SampleType;
import java.util.List;
package com.androidstarterkit.module.ui.adapter;
public class MainBaseAdapter extends BaseAdapter {
private Context context; | private List<SampleType> dataSet; |
kimkevin/AndroidStarterKit | ask-remote-module/src/main/java/com/androidstarterkit/module/ui/adapter/MainBaseAdapter.java | // Path: ask-remote-module/src/main/java/com/androidstarterkit/module/sample/activity/GridViewActivity.java
// public class GridViewActivity extends AppCompatActivity {
// @Override
// protected void onCreate(Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
//
// setContentView(R.layout.activity_sample_main);
//
// if (savedInstanceState == null) {
// getSupportFragmentManager()
// .beginTransaction()
// .add(R.id.container, new GridViewFragment())
// .commit();
// }
// }
// }
//
// Path: ask-remote-module/src/main/java/com/androidstarterkit/module/sample/activity/ListViewActivity.java
// public class ListViewActivity extends AppCompatActivity{
// @Override
// protected void onCreate(Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
//
// setContentView(R.layout.activity_sample_main);
//
// if (savedInstanceState == null) {
// getSupportFragmentManager()
// .beginTransaction()
// .add(R.id.container, new ListViewFragment())
// .commit();
// }
// }
// }
//
// Path: ask-remote-module/src/main/java/com/androidstarterkit/module/sample/activity/RecyclerViewActivity.java
// public class RecyclerViewActivity extends AppCompatActivity {
// @Override
// protected void onCreate(Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
//
// setContentView(R.layout.activity_sample_main);
//
// if (savedInstanceState == null) {
// getSupportFragmentManager()
// .beginTransaction()
// .add(R.id.container, new RecyclerViewFragment())
// .commit();
// }
// }
// }
//
// Path: ask-remote-module/src/main/java/com/androidstarterkit/module/sample/activity/ScrollViewActivity.java
// public class ScrollViewActivity extends AppCompatActivity {
//
// @Override
// protected void onCreate(Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
//
// setContentView(R.layout.activity_sample_main);
//
// if (savedInstanceState == null) {
// getSupportFragmentManager()
// .beginTransaction()
// .add(R.id.container, new ScrollViewFragment())
// .commit();
// }
// }
// }
//
// Path: ask-remote-module/src/main/java/com/androidstarterkit/module/sample/activity/SlidingIconTabActivity.java
// public class SlidingIconTabActivity extends AppCompatActivity {
//
// @Override
// protected void onCreate(Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
//
// getSupportActionBar().setElevation(0);
// setContentView(R.layout.activity_sample_main);
//
// if (savedInstanceState == null) {
// getSupportFragmentManager()
// .beginTransaction()
// .add(R.id.container, new SlidingIconTabFragment())
// .commit();
// }
// }
// }
//
// Path: ask-remote-module/src/main/java/com/androidstarterkit/module/sample/activity/SlidingTabActivity.java
// public class SlidingTabActivity extends AppCompatActivity {
//
// @Override
// protected void onCreate(Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
//
// getSupportActionBar().setElevation(0);
// setContentView(R.layout.activity_sample_main);
//
// if (savedInstanceState == null) {
// getSupportFragmentManager()
// .beginTransaction()
// .add(R.id.container, new SlidingTabFragment())
// .commit();
// }
// }
// }
//
// Path: ask-remote-module/src/main/java/com/androidstarterkit/module/sample/SampleType.java
// public enum SampleType {
// ScrollView, GridView, RecyclerView, ListView, SlidingTabLayout, SlidingIconTabLayout
// }
| import android.content.Context;
import android.content.Intent;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;
import com.androidstarterkit.module.sample.activity.GridViewActivity;
import com.androidstarterkit.module.sample.activity.ListViewActivity;
import com.androidstarterkit.module.R;
import com.androidstarterkit.module.sample.activity.RecyclerViewActivity;
import com.androidstarterkit.module.sample.activity.ScrollViewActivity;
import com.androidstarterkit.module.sample.activity.SlidingIconTabActivity;
import com.androidstarterkit.module.sample.activity.SlidingTabActivity;
import com.androidstarterkit.module.sample.SampleType;
import java.util.List; |
@Override
public long getItemId(int position) {
return 0;
}
@Override
public View getView(final int position, View convertView, ViewGroup parent) {
ViewHolder viewHolder;
if (convertView == null) {
convertView = inflater.inflate(R.layout.layout_main_list_item, parent, false);
viewHolder = new ViewHolder();
viewHolder.title= (TextView) convertView.findViewById(R.id.title);
convertView.setTag(viewHolder);
} else {
viewHolder = (ViewHolder) convertView.getTag();
}
viewHolder.title.setText(dataSet.get(position).name());
convertView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
SampleType sampleType = dataSet.get(position);
Intent intent = null;
switch (sampleType) {
case ScrollView: | // Path: ask-remote-module/src/main/java/com/androidstarterkit/module/sample/activity/GridViewActivity.java
// public class GridViewActivity extends AppCompatActivity {
// @Override
// protected void onCreate(Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
//
// setContentView(R.layout.activity_sample_main);
//
// if (savedInstanceState == null) {
// getSupportFragmentManager()
// .beginTransaction()
// .add(R.id.container, new GridViewFragment())
// .commit();
// }
// }
// }
//
// Path: ask-remote-module/src/main/java/com/androidstarterkit/module/sample/activity/ListViewActivity.java
// public class ListViewActivity extends AppCompatActivity{
// @Override
// protected void onCreate(Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
//
// setContentView(R.layout.activity_sample_main);
//
// if (savedInstanceState == null) {
// getSupportFragmentManager()
// .beginTransaction()
// .add(R.id.container, new ListViewFragment())
// .commit();
// }
// }
// }
//
// Path: ask-remote-module/src/main/java/com/androidstarterkit/module/sample/activity/RecyclerViewActivity.java
// public class RecyclerViewActivity extends AppCompatActivity {
// @Override
// protected void onCreate(Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
//
// setContentView(R.layout.activity_sample_main);
//
// if (savedInstanceState == null) {
// getSupportFragmentManager()
// .beginTransaction()
// .add(R.id.container, new RecyclerViewFragment())
// .commit();
// }
// }
// }
//
// Path: ask-remote-module/src/main/java/com/androidstarterkit/module/sample/activity/ScrollViewActivity.java
// public class ScrollViewActivity extends AppCompatActivity {
//
// @Override
// protected void onCreate(Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
//
// setContentView(R.layout.activity_sample_main);
//
// if (savedInstanceState == null) {
// getSupportFragmentManager()
// .beginTransaction()
// .add(R.id.container, new ScrollViewFragment())
// .commit();
// }
// }
// }
//
// Path: ask-remote-module/src/main/java/com/androidstarterkit/module/sample/activity/SlidingIconTabActivity.java
// public class SlidingIconTabActivity extends AppCompatActivity {
//
// @Override
// protected void onCreate(Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
//
// getSupportActionBar().setElevation(0);
// setContentView(R.layout.activity_sample_main);
//
// if (savedInstanceState == null) {
// getSupportFragmentManager()
// .beginTransaction()
// .add(R.id.container, new SlidingIconTabFragment())
// .commit();
// }
// }
// }
//
// Path: ask-remote-module/src/main/java/com/androidstarterkit/module/sample/activity/SlidingTabActivity.java
// public class SlidingTabActivity extends AppCompatActivity {
//
// @Override
// protected void onCreate(Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
//
// getSupportActionBar().setElevation(0);
// setContentView(R.layout.activity_sample_main);
//
// if (savedInstanceState == null) {
// getSupportFragmentManager()
// .beginTransaction()
// .add(R.id.container, new SlidingTabFragment())
// .commit();
// }
// }
// }
//
// Path: ask-remote-module/src/main/java/com/androidstarterkit/module/sample/SampleType.java
// public enum SampleType {
// ScrollView, GridView, RecyclerView, ListView, SlidingTabLayout, SlidingIconTabLayout
// }
// Path: ask-remote-module/src/main/java/com/androidstarterkit/module/ui/adapter/MainBaseAdapter.java
import android.content.Context;
import android.content.Intent;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;
import com.androidstarterkit.module.sample.activity.GridViewActivity;
import com.androidstarterkit.module.sample.activity.ListViewActivity;
import com.androidstarterkit.module.R;
import com.androidstarterkit.module.sample.activity.RecyclerViewActivity;
import com.androidstarterkit.module.sample.activity.ScrollViewActivity;
import com.androidstarterkit.module.sample.activity.SlidingIconTabActivity;
import com.androidstarterkit.module.sample.activity.SlidingTabActivity;
import com.androidstarterkit.module.sample.SampleType;
import java.util.List;
@Override
public long getItemId(int position) {
return 0;
}
@Override
public View getView(final int position, View convertView, ViewGroup parent) {
ViewHolder viewHolder;
if (convertView == null) {
convertView = inflater.inflate(R.layout.layout_main_list_item, parent, false);
viewHolder = new ViewHolder();
viewHolder.title= (TextView) convertView.findViewById(R.id.title);
convertView.setTag(viewHolder);
} else {
viewHolder = (ViewHolder) convertView.getTag();
}
viewHolder.title.setText(dataSet.get(position).name());
convertView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
SampleType sampleType = dataSet.get(position);
Intent intent = null;
switch (sampleType) {
case ScrollView: | intent = new Intent(context, ScrollViewActivity.class); |
kimkevin/AndroidStarterKit | ask-remote-module/src/main/java/com/androidstarterkit/module/ui/adapter/MainBaseAdapter.java | // Path: ask-remote-module/src/main/java/com/androidstarterkit/module/sample/activity/GridViewActivity.java
// public class GridViewActivity extends AppCompatActivity {
// @Override
// protected void onCreate(Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
//
// setContentView(R.layout.activity_sample_main);
//
// if (savedInstanceState == null) {
// getSupportFragmentManager()
// .beginTransaction()
// .add(R.id.container, new GridViewFragment())
// .commit();
// }
// }
// }
//
// Path: ask-remote-module/src/main/java/com/androidstarterkit/module/sample/activity/ListViewActivity.java
// public class ListViewActivity extends AppCompatActivity{
// @Override
// protected void onCreate(Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
//
// setContentView(R.layout.activity_sample_main);
//
// if (savedInstanceState == null) {
// getSupportFragmentManager()
// .beginTransaction()
// .add(R.id.container, new ListViewFragment())
// .commit();
// }
// }
// }
//
// Path: ask-remote-module/src/main/java/com/androidstarterkit/module/sample/activity/RecyclerViewActivity.java
// public class RecyclerViewActivity extends AppCompatActivity {
// @Override
// protected void onCreate(Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
//
// setContentView(R.layout.activity_sample_main);
//
// if (savedInstanceState == null) {
// getSupportFragmentManager()
// .beginTransaction()
// .add(R.id.container, new RecyclerViewFragment())
// .commit();
// }
// }
// }
//
// Path: ask-remote-module/src/main/java/com/androidstarterkit/module/sample/activity/ScrollViewActivity.java
// public class ScrollViewActivity extends AppCompatActivity {
//
// @Override
// protected void onCreate(Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
//
// setContentView(R.layout.activity_sample_main);
//
// if (savedInstanceState == null) {
// getSupportFragmentManager()
// .beginTransaction()
// .add(R.id.container, new ScrollViewFragment())
// .commit();
// }
// }
// }
//
// Path: ask-remote-module/src/main/java/com/androidstarterkit/module/sample/activity/SlidingIconTabActivity.java
// public class SlidingIconTabActivity extends AppCompatActivity {
//
// @Override
// protected void onCreate(Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
//
// getSupportActionBar().setElevation(0);
// setContentView(R.layout.activity_sample_main);
//
// if (savedInstanceState == null) {
// getSupportFragmentManager()
// .beginTransaction()
// .add(R.id.container, new SlidingIconTabFragment())
// .commit();
// }
// }
// }
//
// Path: ask-remote-module/src/main/java/com/androidstarterkit/module/sample/activity/SlidingTabActivity.java
// public class SlidingTabActivity extends AppCompatActivity {
//
// @Override
// protected void onCreate(Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
//
// getSupportActionBar().setElevation(0);
// setContentView(R.layout.activity_sample_main);
//
// if (savedInstanceState == null) {
// getSupportFragmentManager()
// .beginTransaction()
// .add(R.id.container, new SlidingTabFragment())
// .commit();
// }
// }
// }
//
// Path: ask-remote-module/src/main/java/com/androidstarterkit/module/sample/SampleType.java
// public enum SampleType {
// ScrollView, GridView, RecyclerView, ListView, SlidingTabLayout, SlidingIconTabLayout
// }
| import android.content.Context;
import android.content.Intent;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;
import com.androidstarterkit.module.sample.activity.GridViewActivity;
import com.androidstarterkit.module.sample.activity.ListViewActivity;
import com.androidstarterkit.module.R;
import com.androidstarterkit.module.sample.activity.RecyclerViewActivity;
import com.androidstarterkit.module.sample.activity.ScrollViewActivity;
import com.androidstarterkit.module.sample.activity.SlidingIconTabActivity;
import com.androidstarterkit.module.sample.activity.SlidingTabActivity;
import com.androidstarterkit.module.sample.SampleType;
import java.util.List; | return 0;
}
@Override
public View getView(final int position, View convertView, ViewGroup parent) {
ViewHolder viewHolder;
if (convertView == null) {
convertView = inflater.inflate(R.layout.layout_main_list_item, parent, false);
viewHolder = new ViewHolder();
viewHolder.title= (TextView) convertView.findViewById(R.id.title);
convertView.setTag(viewHolder);
} else {
viewHolder = (ViewHolder) convertView.getTag();
}
viewHolder.title.setText(dataSet.get(position).name());
convertView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
SampleType sampleType = dataSet.get(position);
Intent intent = null;
switch (sampleType) {
case ScrollView:
intent = new Intent(context, ScrollViewActivity.class);
break;
case GridView: | // Path: ask-remote-module/src/main/java/com/androidstarterkit/module/sample/activity/GridViewActivity.java
// public class GridViewActivity extends AppCompatActivity {
// @Override
// protected void onCreate(Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
//
// setContentView(R.layout.activity_sample_main);
//
// if (savedInstanceState == null) {
// getSupportFragmentManager()
// .beginTransaction()
// .add(R.id.container, new GridViewFragment())
// .commit();
// }
// }
// }
//
// Path: ask-remote-module/src/main/java/com/androidstarterkit/module/sample/activity/ListViewActivity.java
// public class ListViewActivity extends AppCompatActivity{
// @Override
// protected void onCreate(Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
//
// setContentView(R.layout.activity_sample_main);
//
// if (savedInstanceState == null) {
// getSupportFragmentManager()
// .beginTransaction()
// .add(R.id.container, new ListViewFragment())
// .commit();
// }
// }
// }
//
// Path: ask-remote-module/src/main/java/com/androidstarterkit/module/sample/activity/RecyclerViewActivity.java
// public class RecyclerViewActivity extends AppCompatActivity {
// @Override
// protected void onCreate(Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
//
// setContentView(R.layout.activity_sample_main);
//
// if (savedInstanceState == null) {
// getSupportFragmentManager()
// .beginTransaction()
// .add(R.id.container, new RecyclerViewFragment())
// .commit();
// }
// }
// }
//
// Path: ask-remote-module/src/main/java/com/androidstarterkit/module/sample/activity/ScrollViewActivity.java
// public class ScrollViewActivity extends AppCompatActivity {
//
// @Override
// protected void onCreate(Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
//
// setContentView(R.layout.activity_sample_main);
//
// if (savedInstanceState == null) {
// getSupportFragmentManager()
// .beginTransaction()
// .add(R.id.container, new ScrollViewFragment())
// .commit();
// }
// }
// }
//
// Path: ask-remote-module/src/main/java/com/androidstarterkit/module/sample/activity/SlidingIconTabActivity.java
// public class SlidingIconTabActivity extends AppCompatActivity {
//
// @Override
// protected void onCreate(Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
//
// getSupportActionBar().setElevation(0);
// setContentView(R.layout.activity_sample_main);
//
// if (savedInstanceState == null) {
// getSupportFragmentManager()
// .beginTransaction()
// .add(R.id.container, new SlidingIconTabFragment())
// .commit();
// }
// }
// }
//
// Path: ask-remote-module/src/main/java/com/androidstarterkit/module/sample/activity/SlidingTabActivity.java
// public class SlidingTabActivity extends AppCompatActivity {
//
// @Override
// protected void onCreate(Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
//
// getSupportActionBar().setElevation(0);
// setContentView(R.layout.activity_sample_main);
//
// if (savedInstanceState == null) {
// getSupportFragmentManager()
// .beginTransaction()
// .add(R.id.container, new SlidingTabFragment())
// .commit();
// }
// }
// }
//
// Path: ask-remote-module/src/main/java/com/androidstarterkit/module/sample/SampleType.java
// public enum SampleType {
// ScrollView, GridView, RecyclerView, ListView, SlidingTabLayout, SlidingIconTabLayout
// }
// Path: ask-remote-module/src/main/java/com/androidstarterkit/module/ui/adapter/MainBaseAdapter.java
import android.content.Context;
import android.content.Intent;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;
import com.androidstarterkit.module.sample.activity.GridViewActivity;
import com.androidstarterkit.module.sample.activity.ListViewActivity;
import com.androidstarterkit.module.R;
import com.androidstarterkit.module.sample.activity.RecyclerViewActivity;
import com.androidstarterkit.module.sample.activity.ScrollViewActivity;
import com.androidstarterkit.module.sample.activity.SlidingIconTabActivity;
import com.androidstarterkit.module.sample.activity.SlidingTabActivity;
import com.androidstarterkit.module.sample.SampleType;
import java.util.List;
return 0;
}
@Override
public View getView(final int position, View convertView, ViewGroup parent) {
ViewHolder viewHolder;
if (convertView == null) {
convertView = inflater.inflate(R.layout.layout_main_list_item, parent, false);
viewHolder = new ViewHolder();
viewHolder.title= (TextView) convertView.findViewById(R.id.title);
convertView.setTag(viewHolder);
} else {
viewHolder = (ViewHolder) convertView.getTag();
}
viewHolder.title.setText(dataSet.get(position).name());
convertView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
SampleType sampleType = dataSet.get(position);
Intent intent = null;
switch (sampleType) {
case ScrollView:
intent = new Intent(context, ScrollViewActivity.class);
break;
case GridView: | intent = new Intent(context, GridViewActivity.class); |
kimkevin/AndroidStarterKit | ask-remote-module/src/main/java/com/androidstarterkit/module/ui/adapter/MainBaseAdapter.java | // Path: ask-remote-module/src/main/java/com/androidstarterkit/module/sample/activity/GridViewActivity.java
// public class GridViewActivity extends AppCompatActivity {
// @Override
// protected void onCreate(Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
//
// setContentView(R.layout.activity_sample_main);
//
// if (savedInstanceState == null) {
// getSupportFragmentManager()
// .beginTransaction()
// .add(R.id.container, new GridViewFragment())
// .commit();
// }
// }
// }
//
// Path: ask-remote-module/src/main/java/com/androidstarterkit/module/sample/activity/ListViewActivity.java
// public class ListViewActivity extends AppCompatActivity{
// @Override
// protected void onCreate(Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
//
// setContentView(R.layout.activity_sample_main);
//
// if (savedInstanceState == null) {
// getSupportFragmentManager()
// .beginTransaction()
// .add(R.id.container, new ListViewFragment())
// .commit();
// }
// }
// }
//
// Path: ask-remote-module/src/main/java/com/androidstarterkit/module/sample/activity/RecyclerViewActivity.java
// public class RecyclerViewActivity extends AppCompatActivity {
// @Override
// protected void onCreate(Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
//
// setContentView(R.layout.activity_sample_main);
//
// if (savedInstanceState == null) {
// getSupportFragmentManager()
// .beginTransaction()
// .add(R.id.container, new RecyclerViewFragment())
// .commit();
// }
// }
// }
//
// Path: ask-remote-module/src/main/java/com/androidstarterkit/module/sample/activity/ScrollViewActivity.java
// public class ScrollViewActivity extends AppCompatActivity {
//
// @Override
// protected void onCreate(Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
//
// setContentView(R.layout.activity_sample_main);
//
// if (savedInstanceState == null) {
// getSupportFragmentManager()
// .beginTransaction()
// .add(R.id.container, new ScrollViewFragment())
// .commit();
// }
// }
// }
//
// Path: ask-remote-module/src/main/java/com/androidstarterkit/module/sample/activity/SlidingIconTabActivity.java
// public class SlidingIconTabActivity extends AppCompatActivity {
//
// @Override
// protected void onCreate(Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
//
// getSupportActionBar().setElevation(0);
// setContentView(R.layout.activity_sample_main);
//
// if (savedInstanceState == null) {
// getSupportFragmentManager()
// .beginTransaction()
// .add(R.id.container, new SlidingIconTabFragment())
// .commit();
// }
// }
// }
//
// Path: ask-remote-module/src/main/java/com/androidstarterkit/module/sample/activity/SlidingTabActivity.java
// public class SlidingTabActivity extends AppCompatActivity {
//
// @Override
// protected void onCreate(Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
//
// getSupportActionBar().setElevation(0);
// setContentView(R.layout.activity_sample_main);
//
// if (savedInstanceState == null) {
// getSupportFragmentManager()
// .beginTransaction()
// .add(R.id.container, new SlidingTabFragment())
// .commit();
// }
// }
// }
//
// Path: ask-remote-module/src/main/java/com/androidstarterkit/module/sample/SampleType.java
// public enum SampleType {
// ScrollView, GridView, RecyclerView, ListView, SlidingTabLayout, SlidingIconTabLayout
// }
| import android.content.Context;
import android.content.Intent;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;
import com.androidstarterkit.module.sample.activity.GridViewActivity;
import com.androidstarterkit.module.sample.activity.ListViewActivity;
import com.androidstarterkit.module.R;
import com.androidstarterkit.module.sample.activity.RecyclerViewActivity;
import com.androidstarterkit.module.sample.activity.ScrollViewActivity;
import com.androidstarterkit.module.sample.activity.SlidingIconTabActivity;
import com.androidstarterkit.module.sample.activity.SlidingTabActivity;
import com.androidstarterkit.module.sample.SampleType;
import java.util.List; | @Override
public View getView(final int position, View convertView, ViewGroup parent) {
ViewHolder viewHolder;
if (convertView == null) {
convertView = inflater.inflate(R.layout.layout_main_list_item, parent, false);
viewHolder = new ViewHolder();
viewHolder.title= (TextView) convertView.findViewById(R.id.title);
convertView.setTag(viewHolder);
} else {
viewHolder = (ViewHolder) convertView.getTag();
}
viewHolder.title.setText(dataSet.get(position).name());
convertView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
SampleType sampleType = dataSet.get(position);
Intent intent = null;
switch (sampleType) {
case ScrollView:
intent = new Intent(context, ScrollViewActivity.class);
break;
case GridView:
intent = new Intent(context, GridViewActivity.class);
break;
case RecyclerView: | // Path: ask-remote-module/src/main/java/com/androidstarterkit/module/sample/activity/GridViewActivity.java
// public class GridViewActivity extends AppCompatActivity {
// @Override
// protected void onCreate(Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
//
// setContentView(R.layout.activity_sample_main);
//
// if (savedInstanceState == null) {
// getSupportFragmentManager()
// .beginTransaction()
// .add(R.id.container, new GridViewFragment())
// .commit();
// }
// }
// }
//
// Path: ask-remote-module/src/main/java/com/androidstarterkit/module/sample/activity/ListViewActivity.java
// public class ListViewActivity extends AppCompatActivity{
// @Override
// protected void onCreate(Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
//
// setContentView(R.layout.activity_sample_main);
//
// if (savedInstanceState == null) {
// getSupportFragmentManager()
// .beginTransaction()
// .add(R.id.container, new ListViewFragment())
// .commit();
// }
// }
// }
//
// Path: ask-remote-module/src/main/java/com/androidstarterkit/module/sample/activity/RecyclerViewActivity.java
// public class RecyclerViewActivity extends AppCompatActivity {
// @Override
// protected void onCreate(Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
//
// setContentView(R.layout.activity_sample_main);
//
// if (savedInstanceState == null) {
// getSupportFragmentManager()
// .beginTransaction()
// .add(R.id.container, new RecyclerViewFragment())
// .commit();
// }
// }
// }
//
// Path: ask-remote-module/src/main/java/com/androidstarterkit/module/sample/activity/ScrollViewActivity.java
// public class ScrollViewActivity extends AppCompatActivity {
//
// @Override
// protected void onCreate(Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
//
// setContentView(R.layout.activity_sample_main);
//
// if (savedInstanceState == null) {
// getSupportFragmentManager()
// .beginTransaction()
// .add(R.id.container, new ScrollViewFragment())
// .commit();
// }
// }
// }
//
// Path: ask-remote-module/src/main/java/com/androidstarterkit/module/sample/activity/SlidingIconTabActivity.java
// public class SlidingIconTabActivity extends AppCompatActivity {
//
// @Override
// protected void onCreate(Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
//
// getSupportActionBar().setElevation(0);
// setContentView(R.layout.activity_sample_main);
//
// if (savedInstanceState == null) {
// getSupportFragmentManager()
// .beginTransaction()
// .add(R.id.container, new SlidingIconTabFragment())
// .commit();
// }
// }
// }
//
// Path: ask-remote-module/src/main/java/com/androidstarterkit/module/sample/activity/SlidingTabActivity.java
// public class SlidingTabActivity extends AppCompatActivity {
//
// @Override
// protected void onCreate(Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
//
// getSupportActionBar().setElevation(0);
// setContentView(R.layout.activity_sample_main);
//
// if (savedInstanceState == null) {
// getSupportFragmentManager()
// .beginTransaction()
// .add(R.id.container, new SlidingTabFragment())
// .commit();
// }
// }
// }
//
// Path: ask-remote-module/src/main/java/com/androidstarterkit/module/sample/SampleType.java
// public enum SampleType {
// ScrollView, GridView, RecyclerView, ListView, SlidingTabLayout, SlidingIconTabLayout
// }
// Path: ask-remote-module/src/main/java/com/androidstarterkit/module/ui/adapter/MainBaseAdapter.java
import android.content.Context;
import android.content.Intent;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;
import com.androidstarterkit.module.sample.activity.GridViewActivity;
import com.androidstarterkit.module.sample.activity.ListViewActivity;
import com.androidstarterkit.module.R;
import com.androidstarterkit.module.sample.activity.RecyclerViewActivity;
import com.androidstarterkit.module.sample.activity.ScrollViewActivity;
import com.androidstarterkit.module.sample.activity.SlidingIconTabActivity;
import com.androidstarterkit.module.sample.activity.SlidingTabActivity;
import com.androidstarterkit.module.sample.SampleType;
import java.util.List;
@Override
public View getView(final int position, View convertView, ViewGroup parent) {
ViewHolder viewHolder;
if (convertView == null) {
convertView = inflater.inflate(R.layout.layout_main_list_item, parent, false);
viewHolder = new ViewHolder();
viewHolder.title= (TextView) convertView.findViewById(R.id.title);
convertView.setTag(viewHolder);
} else {
viewHolder = (ViewHolder) convertView.getTag();
}
viewHolder.title.setText(dataSet.get(position).name());
convertView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
SampleType sampleType = dataSet.get(position);
Intent intent = null;
switch (sampleType) {
case ScrollView:
intent = new Intent(context, ScrollViewActivity.class);
break;
case GridView:
intent = new Intent(context, GridViewActivity.class);
break;
case RecyclerView: | intent = new Intent(context, RecyclerViewActivity.class); |
kimkevin/AndroidStarterKit | ask-remote-module/src/main/java/com/androidstarterkit/module/ui/adapter/MainBaseAdapter.java | // Path: ask-remote-module/src/main/java/com/androidstarterkit/module/sample/activity/GridViewActivity.java
// public class GridViewActivity extends AppCompatActivity {
// @Override
// protected void onCreate(Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
//
// setContentView(R.layout.activity_sample_main);
//
// if (savedInstanceState == null) {
// getSupportFragmentManager()
// .beginTransaction()
// .add(R.id.container, new GridViewFragment())
// .commit();
// }
// }
// }
//
// Path: ask-remote-module/src/main/java/com/androidstarterkit/module/sample/activity/ListViewActivity.java
// public class ListViewActivity extends AppCompatActivity{
// @Override
// protected void onCreate(Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
//
// setContentView(R.layout.activity_sample_main);
//
// if (savedInstanceState == null) {
// getSupportFragmentManager()
// .beginTransaction()
// .add(R.id.container, new ListViewFragment())
// .commit();
// }
// }
// }
//
// Path: ask-remote-module/src/main/java/com/androidstarterkit/module/sample/activity/RecyclerViewActivity.java
// public class RecyclerViewActivity extends AppCompatActivity {
// @Override
// protected void onCreate(Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
//
// setContentView(R.layout.activity_sample_main);
//
// if (savedInstanceState == null) {
// getSupportFragmentManager()
// .beginTransaction()
// .add(R.id.container, new RecyclerViewFragment())
// .commit();
// }
// }
// }
//
// Path: ask-remote-module/src/main/java/com/androidstarterkit/module/sample/activity/ScrollViewActivity.java
// public class ScrollViewActivity extends AppCompatActivity {
//
// @Override
// protected void onCreate(Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
//
// setContentView(R.layout.activity_sample_main);
//
// if (savedInstanceState == null) {
// getSupportFragmentManager()
// .beginTransaction()
// .add(R.id.container, new ScrollViewFragment())
// .commit();
// }
// }
// }
//
// Path: ask-remote-module/src/main/java/com/androidstarterkit/module/sample/activity/SlidingIconTabActivity.java
// public class SlidingIconTabActivity extends AppCompatActivity {
//
// @Override
// protected void onCreate(Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
//
// getSupportActionBar().setElevation(0);
// setContentView(R.layout.activity_sample_main);
//
// if (savedInstanceState == null) {
// getSupportFragmentManager()
// .beginTransaction()
// .add(R.id.container, new SlidingIconTabFragment())
// .commit();
// }
// }
// }
//
// Path: ask-remote-module/src/main/java/com/androidstarterkit/module/sample/activity/SlidingTabActivity.java
// public class SlidingTabActivity extends AppCompatActivity {
//
// @Override
// protected void onCreate(Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
//
// getSupportActionBar().setElevation(0);
// setContentView(R.layout.activity_sample_main);
//
// if (savedInstanceState == null) {
// getSupportFragmentManager()
// .beginTransaction()
// .add(R.id.container, new SlidingTabFragment())
// .commit();
// }
// }
// }
//
// Path: ask-remote-module/src/main/java/com/androidstarterkit/module/sample/SampleType.java
// public enum SampleType {
// ScrollView, GridView, RecyclerView, ListView, SlidingTabLayout, SlidingIconTabLayout
// }
| import android.content.Context;
import android.content.Intent;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;
import com.androidstarterkit.module.sample.activity.GridViewActivity;
import com.androidstarterkit.module.sample.activity.ListViewActivity;
import com.androidstarterkit.module.R;
import com.androidstarterkit.module.sample.activity.RecyclerViewActivity;
import com.androidstarterkit.module.sample.activity.ScrollViewActivity;
import com.androidstarterkit.module.sample.activity.SlidingIconTabActivity;
import com.androidstarterkit.module.sample.activity.SlidingTabActivity;
import com.androidstarterkit.module.sample.SampleType;
import java.util.List; |
if (convertView == null) {
convertView = inflater.inflate(R.layout.layout_main_list_item, parent, false);
viewHolder = new ViewHolder();
viewHolder.title= (TextView) convertView.findViewById(R.id.title);
convertView.setTag(viewHolder);
} else {
viewHolder = (ViewHolder) convertView.getTag();
}
viewHolder.title.setText(dataSet.get(position).name());
convertView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
SampleType sampleType = dataSet.get(position);
Intent intent = null;
switch (sampleType) {
case ScrollView:
intent = new Intent(context, ScrollViewActivity.class);
break;
case GridView:
intent = new Intent(context, GridViewActivity.class);
break;
case RecyclerView:
intent = new Intent(context, RecyclerViewActivity.class);
break;
case ListView: | // Path: ask-remote-module/src/main/java/com/androidstarterkit/module/sample/activity/GridViewActivity.java
// public class GridViewActivity extends AppCompatActivity {
// @Override
// protected void onCreate(Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
//
// setContentView(R.layout.activity_sample_main);
//
// if (savedInstanceState == null) {
// getSupportFragmentManager()
// .beginTransaction()
// .add(R.id.container, new GridViewFragment())
// .commit();
// }
// }
// }
//
// Path: ask-remote-module/src/main/java/com/androidstarterkit/module/sample/activity/ListViewActivity.java
// public class ListViewActivity extends AppCompatActivity{
// @Override
// protected void onCreate(Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
//
// setContentView(R.layout.activity_sample_main);
//
// if (savedInstanceState == null) {
// getSupportFragmentManager()
// .beginTransaction()
// .add(R.id.container, new ListViewFragment())
// .commit();
// }
// }
// }
//
// Path: ask-remote-module/src/main/java/com/androidstarterkit/module/sample/activity/RecyclerViewActivity.java
// public class RecyclerViewActivity extends AppCompatActivity {
// @Override
// protected void onCreate(Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
//
// setContentView(R.layout.activity_sample_main);
//
// if (savedInstanceState == null) {
// getSupportFragmentManager()
// .beginTransaction()
// .add(R.id.container, new RecyclerViewFragment())
// .commit();
// }
// }
// }
//
// Path: ask-remote-module/src/main/java/com/androidstarterkit/module/sample/activity/ScrollViewActivity.java
// public class ScrollViewActivity extends AppCompatActivity {
//
// @Override
// protected void onCreate(Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
//
// setContentView(R.layout.activity_sample_main);
//
// if (savedInstanceState == null) {
// getSupportFragmentManager()
// .beginTransaction()
// .add(R.id.container, new ScrollViewFragment())
// .commit();
// }
// }
// }
//
// Path: ask-remote-module/src/main/java/com/androidstarterkit/module/sample/activity/SlidingIconTabActivity.java
// public class SlidingIconTabActivity extends AppCompatActivity {
//
// @Override
// protected void onCreate(Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
//
// getSupportActionBar().setElevation(0);
// setContentView(R.layout.activity_sample_main);
//
// if (savedInstanceState == null) {
// getSupportFragmentManager()
// .beginTransaction()
// .add(R.id.container, new SlidingIconTabFragment())
// .commit();
// }
// }
// }
//
// Path: ask-remote-module/src/main/java/com/androidstarterkit/module/sample/activity/SlidingTabActivity.java
// public class SlidingTabActivity extends AppCompatActivity {
//
// @Override
// protected void onCreate(Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
//
// getSupportActionBar().setElevation(0);
// setContentView(R.layout.activity_sample_main);
//
// if (savedInstanceState == null) {
// getSupportFragmentManager()
// .beginTransaction()
// .add(R.id.container, new SlidingTabFragment())
// .commit();
// }
// }
// }
//
// Path: ask-remote-module/src/main/java/com/androidstarterkit/module/sample/SampleType.java
// public enum SampleType {
// ScrollView, GridView, RecyclerView, ListView, SlidingTabLayout, SlidingIconTabLayout
// }
// Path: ask-remote-module/src/main/java/com/androidstarterkit/module/ui/adapter/MainBaseAdapter.java
import android.content.Context;
import android.content.Intent;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;
import com.androidstarterkit.module.sample.activity.GridViewActivity;
import com.androidstarterkit.module.sample.activity.ListViewActivity;
import com.androidstarterkit.module.R;
import com.androidstarterkit.module.sample.activity.RecyclerViewActivity;
import com.androidstarterkit.module.sample.activity.ScrollViewActivity;
import com.androidstarterkit.module.sample.activity.SlidingIconTabActivity;
import com.androidstarterkit.module.sample.activity.SlidingTabActivity;
import com.androidstarterkit.module.sample.SampleType;
import java.util.List;
if (convertView == null) {
convertView = inflater.inflate(R.layout.layout_main_list_item, parent, false);
viewHolder = new ViewHolder();
viewHolder.title= (TextView) convertView.findViewById(R.id.title);
convertView.setTag(viewHolder);
} else {
viewHolder = (ViewHolder) convertView.getTag();
}
viewHolder.title.setText(dataSet.get(position).name());
convertView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
SampleType sampleType = dataSet.get(position);
Intent intent = null;
switch (sampleType) {
case ScrollView:
intent = new Intent(context, ScrollViewActivity.class);
break;
case GridView:
intent = new Intent(context, GridViewActivity.class);
break;
case RecyclerView:
intent = new Intent(context, RecyclerViewActivity.class);
break;
case ListView: | intent = new Intent(context, ListViewActivity.class); |
kimkevin/AndroidStarterKit | ask-remote-module/src/main/java/com/androidstarterkit/module/ui/adapter/MainBaseAdapter.java | // Path: ask-remote-module/src/main/java/com/androidstarterkit/module/sample/activity/GridViewActivity.java
// public class GridViewActivity extends AppCompatActivity {
// @Override
// protected void onCreate(Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
//
// setContentView(R.layout.activity_sample_main);
//
// if (savedInstanceState == null) {
// getSupportFragmentManager()
// .beginTransaction()
// .add(R.id.container, new GridViewFragment())
// .commit();
// }
// }
// }
//
// Path: ask-remote-module/src/main/java/com/androidstarterkit/module/sample/activity/ListViewActivity.java
// public class ListViewActivity extends AppCompatActivity{
// @Override
// protected void onCreate(Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
//
// setContentView(R.layout.activity_sample_main);
//
// if (savedInstanceState == null) {
// getSupportFragmentManager()
// .beginTransaction()
// .add(R.id.container, new ListViewFragment())
// .commit();
// }
// }
// }
//
// Path: ask-remote-module/src/main/java/com/androidstarterkit/module/sample/activity/RecyclerViewActivity.java
// public class RecyclerViewActivity extends AppCompatActivity {
// @Override
// protected void onCreate(Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
//
// setContentView(R.layout.activity_sample_main);
//
// if (savedInstanceState == null) {
// getSupportFragmentManager()
// .beginTransaction()
// .add(R.id.container, new RecyclerViewFragment())
// .commit();
// }
// }
// }
//
// Path: ask-remote-module/src/main/java/com/androidstarterkit/module/sample/activity/ScrollViewActivity.java
// public class ScrollViewActivity extends AppCompatActivity {
//
// @Override
// protected void onCreate(Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
//
// setContentView(R.layout.activity_sample_main);
//
// if (savedInstanceState == null) {
// getSupportFragmentManager()
// .beginTransaction()
// .add(R.id.container, new ScrollViewFragment())
// .commit();
// }
// }
// }
//
// Path: ask-remote-module/src/main/java/com/androidstarterkit/module/sample/activity/SlidingIconTabActivity.java
// public class SlidingIconTabActivity extends AppCompatActivity {
//
// @Override
// protected void onCreate(Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
//
// getSupportActionBar().setElevation(0);
// setContentView(R.layout.activity_sample_main);
//
// if (savedInstanceState == null) {
// getSupportFragmentManager()
// .beginTransaction()
// .add(R.id.container, new SlidingIconTabFragment())
// .commit();
// }
// }
// }
//
// Path: ask-remote-module/src/main/java/com/androidstarterkit/module/sample/activity/SlidingTabActivity.java
// public class SlidingTabActivity extends AppCompatActivity {
//
// @Override
// protected void onCreate(Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
//
// getSupportActionBar().setElevation(0);
// setContentView(R.layout.activity_sample_main);
//
// if (savedInstanceState == null) {
// getSupportFragmentManager()
// .beginTransaction()
// .add(R.id.container, new SlidingTabFragment())
// .commit();
// }
// }
// }
//
// Path: ask-remote-module/src/main/java/com/androidstarterkit/module/sample/SampleType.java
// public enum SampleType {
// ScrollView, GridView, RecyclerView, ListView, SlidingTabLayout, SlidingIconTabLayout
// }
| import android.content.Context;
import android.content.Intent;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;
import com.androidstarterkit.module.sample.activity.GridViewActivity;
import com.androidstarterkit.module.sample.activity.ListViewActivity;
import com.androidstarterkit.module.R;
import com.androidstarterkit.module.sample.activity.RecyclerViewActivity;
import com.androidstarterkit.module.sample.activity.ScrollViewActivity;
import com.androidstarterkit.module.sample.activity.SlidingIconTabActivity;
import com.androidstarterkit.module.sample.activity.SlidingTabActivity;
import com.androidstarterkit.module.sample.SampleType;
import java.util.List; |
viewHolder = new ViewHolder();
viewHolder.title= (TextView) convertView.findViewById(R.id.title);
convertView.setTag(viewHolder);
} else {
viewHolder = (ViewHolder) convertView.getTag();
}
viewHolder.title.setText(dataSet.get(position).name());
convertView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
SampleType sampleType = dataSet.get(position);
Intent intent = null;
switch (sampleType) {
case ScrollView:
intent = new Intent(context, ScrollViewActivity.class);
break;
case GridView:
intent = new Intent(context, GridViewActivity.class);
break;
case RecyclerView:
intent = new Intent(context, RecyclerViewActivity.class);
break;
case ListView:
intent = new Intent(context, ListViewActivity.class);
break;
case SlidingTabLayout: | // Path: ask-remote-module/src/main/java/com/androidstarterkit/module/sample/activity/GridViewActivity.java
// public class GridViewActivity extends AppCompatActivity {
// @Override
// protected void onCreate(Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
//
// setContentView(R.layout.activity_sample_main);
//
// if (savedInstanceState == null) {
// getSupportFragmentManager()
// .beginTransaction()
// .add(R.id.container, new GridViewFragment())
// .commit();
// }
// }
// }
//
// Path: ask-remote-module/src/main/java/com/androidstarterkit/module/sample/activity/ListViewActivity.java
// public class ListViewActivity extends AppCompatActivity{
// @Override
// protected void onCreate(Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
//
// setContentView(R.layout.activity_sample_main);
//
// if (savedInstanceState == null) {
// getSupportFragmentManager()
// .beginTransaction()
// .add(R.id.container, new ListViewFragment())
// .commit();
// }
// }
// }
//
// Path: ask-remote-module/src/main/java/com/androidstarterkit/module/sample/activity/RecyclerViewActivity.java
// public class RecyclerViewActivity extends AppCompatActivity {
// @Override
// protected void onCreate(Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
//
// setContentView(R.layout.activity_sample_main);
//
// if (savedInstanceState == null) {
// getSupportFragmentManager()
// .beginTransaction()
// .add(R.id.container, new RecyclerViewFragment())
// .commit();
// }
// }
// }
//
// Path: ask-remote-module/src/main/java/com/androidstarterkit/module/sample/activity/ScrollViewActivity.java
// public class ScrollViewActivity extends AppCompatActivity {
//
// @Override
// protected void onCreate(Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
//
// setContentView(R.layout.activity_sample_main);
//
// if (savedInstanceState == null) {
// getSupportFragmentManager()
// .beginTransaction()
// .add(R.id.container, new ScrollViewFragment())
// .commit();
// }
// }
// }
//
// Path: ask-remote-module/src/main/java/com/androidstarterkit/module/sample/activity/SlidingIconTabActivity.java
// public class SlidingIconTabActivity extends AppCompatActivity {
//
// @Override
// protected void onCreate(Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
//
// getSupportActionBar().setElevation(0);
// setContentView(R.layout.activity_sample_main);
//
// if (savedInstanceState == null) {
// getSupportFragmentManager()
// .beginTransaction()
// .add(R.id.container, new SlidingIconTabFragment())
// .commit();
// }
// }
// }
//
// Path: ask-remote-module/src/main/java/com/androidstarterkit/module/sample/activity/SlidingTabActivity.java
// public class SlidingTabActivity extends AppCompatActivity {
//
// @Override
// protected void onCreate(Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
//
// getSupportActionBar().setElevation(0);
// setContentView(R.layout.activity_sample_main);
//
// if (savedInstanceState == null) {
// getSupportFragmentManager()
// .beginTransaction()
// .add(R.id.container, new SlidingTabFragment())
// .commit();
// }
// }
// }
//
// Path: ask-remote-module/src/main/java/com/androidstarterkit/module/sample/SampleType.java
// public enum SampleType {
// ScrollView, GridView, RecyclerView, ListView, SlidingTabLayout, SlidingIconTabLayout
// }
// Path: ask-remote-module/src/main/java/com/androidstarterkit/module/ui/adapter/MainBaseAdapter.java
import android.content.Context;
import android.content.Intent;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;
import com.androidstarterkit.module.sample.activity.GridViewActivity;
import com.androidstarterkit.module.sample.activity.ListViewActivity;
import com.androidstarterkit.module.R;
import com.androidstarterkit.module.sample.activity.RecyclerViewActivity;
import com.androidstarterkit.module.sample.activity.ScrollViewActivity;
import com.androidstarterkit.module.sample.activity.SlidingIconTabActivity;
import com.androidstarterkit.module.sample.activity.SlidingTabActivity;
import com.androidstarterkit.module.sample.SampleType;
import java.util.List;
viewHolder = new ViewHolder();
viewHolder.title= (TextView) convertView.findViewById(R.id.title);
convertView.setTag(viewHolder);
} else {
viewHolder = (ViewHolder) convertView.getTag();
}
viewHolder.title.setText(dataSet.get(position).name());
convertView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
SampleType sampleType = dataSet.get(position);
Intent intent = null;
switch (sampleType) {
case ScrollView:
intent = new Intent(context, ScrollViewActivity.class);
break;
case GridView:
intent = new Intent(context, GridViewActivity.class);
break;
case RecyclerView:
intent = new Intent(context, RecyclerViewActivity.class);
break;
case ListView:
intent = new Intent(context, ListViewActivity.class);
break;
case SlidingTabLayout: | intent = new Intent(context, SlidingTabActivity.class); |
kimkevin/AndroidStarterKit | ask-remote-module/src/main/java/com/androidstarterkit/module/ui/adapter/MainBaseAdapter.java | // Path: ask-remote-module/src/main/java/com/androidstarterkit/module/sample/activity/GridViewActivity.java
// public class GridViewActivity extends AppCompatActivity {
// @Override
// protected void onCreate(Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
//
// setContentView(R.layout.activity_sample_main);
//
// if (savedInstanceState == null) {
// getSupportFragmentManager()
// .beginTransaction()
// .add(R.id.container, new GridViewFragment())
// .commit();
// }
// }
// }
//
// Path: ask-remote-module/src/main/java/com/androidstarterkit/module/sample/activity/ListViewActivity.java
// public class ListViewActivity extends AppCompatActivity{
// @Override
// protected void onCreate(Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
//
// setContentView(R.layout.activity_sample_main);
//
// if (savedInstanceState == null) {
// getSupportFragmentManager()
// .beginTransaction()
// .add(R.id.container, new ListViewFragment())
// .commit();
// }
// }
// }
//
// Path: ask-remote-module/src/main/java/com/androidstarterkit/module/sample/activity/RecyclerViewActivity.java
// public class RecyclerViewActivity extends AppCompatActivity {
// @Override
// protected void onCreate(Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
//
// setContentView(R.layout.activity_sample_main);
//
// if (savedInstanceState == null) {
// getSupportFragmentManager()
// .beginTransaction()
// .add(R.id.container, new RecyclerViewFragment())
// .commit();
// }
// }
// }
//
// Path: ask-remote-module/src/main/java/com/androidstarterkit/module/sample/activity/ScrollViewActivity.java
// public class ScrollViewActivity extends AppCompatActivity {
//
// @Override
// protected void onCreate(Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
//
// setContentView(R.layout.activity_sample_main);
//
// if (savedInstanceState == null) {
// getSupportFragmentManager()
// .beginTransaction()
// .add(R.id.container, new ScrollViewFragment())
// .commit();
// }
// }
// }
//
// Path: ask-remote-module/src/main/java/com/androidstarterkit/module/sample/activity/SlidingIconTabActivity.java
// public class SlidingIconTabActivity extends AppCompatActivity {
//
// @Override
// protected void onCreate(Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
//
// getSupportActionBar().setElevation(0);
// setContentView(R.layout.activity_sample_main);
//
// if (savedInstanceState == null) {
// getSupportFragmentManager()
// .beginTransaction()
// .add(R.id.container, new SlidingIconTabFragment())
// .commit();
// }
// }
// }
//
// Path: ask-remote-module/src/main/java/com/androidstarterkit/module/sample/activity/SlidingTabActivity.java
// public class SlidingTabActivity extends AppCompatActivity {
//
// @Override
// protected void onCreate(Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
//
// getSupportActionBar().setElevation(0);
// setContentView(R.layout.activity_sample_main);
//
// if (savedInstanceState == null) {
// getSupportFragmentManager()
// .beginTransaction()
// .add(R.id.container, new SlidingTabFragment())
// .commit();
// }
// }
// }
//
// Path: ask-remote-module/src/main/java/com/androidstarterkit/module/sample/SampleType.java
// public enum SampleType {
// ScrollView, GridView, RecyclerView, ListView, SlidingTabLayout, SlidingIconTabLayout
// }
| import android.content.Context;
import android.content.Intent;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;
import com.androidstarterkit.module.sample.activity.GridViewActivity;
import com.androidstarterkit.module.sample.activity.ListViewActivity;
import com.androidstarterkit.module.R;
import com.androidstarterkit.module.sample.activity.RecyclerViewActivity;
import com.androidstarterkit.module.sample.activity.ScrollViewActivity;
import com.androidstarterkit.module.sample.activity.SlidingIconTabActivity;
import com.androidstarterkit.module.sample.activity.SlidingTabActivity;
import com.androidstarterkit.module.sample.SampleType;
import java.util.List; | convertView.setTag(viewHolder);
} else {
viewHolder = (ViewHolder) convertView.getTag();
}
viewHolder.title.setText(dataSet.get(position).name());
convertView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
SampleType sampleType = dataSet.get(position);
Intent intent = null;
switch (sampleType) {
case ScrollView:
intent = new Intent(context, ScrollViewActivity.class);
break;
case GridView:
intent = new Intent(context, GridViewActivity.class);
break;
case RecyclerView:
intent = new Intent(context, RecyclerViewActivity.class);
break;
case ListView:
intent = new Intent(context, ListViewActivity.class);
break;
case SlidingTabLayout:
intent = new Intent(context, SlidingTabActivity.class);
break;
case SlidingIconTabLayout: | // Path: ask-remote-module/src/main/java/com/androidstarterkit/module/sample/activity/GridViewActivity.java
// public class GridViewActivity extends AppCompatActivity {
// @Override
// protected void onCreate(Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
//
// setContentView(R.layout.activity_sample_main);
//
// if (savedInstanceState == null) {
// getSupportFragmentManager()
// .beginTransaction()
// .add(R.id.container, new GridViewFragment())
// .commit();
// }
// }
// }
//
// Path: ask-remote-module/src/main/java/com/androidstarterkit/module/sample/activity/ListViewActivity.java
// public class ListViewActivity extends AppCompatActivity{
// @Override
// protected void onCreate(Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
//
// setContentView(R.layout.activity_sample_main);
//
// if (savedInstanceState == null) {
// getSupportFragmentManager()
// .beginTransaction()
// .add(R.id.container, new ListViewFragment())
// .commit();
// }
// }
// }
//
// Path: ask-remote-module/src/main/java/com/androidstarterkit/module/sample/activity/RecyclerViewActivity.java
// public class RecyclerViewActivity extends AppCompatActivity {
// @Override
// protected void onCreate(Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
//
// setContentView(R.layout.activity_sample_main);
//
// if (savedInstanceState == null) {
// getSupportFragmentManager()
// .beginTransaction()
// .add(R.id.container, new RecyclerViewFragment())
// .commit();
// }
// }
// }
//
// Path: ask-remote-module/src/main/java/com/androidstarterkit/module/sample/activity/ScrollViewActivity.java
// public class ScrollViewActivity extends AppCompatActivity {
//
// @Override
// protected void onCreate(Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
//
// setContentView(R.layout.activity_sample_main);
//
// if (savedInstanceState == null) {
// getSupportFragmentManager()
// .beginTransaction()
// .add(R.id.container, new ScrollViewFragment())
// .commit();
// }
// }
// }
//
// Path: ask-remote-module/src/main/java/com/androidstarterkit/module/sample/activity/SlidingIconTabActivity.java
// public class SlidingIconTabActivity extends AppCompatActivity {
//
// @Override
// protected void onCreate(Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
//
// getSupportActionBar().setElevation(0);
// setContentView(R.layout.activity_sample_main);
//
// if (savedInstanceState == null) {
// getSupportFragmentManager()
// .beginTransaction()
// .add(R.id.container, new SlidingIconTabFragment())
// .commit();
// }
// }
// }
//
// Path: ask-remote-module/src/main/java/com/androidstarterkit/module/sample/activity/SlidingTabActivity.java
// public class SlidingTabActivity extends AppCompatActivity {
//
// @Override
// protected void onCreate(Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
//
// getSupportActionBar().setElevation(0);
// setContentView(R.layout.activity_sample_main);
//
// if (savedInstanceState == null) {
// getSupportFragmentManager()
// .beginTransaction()
// .add(R.id.container, new SlidingTabFragment())
// .commit();
// }
// }
// }
//
// Path: ask-remote-module/src/main/java/com/androidstarterkit/module/sample/SampleType.java
// public enum SampleType {
// ScrollView, GridView, RecyclerView, ListView, SlidingTabLayout, SlidingIconTabLayout
// }
// Path: ask-remote-module/src/main/java/com/androidstarterkit/module/ui/adapter/MainBaseAdapter.java
import android.content.Context;
import android.content.Intent;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;
import com.androidstarterkit.module.sample.activity.GridViewActivity;
import com.androidstarterkit.module.sample.activity.ListViewActivity;
import com.androidstarterkit.module.R;
import com.androidstarterkit.module.sample.activity.RecyclerViewActivity;
import com.androidstarterkit.module.sample.activity.ScrollViewActivity;
import com.androidstarterkit.module.sample.activity.SlidingIconTabActivity;
import com.androidstarterkit.module.sample.activity.SlidingTabActivity;
import com.androidstarterkit.module.sample.SampleType;
import java.util.List;
convertView.setTag(viewHolder);
} else {
viewHolder = (ViewHolder) convertView.getTag();
}
viewHolder.title.setText(dataSet.get(position).name());
convertView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
SampleType sampleType = dataSet.get(position);
Intent intent = null;
switch (sampleType) {
case ScrollView:
intent = new Intent(context, ScrollViewActivity.class);
break;
case GridView:
intent = new Intent(context, GridViewActivity.class);
break;
case RecyclerView:
intent = new Intent(context, RecyclerViewActivity.class);
break;
case ListView:
intent = new Intent(context, ListViewActivity.class);
break;
case SlidingTabLayout:
intent = new Intent(context, SlidingTabActivity.class);
break;
case SlidingIconTabLayout: | intent = new Intent(context, SlidingIconTabActivity.class); |
kimkevin/AndroidStarterKit | ask-app/src/main/java/com/androidstarterkit/util/FileUtils.java | // Path: ask-app/src/main/java/com/androidstarterkit/config/AskConfig.java
// public class AskConfig {
// public static final String DEFAULT_ASK_APP_NAME = "ask-app";
// public static final String DEFAULT_SAMPLE_MODULE_NAME = "ask-sample";
// public static final String DEFAULT_REMOTE_MODULE_NAME = "ask-remote-module";
//
// public static final int DEVELOPMENT = 0;
// public static final int PRODUCTION = 1;
//
// public static final int OUTPUT_PROD_PROJECT = 0;
// public static final int OUTPUT_DEV_ASK_SAMPLE = 1;
// }
| import com.androidstarterkit.config.AskConfig;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.nio.channels.FileChannel;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
import java.util.regex.Matcher;
import java.util.regex.Pattern; | package com.androidstarterkit.util;
public class FileUtils {
public static String getRootPath() {
File projectDir = new File(".");
try { | // Path: ask-app/src/main/java/com/androidstarterkit/config/AskConfig.java
// public class AskConfig {
// public static final String DEFAULT_ASK_APP_NAME = "ask-app";
// public static final String DEFAULT_SAMPLE_MODULE_NAME = "ask-sample";
// public static final String DEFAULT_REMOTE_MODULE_NAME = "ask-remote-module";
//
// public static final int DEVELOPMENT = 0;
// public static final int PRODUCTION = 1;
//
// public static final int OUTPUT_PROD_PROJECT = 0;
// public static final int OUTPUT_DEV_ASK_SAMPLE = 1;
// }
// Path: ask-app/src/main/java/com/androidstarterkit/util/FileUtils.java
import com.androidstarterkit.config.AskConfig;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.nio.channels.FileChannel;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
package com.androidstarterkit.util;
public class FileUtils {
public static String getRootPath() {
File projectDir = new File(".");
try { | int index = projectDir.getCanonicalPath().indexOf(AskConfig.DEFAULT_ASK_APP_NAME); |
kimkevin/AndroidStarterKit | ask-app/src/main/java/com/androidstarterkit/injection/ModuleLoader.java | // Path: ask-app/src/main/java/com/androidstarterkit/injection/model/Config.java
// public class Config {
// @SerializedName("path")
// protected String path;
//
// @SerializedName("file")
// protected String fileNameEx;
//
// public Config(String path, String fileNameEx) {
// this.path = path;
// this.fileNameEx = fileNameEx;
// }
//
// public String getPath() {
// return path;
// }
//
// public String getFullPathname() {
// return path + "/" + fileNameEx;
// }
//
// public void setPath(String path) {
// this.path = path;
// }
//
// public String getFileName() {
// return FileUtils.removeExtension(fileNameEx);
// }
//
// public String getFileNameEx() {
// return fileNameEx;
// }
//
// public void setFileNameEx(String fileNameEx) {
// this.fileNameEx = fileNameEx;
// }
//
// @Override
// public String toString() {
// return "Config{" +
// "path='" + path + '\'' +
// ", fileNameEx='" + fileNameEx + '\'' +
// '}';
// }
// }
//
// Path: ask-app/src/main/java/com/androidstarterkit/injection/model/GradleConfig.java
// public class GradleConfig extends Config {
// @SerializedName("snippet")
// private List<Snippet> snippets;
//
// public GradleConfig(String path, String fileNameEx) {
// this(path, fileNameEx, null);
// }
//
// private GradleConfig(String path, String fileNameEx, List<Snippet> snippets) {
// super(path, fileNameEx);
// this.snippets = snippets;
// }
//
// public List<Snippet> getSnippets() {
// return snippets;
// }
//
// public void addSnippet(Snippet snippet) {
// if (snippets == null) {
// snippets = new ArrayList<>();
// }
//
// snippets.add(snippet);
// }
//
// @Override
// public String toString() {
// return super.toString() + ", GradleConfig{" +
// "path='" + path + '\'' +
// ", fileNameEx='" + fileNameEx + '\'' +
// ", configs=" + snippets +
// '}';
// }
// }
//
// Path: ask-app/src/main/java/com/androidstarterkit/injection/model/JavaConfig.java
// public class JavaConfig extends Config{
// @SerializedName("import")
// private List<String> imports;
//
// @SerializedName("field")
// private List<String> fields;
//
// @SerializedName("method")
// private List<Method> methods;
//
// public JavaConfig(String path, String fileNameEx) {
// super(path, fileNameEx);
// }
//
// public List<String> getImports() {
// return imports;
// }
//
// public List<String> getFields() {
// return fields;
// }
//
// public List<Method> getMethods() {
// return methods;
// }
//
// public void replaceImportStrings(String reg, String applicationId) {
// for (int i = 0, li = imports.size(); i < li; i++) {
// imports.set(i, imports.get(i).replace(reg, applicationId));
// }
// }
//
// @Override
// public String toString() {
// return super.toString() + ", JavaConfig{" +
// "imports=" + imports +
// ", fields=" + fields +
// ", methods=" + methods +
// '}';
// }
// }
//
// Path: ask-app/src/main/java/com/androidstarterkit/injection/model/ManifestConfig.java
// public class ManifestConfig extends Config {
// @SerializedName("element")
// private List<ManifestElement> manifestElements;
//
// public ManifestConfig(String path, String fileNameEx) {
// super(path, fileNameEx);
// }
//
// public List<ManifestElement> getManifestElements() {
// return manifestElements;
// }
//
// @Override
// public String toString() {
// return "ManifestConfig{" +
// "manifestElements=" + manifestElements +
// '}';
// }
// }
| import com.androidstarterkit.injection.model.Config;
import com.androidstarterkit.injection.model.GradleConfig;
import com.androidstarterkit.injection.model.JavaConfig;
import com.androidstarterkit.injection.model.ManifestConfig;
import java.io.File;
import java.util.ArrayList;
import java.util.List; | package com.androidstarterkit.injection;
public class ModuleLoader {
private List<CodeGenerator> codeGenerators;
public ModuleLoader() {
codeGenerators = new ArrayList<>();
}
public void generateCode() {
codeGenerators.forEach(CodeGenerator::apply);
}
public void addCodeGenerator(CodeGenerator codeGenerator) {
if (!codeGenerators.contains(codeGenerator)) {
codeGenerators.add(codeGenerator);
}
}
| // Path: ask-app/src/main/java/com/androidstarterkit/injection/model/Config.java
// public class Config {
// @SerializedName("path")
// protected String path;
//
// @SerializedName("file")
// protected String fileNameEx;
//
// public Config(String path, String fileNameEx) {
// this.path = path;
// this.fileNameEx = fileNameEx;
// }
//
// public String getPath() {
// return path;
// }
//
// public String getFullPathname() {
// return path + "/" + fileNameEx;
// }
//
// public void setPath(String path) {
// this.path = path;
// }
//
// public String getFileName() {
// return FileUtils.removeExtension(fileNameEx);
// }
//
// public String getFileNameEx() {
// return fileNameEx;
// }
//
// public void setFileNameEx(String fileNameEx) {
// this.fileNameEx = fileNameEx;
// }
//
// @Override
// public String toString() {
// return "Config{" +
// "path='" + path + '\'' +
// ", fileNameEx='" + fileNameEx + '\'' +
// '}';
// }
// }
//
// Path: ask-app/src/main/java/com/androidstarterkit/injection/model/GradleConfig.java
// public class GradleConfig extends Config {
// @SerializedName("snippet")
// private List<Snippet> snippets;
//
// public GradleConfig(String path, String fileNameEx) {
// this(path, fileNameEx, null);
// }
//
// private GradleConfig(String path, String fileNameEx, List<Snippet> snippets) {
// super(path, fileNameEx);
// this.snippets = snippets;
// }
//
// public List<Snippet> getSnippets() {
// return snippets;
// }
//
// public void addSnippet(Snippet snippet) {
// if (snippets == null) {
// snippets = new ArrayList<>();
// }
//
// snippets.add(snippet);
// }
//
// @Override
// public String toString() {
// return super.toString() + ", GradleConfig{" +
// "path='" + path + '\'' +
// ", fileNameEx='" + fileNameEx + '\'' +
// ", configs=" + snippets +
// '}';
// }
// }
//
// Path: ask-app/src/main/java/com/androidstarterkit/injection/model/JavaConfig.java
// public class JavaConfig extends Config{
// @SerializedName("import")
// private List<String> imports;
//
// @SerializedName("field")
// private List<String> fields;
//
// @SerializedName("method")
// private List<Method> methods;
//
// public JavaConfig(String path, String fileNameEx) {
// super(path, fileNameEx);
// }
//
// public List<String> getImports() {
// return imports;
// }
//
// public List<String> getFields() {
// return fields;
// }
//
// public List<Method> getMethods() {
// return methods;
// }
//
// public void replaceImportStrings(String reg, String applicationId) {
// for (int i = 0, li = imports.size(); i < li; i++) {
// imports.set(i, imports.get(i).replace(reg, applicationId));
// }
// }
//
// @Override
// public String toString() {
// return super.toString() + ", JavaConfig{" +
// "imports=" + imports +
// ", fields=" + fields +
// ", methods=" + methods +
// '}';
// }
// }
//
// Path: ask-app/src/main/java/com/androidstarterkit/injection/model/ManifestConfig.java
// public class ManifestConfig extends Config {
// @SerializedName("element")
// private List<ManifestElement> manifestElements;
//
// public ManifestConfig(String path, String fileNameEx) {
// super(path, fileNameEx);
// }
//
// public List<ManifestElement> getManifestElements() {
// return manifestElements;
// }
//
// @Override
// public String toString() {
// return "ManifestConfig{" +
// "manifestElements=" + manifestElements +
// '}';
// }
// }
// Path: ask-app/src/main/java/com/androidstarterkit/injection/ModuleLoader.java
import com.androidstarterkit.injection.model.Config;
import com.androidstarterkit.injection.model.GradleConfig;
import com.androidstarterkit.injection.model.JavaConfig;
import com.androidstarterkit.injection.model.ManifestConfig;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
package com.androidstarterkit.injection;
public class ModuleLoader {
private List<CodeGenerator> codeGenerators;
public ModuleLoader() {
codeGenerators = new ArrayList<>();
}
public void generateCode() {
codeGenerators.forEach(CodeGenerator::apply);
}
public void addCodeGenerator(CodeGenerator codeGenerator) {
if (!codeGenerators.contains(codeGenerator)) {
codeGenerators.add(codeGenerator);
}
}
| public void addManifestConfigs(List<ManifestConfig> configs) { |
kimkevin/AndroidStarterKit | ask-app/src/main/java/com/androidstarterkit/injection/ModuleLoader.java | // Path: ask-app/src/main/java/com/androidstarterkit/injection/model/Config.java
// public class Config {
// @SerializedName("path")
// protected String path;
//
// @SerializedName("file")
// protected String fileNameEx;
//
// public Config(String path, String fileNameEx) {
// this.path = path;
// this.fileNameEx = fileNameEx;
// }
//
// public String getPath() {
// return path;
// }
//
// public String getFullPathname() {
// return path + "/" + fileNameEx;
// }
//
// public void setPath(String path) {
// this.path = path;
// }
//
// public String getFileName() {
// return FileUtils.removeExtension(fileNameEx);
// }
//
// public String getFileNameEx() {
// return fileNameEx;
// }
//
// public void setFileNameEx(String fileNameEx) {
// this.fileNameEx = fileNameEx;
// }
//
// @Override
// public String toString() {
// return "Config{" +
// "path='" + path + '\'' +
// ", fileNameEx='" + fileNameEx + '\'' +
// '}';
// }
// }
//
// Path: ask-app/src/main/java/com/androidstarterkit/injection/model/GradleConfig.java
// public class GradleConfig extends Config {
// @SerializedName("snippet")
// private List<Snippet> snippets;
//
// public GradleConfig(String path, String fileNameEx) {
// this(path, fileNameEx, null);
// }
//
// private GradleConfig(String path, String fileNameEx, List<Snippet> snippets) {
// super(path, fileNameEx);
// this.snippets = snippets;
// }
//
// public List<Snippet> getSnippets() {
// return snippets;
// }
//
// public void addSnippet(Snippet snippet) {
// if (snippets == null) {
// snippets = new ArrayList<>();
// }
//
// snippets.add(snippet);
// }
//
// @Override
// public String toString() {
// return super.toString() + ", GradleConfig{" +
// "path='" + path + '\'' +
// ", fileNameEx='" + fileNameEx + '\'' +
// ", configs=" + snippets +
// '}';
// }
// }
//
// Path: ask-app/src/main/java/com/androidstarterkit/injection/model/JavaConfig.java
// public class JavaConfig extends Config{
// @SerializedName("import")
// private List<String> imports;
//
// @SerializedName("field")
// private List<String> fields;
//
// @SerializedName("method")
// private List<Method> methods;
//
// public JavaConfig(String path, String fileNameEx) {
// super(path, fileNameEx);
// }
//
// public List<String> getImports() {
// return imports;
// }
//
// public List<String> getFields() {
// return fields;
// }
//
// public List<Method> getMethods() {
// return methods;
// }
//
// public void replaceImportStrings(String reg, String applicationId) {
// for (int i = 0, li = imports.size(); i < li; i++) {
// imports.set(i, imports.get(i).replace(reg, applicationId));
// }
// }
//
// @Override
// public String toString() {
// return super.toString() + ", JavaConfig{" +
// "imports=" + imports +
// ", fields=" + fields +
// ", methods=" + methods +
// '}';
// }
// }
//
// Path: ask-app/src/main/java/com/androidstarterkit/injection/model/ManifestConfig.java
// public class ManifestConfig extends Config {
// @SerializedName("element")
// private List<ManifestElement> manifestElements;
//
// public ManifestConfig(String path, String fileNameEx) {
// super(path, fileNameEx);
// }
//
// public List<ManifestElement> getManifestElements() {
// return manifestElements;
// }
//
// @Override
// public String toString() {
// return "ManifestConfig{" +
// "manifestElements=" + manifestElements +
// '}';
// }
// }
| import com.androidstarterkit.injection.model.Config;
import com.androidstarterkit.injection.model.GradleConfig;
import com.androidstarterkit.injection.model.JavaConfig;
import com.androidstarterkit.injection.model.ManifestConfig;
import java.io.File;
import java.util.ArrayList;
import java.util.List; | package com.androidstarterkit.injection;
public class ModuleLoader {
private List<CodeGenerator> codeGenerators;
public ModuleLoader() {
codeGenerators = new ArrayList<>();
}
public void generateCode() {
codeGenerators.forEach(CodeGenerator::apply);
}
public void addCodeGenerator(CodeGenerator codeGenerator) {
if (!codeGenerators.contains(codeGenerator)) {
codeGenerators.add(codeGenerator);
}
}
public void addManifestConfigs(List<ManifestConfig> configs) {
if (configs != null) {
configs.forEach(this::addConfig);
}
}
| // Path: ask-app/src/main/java/com/androidstarterkit/injection/model/Config.java
// public class Config {
// @SerializedName("path")
// protected String path;
//
// @SerializedName("file")
// protected String fileNameEx;
//
// public Config(String path, String fileNameEx) {
// this.path = path;
// this.fileNameEx = fileNameEx;
// }
//
// public String getPath() {
// return path;
// }
//
// public String getFullPathname() {
// return path + "/" + fileNameEx;
// }
//
// public void setPath(String path) {
// this.path = path;
// }
//
// public String getFileName() {
// return FileUtils.removeExtension(fileNameEx);
// }
//
// public String getFileNameEx() {
// return fileNameEx;
// }
//
// public void setFileNameEx(String fileNameEx) {
// this.fileNameEx = fileNameEx;
// }
//
// @Override
// public String toString() {
// return "Config{" +
// "path='" + path + '\'' +
// ", fileNameEx='" + fileNameEx + '\'' +
// '}';
// }
// }
//
// Path: ask-app/src/main/java/com/androidstarterkit/injection/model/GradleConfig.java
// public class GradleConfig extends Config {
// @SerializedName("snippet")
// private List<Snippet> snippets;
//
// public GradleConfig(String path, String fileNameEx) {
// this(path, fileNameEx, null);
// }
//
// private GradleConfig(String path, String fileNameEx, List<Snippet> snippets) {
// super(path, fileNameEx);
// this.snippets = snippets;
// }
//
// public List<Snippet> getSnippets() {
// return snippets;
// }
//
// public void addSnippet(Snippet snippet) {
// if (snippets == null) {
// snippets = new ArrayList<>();
// }
//
// snippets.add(snippet);
// }
//
// @Override
// public String toString() {
// return super.toString() + ", GradleConfig{" +
// "path='" + path + '\'' +
// ", fileNameEx='" + fileNameEx + '\'' +
// ", configs=" + snippets +
// '}';
// }
// }
//
// Path: ask-app/src/main/java/com/androidstarterkit/injection/model/JavaConfig.java
// public class JavaConfig extends Config{
// @SerializedName("import")
// private List<String> imports;
//
// @SerializedName("field")
// private List<String> fields;
//
// @SerializedName("method")
// private List<Method> methods;
//
// public JavaConfig(String path, String fileNameEx) {
// super(path, fileNameEx);
// }
//
// public List<String> getImports() {
// return imports;
// }
//
// public List<String> getFields() {
// return fields;
// }
//
// public List<Method> getMethods() {
// return methods;
// }
//
// public void replaceImportStrings(String reg, String applicationId) {
// for (int i = 0, li = imports.size(); i < li; i++) {
// imports.set(i, imports.get(i).replace(reg, applicationId));
// }
// }
//
// @Override
// public String toString() {
// return super.toString() + ", JavaConfig{" +
// "imports=" + imports +
// ", fields=" + fields +
// ", methods=" + methods +
// '}';
// }
// }
//
// Path: ask-app/src/main/java/com/androidstarterkit/injection/model/ManifestConfig.java
// public class ManifestConfig extends Config {
// @SerializedName("element")
// private List<ManifestElement> manifestElements;
//
// public ManifestConfig(String path, String fileNameEx) {
// super(path, fileNameEx);
// }
//
// public List<ManifestElement> getManifestElements() {
// return manifestElements;
// }
//
// @Override
// public String toString() {
// return "ManifestConfig{" +
// "manifestElements=" + manifestElements +
// '}';
// }
// }
// Path: ask-app/src/main/java/com/androidstarterkit/injection/ModuleLoader.java
import com.androidstarterkit.injection.model.Config;
import com.androidstarterkit.injection.model.GradleConfig;
import com.androidstarterkit.injection.model.JavaConfig;
import com.androidstarterkit.injection.model.ManifestConfig;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
package com.androidstarterkit.injection;
public class ModuleLoader {
private List<CodeGenerator> codeGenerators;
public ModuleLoader() {
codeGenerators = new ArrayList<>();
}
public void generateCode() {
codeGenerators.forEach(CodeGenerator::apply);
}
public void addCodeGenerator(CodeGenerator codeGenerator) {
if (!codeGenerators.contains(codeGenerator)) {
codeGenerators.add(codeGenerator);
}
}
public void addManifestConfigs(List<ManifestConfig> configs) {
if (configs != null) {
configs.forEach(this::addConfig);
}
}
| public void addJavaConfigs(List<JavaConfig> configs) { |
kimkevin/AndroidStarterKit | ask-app/src/main/java/com/androidstarterkit/injection/ModuleLoader.java | // Path: ask-app/src/main/java/com/androidstarterkit/injection/model/Config.java
// public class Config {
// @SerializedName("path")
// protected String path;
//
// @SerializedName("file")
// protected String fileNameEx;
//
// public Config(String path, String fileNameEx) {
// this.path = path;
// this.fileNameEx = fileNameEx;
// }
//
// public String getPath() {
// return path;
// }
//
// public String getFullPathname() {
// return path + "/" + fileNameEx;
// }
//
// public void setPath(String path) {
// this.path = path;
// }
//
// public String getFileName() {
// return FileUtils.removeExtension(fileNameEx);
// }
//
// public String getFileNameEx() {
// return fileNameEx;
// }
//
// public void setFileNameEx(String fileNameEx) {
// this.fileNameEx = fileNameEx;
// }
//
// @Override
// public String toString() {
// return "Config{" +
// "path='" + path + '\'' +
// ", fileNameEx='" + fileNameEx + '\'' +
// '}';
// }
// }
//
// Path: ask-app/src/main/java/com/androidstarterkit/injection/model/GradleConfig.java
// public class GradleConfig extends Config {
// @SerializedName("snippet")
// private List<Snippet> snippets;
//
// public GradleConfig(String path, String fileNameEx) {
// this(path, fileNameEx, null);
// }
//
// private GradleConfig(String path, String fileNameEx, List<Snippet> snippets) {
// super(path, fileNameEx);
// this.snippets = snippets;
// }
//
// public List<Snippet> getSnippets() {
// return snippets;
// }
//
// public void addSnippet(Snippet snippet) {
// if (snippets == null) {
// snippets = new ArrayList<>();
// }
//
// snippets.add(snippet);
// }
//
// @Override
// public String toString() {
// return super.toString() + ", GradleConfig{" +
// "path='" + path + '\'' +
// ", fileNameEx='" + fileNameEx + '\'' +
// ", configs=" + snippets +
// '}';
// }
// }
//
// Path: ask-app/src/main/java/com/androidstarterkit/injection/model/JavaConfig.java
// public class JavaConfig extends Config{
// @SerializedName("import")
// private List<String> imports;
//
// @SerializedName("field")
// private List<String> fields;
//
// @SerializedName("method")
// private List<Method> methods;
//
// public JavaConfig(String path, String fileNameEx) {
// super(path, fileNameEx);
// }
//
// public List<String> getImports() {
// return imports;
// }
//
// public List<String> getFields() {
// return fields;
// }
//
// public List<Method> getMethods() {
// return methods;
// }
//
// public void replaceImportStrings(String reg, String applicationId) {
// for (int i = 0, li = imports.size(); i < li; i++) {
// imports.set(i, imports.get(i).replace(reg, applicationId));
// }
// }
//
// @Override
// public String toString() {
// return super.toString() + ", JavaConfig{" +
// "imports=" + imports +
// ", fields=" + fields +
// ", methods=" + methods +
// '}';
// }
// }
//
// Path: ask-app/src/main/java/com/androidstarterkit/injection/model/ManifestConfig.java
// public class ManifestConfig extends Config {
// @SerializedName("element")
// private List<ManifestElement> manifestElements;
//
// public ManifestConfig(String path, String fileNameEx) {
// super(path, fileNameEx);
// }
//
// public List<ManifestElement> getManifestElements() {
// return manifestElements;
// }
//
// @Override
// public String toString() {
// return "ManifestConfig{" +
// "manifestElements=" + manifestElements +
// '}';
// }
// }
| import com.androidstarterkit.injection.model.Config;
import com.androidstarterkit.injection.model.GradleConfig;
import com.androidstarterkit.injection.model.JavaConfig;
import com.androidstarterkit.injection.model.ManifestConfig;
import java.io.File;
import java.util.ArrayList;
import java.util.List; | package com.androidstarterkit.injection;
public class ModuleLoader {
private List<CodeGenerator> codeGenerators;
public ModuleLoader() {
codeGenerators = new ArrayList<>();
}
public void generateCode() {
codeGenerators.forEach(CodeGenerator::apply);
}
public void addCodeGenerator(CodeGenerator codeGenerator) {
if (!codeGenerators.contains(codeGenerator)) {
codeGenerators.add(codeGenerator);
}
}
public void addManifestConfigs(List<ManifestConfig> configs) {
if (configs != null) {
configs.forEach(this::addConfig);
}
}
public void addJavaConfigs(List<JavaConfig> configs) {
if (configs != null) {
configs.forEach(this::addConfig);
}
}
| // Path: ask-app/src/main/java/com/androidstarterkit/injection/model/Config.java
// public class Config {
// @SerializedName("path")
// protected String path;
//
// @SerializedName("file")
// protected String fileNameEx;
//
// public Config(String path, String fileNameEx) {
// this.path = path;
// this.fileNameEx = fileNameEx;
// }
//
// public String getPath() {
// return path;
// }
//
// public String getFullPathname() {
// return path + "/" + fileNameEx;
// }
//
// public void setPath(String path) {
// this.path = path;
// }
//
// public String getFileName() {
// return FileUtils.removeExtension(fileNameEx);
// }
//
// public String getFileNameEx() {
// return fileNameEx;
// }
//
// public void setFileNameEx(String fileNameEx) {
// this.fileNameEx = fileNameEx;
// }
//
// @Override
// public String toString() {
// return "Config{" +
// "path='" + path + '\'' +
// ", fileNameEx='" + fileNameEx + '\'' +
// '}';
// }
// }
//
// Path: ask-app/src/main/java/com/androidstarterkit/injection/model/GradleConfig.java
// public class GradleConfig extends Config {
// @SerializedName("snippet")
// private List<Snippet> snippets;
//
// public GradleConfig(String path, String fileNameEx) {
// this(path, fileNameEx, null);
// }
//
// private GradleConfig(String path, String fileNameEx, List<Snippet> snippets) {
// super(path, fileNameEx);
// this.snippets = snippets;
// }
//
// public List<Snippet> getSnippets() {
// return snippets;
// }
//
// public void addSnippet(Snippet snippet) {
// if (snippets == null) {
// snippets = new ArrayList<>();
// }
//
// snippets.add(snippet);
// }
//
// @Override
// public String toString() {
// return super.toString() + ", GradleConfig{" +
// "path='" + path + '\'' +
// ", fileNameEx='" + fileNameEx + '\'' +
// ", configs=" + snippets +
// '}';
// }
// }
//
// Path: ask-app/src/main/java/com/androidstarterkit/injection/model/JavaConfig.java
// public class JavaConfig extends Config{
// @SerializedName("import")
// private List<String> imports;
//
// @SerializedName("field")
// private List<String> fields;
//
// @SerializedName("method")
// private List<Method> methods;
//
// public JavaConfig(String path, String fileNameEx) {
// super(path, fileNameEx);
// }
//
// public List<String> getImports() {
// return imports;
// }
//
// public List<String> getFields() {
// return fields;
// }
//
// public List<Method> getMethods() {
// return methods;
// }
//
// public void replaceImportStrings(String reg, String applicationId) {
// for (int i = 0, li = imports.size(); i < li; i++) {
// imports.set(i, imports.get(i).replace(reg, applicationId));
// }
// }
//
// @Override
// public String toString() {
// return super.toString() + ", JavaConfig{" +
// "imports=" + imports +
// ", fields=" + fields +
// ", methods=" + methods +
// '}';
// }
// }
//
// Path: ask-app/src/main/java/com/androidstarterkit/injection/model/ManifestConfig.java
// public class ManifestConfig extends Config {
// @SerializedName("element")
// private List<ManifestElement> manifestElements;
//
// public ManifestConfig(String path, String fileNameEx) {
// super(path, fileNameEx);
// }
//
// public List<ManifestElement> getManifestElements() {
// return manifestElements;
// }
//
// @Override
// public String toString() {
// return "ManifestConfig{" +
// "manifestElements=" + manifestElements +
// '}';
// }
// }
// Path: ask-app/src/main/java/com/androidstarterkit/injection/ModuleLoader.java
import com.androidstarterkit.injection.model.Config;
import com.androidstarterkit.injection.model.GradleConfig;
import com.androidstarterkit.injection.model.JavaConfig;
import com.androidstarterkit.injection.model.ManifestConfig;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
package com.androidstarterkit.injection;
public class ModuleLoader {
private List<CodeGenerator> codeGenerators;
public ModuleLoader() {
codeGenerators = new ArrayList<>();
}
public void generateCode() {
codeGenerators.forEach(CodeGenerator::apply);
}
public void addCodeGenerator(CodeGenerator codeGenerator) {
if (!codeGenerators.contains(codeGenerator)) {
codeGenerators.add(codeGenerator);
}
}
public void addManifestConfigs(List<ManifestConfig> configs) {
if (configs != null) {
configs.forEach(this::addConfig);
}
}
public void addJavaConfigs(List<JavaConfig> configs) {
if (configs != null) {
configs.forEach(this::addConfig);
}
}
| public void addGradleConfigs(List<GradleConfig> configs) { |
kimkevin/AndroidStarterKit | ask-app/src/main/java/com/androidstarterkit/injection/ModuleLoader.java | // Path: ask-app/src/main/java/com/androidstarterkit/injection/model/Config.java
// public class Config {
// @SerializedName("path")
// protected String path;
//
// @SerializedName("file")
// protected String fileNameEx;
//
// public Config(String path, String fileNameEx) {
// this.path = path;
// this.fileNameEx = fileNameEx;
// }
//
// public String getPath() {
// return path;
// }
//
// public String getFullPathname() {
// return path + "/" + fileNameEx;
// }
//
// public void setPath(String path) {
// this.path = path;
// }
//
// public String getFileName() {
// return FileUtils.removeExtension(fileNameEx);
// }
//
// public String getFileNameEx() {
// return fileNameEx;
// }
//
// public void setFileNameEx(String fileNameEx) {
// this.fileNameEx = fileNameEx;
// }
//
// @Override
// public String toString() {
// return "Config{" +
// "path='" + path + '\'' +
// ", fileNameEx='" + fileNameEx + '\'' +
// '}';
// }
// }
//
// Path: ask-app/src/main/java/com/androidstarterkit/injection/model/GradleConfig.java
// public class GradleConfig extends Config {
// @SerializedName("snippet")
// private List<Snippet> snippets;
//
// public GradleConfig(String path, String fileNameEx) {
// this(path, fileNameEx, null);
// }
//
// private GradleConfig(String path, String fileNameEx, List<Snippet> snippets) {
// super(path, fileNameEx);
// this.snippets = snippets;
// }
//
// public List<Snippet> getSnippets() {
// return snippets;
// }
//
// public void addSnippet(Snippet snippet) {
// if (snippets == null) {
// snippets = new ArrayList<>();
// }
//
// snippets.add(snippet);
// }
//
// @Override
// public String toString() {
// return super.toString() + ", GradleConfig{" +
// "path='" + path + '\'' +
// ", fileNameEx='" + fileNameEx + '\'' +
// ", configs=" + snippets +
// '}';
// }
// }
//
// Path: ask-app/src/main/java/com/androidstarterkit/injection/model/JavaConfig.java
// public class JavaConfig extends Config{
// @SerializedName("import")
// private List<String> imports;
//
// @SerializedName("field")
// private List<String> fields;
//
// @SerializedName("method")
// private List<Method> methods;
//
// public JavaConfig(String path, String fileNameEx) {
// super(path, fileNameEx);
// }
//
// public List<String> getImports() {
// return imports;
// }
//
// public List<String> getFields() {
// return fields;
// }
//
// public List<Method> getMethods() {
// return methods;
// }
//
// public void replaceImportStrings(String reg, String applicationId) {
// for (int i = 0, li = imports.size(); i < li; i++) {
// imports.set(i, imports.get(i).replace(reg, applicationId));
// }
// }
//
// @Override
// public String toString() {
// return super.toString() + ", JavaConfig{" +
// "imports=" + imports +
// ", fields=" + fields +
// ", methods=" + methods +
// '}';
// }
// }
//
// Path: ask-app/src/main/java/com/androidstarterkit/injection/model/ManifestConfig.java
// public class ManifestConfig extends Config {
// @SerializedName("element")
// private List<ManifestElement> manifestElements;
//
// public ManifestConfig(String path, String fileNameEx) {
// super(path, fileNameEx);
// }
//
// public List<ManifestElement> getManifestElements() {
// return manifestElements;
// }
//
// @Override
// public String toString() {
// return "ManifestConfig{" +
// "manifestElements=" + manifestElements +
// '}';
// }
// }
| import com.androidstarterkit.injection.model.Config;
import com.androidstarterkit.injection.model.GradleConfig;
import com.androidstarterkit.injection.model.JavaConfig;
import com.androidstarterkit.injection.model.ManifestConfig;
import java.io.File;
import java.util.ArrayList;
import java.util.List; | package com.androidstarterkit.injection;
public class ModuleLoader {
private List<CodeGenerator> codeGenerators;
public ModuleLoader() {
codeGenerators = new ArrayList<>();
}
public void generateCode() {
codeGenerators.forEach(CodeGenerator::apply);
}
public void addCodeGenerator(CodeGenerator codeGenerator) {
if (!codeGenerators.contains(codeGenerator)) {
codeGenerators.add(codeGenerator);
}
}
public void addManifestConfigs(List<ManifestConfig> configs) {
if (configs != null) {
configs.forEach(this::addConfig);
}
}
public void addJavaConfigs(List<JavaConfig> configs) {
if (configs != null) {
configs.forEach(this::addConfig);
}
}
public void addGradleConfigs(List<GradleConfig> configs) {
if (configs != null) {
configs.forEach(this::addConfig);
}
}
| // Path: ask-app/src/main/java/com/androidstarterkit/injection/model/Config.java
// public class Config {
// @SerializedName("path")
// protected String path;
//
// @SerializedName("file")
// protected String fileNameEx;
//
// public Config(String path, String fileNameEx) {
// this.path = path;
// this.fileNameEx = fileNameEx;
// }
//
// public String getPath() {
// return path;
// }
//
// public String getFullPathname() {
// return path + "/" + fileNameEx;
// }
//
// public void setPath(String path) {
// this.path = path;
// }
//
// public String getFileName() {
// return FileUtils.removeExtension(fileNameEx);
// }
//
// public String getFileNameEx() {
// return fileNameEx;
// }
//
// public void setFileNameEx(String fileNameEx) {
// this.fileNameEx = fileNameEx;
// }
//
// @Override
// public String toString() {
// return "Config{" +
// "path='" + path + '\'' +
// ", fileNameEx='" + fileNameEx + '\'' +
// '}';
// }
// }
//
// Path: ask-app/src/main/java/com/androidstarterkit/injection/model/GradleConfig.java
// public class GradleConfig extends Config {
// @SerializedName("snippet")
// private List<Snippet> snippets;
//
// public GradleConfig(String path, String fileNameEx) {
// this(path, fileNameEx, null);
// }
//
// private GradleConfig(String path, String fileNameEx, List<Snippet> snippets) {
// super(path, fileNameEx);
// this.snippets = snippets;
// }
//
// public List<Snippet> getSnippets() {
// return snippets;
// }
//
// public void addSnippet(Snippet snippet) {
// if (snippets == null) {
// snippets = new ArrayList<>();
// }
//
// snippets.add(snippet);
// }
//
// @Override
// public String toString() {
// return super.toString() + ", GradleConfig{" +
// "path='" + path + '\'' +
// ", fileNameEx='" + fileNameEx + '\'' +
// ", configs=" + snippets +
// '}';
// }
// }
//
// Path: ask-app/src/main/java/com/androidstarterkit/injection/model/JavaConfig.java
// public class JavaConfig extends Config{
// @SerializedName("import")
// private List<String> imports;
//
// @SerializedName("field")
// private List<String> fields;
//
// @SerializedName("method")
// private List<Method> methods;
//
// public JavaConfig(String path, String fileNameEx) {
// super(path, fileNameEx);
// }
//
// public List<String> getImports() {
// return imports;
// }
//
// public List<String> getFields() {
// return fields;
// }
//
// public List<Method> getMethods() {
// return methods;
// }
//
// public void replaceImportStrings(String reg, String applicationId) {
// for (int i = 0, li = imports.size(); i < li; i++) {
// imports.set(i, imports.get(i).replace(reg, applicationId));
// }
// }
//
// @Override
// public String toString() {
// return super.toString() + ", JavaConfig{" +
// "imports=" + imports +
// ", fields=" + fields +
// ", methods=" + methods +
// '}';
// }
// }
//
// Path: ask-app/src/main/java/com/androidstarterkit/injection/model/ManifestConfig.java
// public class ManifestConfig extends Config {
// @SerializedName("element")
// private List<ManifestElement> manifestElements;
//
// public ManifestConfig(String path, String fileNameEx) {
// super(path, fileNameEx);
// }
//
// public List<ManifestElement> getManifestElements() {
// return manifestElements;
// }
//
// @Override
// public String toString() {
// return "ManifestConfig{" +
// "manifestElements=" + manifestElements +
// '}';
// }
// }
// Path: ask-app/src/main/java/com/androidstarterkit/injection/ModuleLoader.java
import com.androidstarterkit.injection.model.Config;
import com.androidstarterkit.injection.model.GradleConfig;
import com.androidstarterkit.injection.model.JavaConfig;
import com.androidstarterkit.injection.model.ManifestConfig;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
package com.androidstarterkit.injection;
public class ModuleLoader {
private List<CodeGenerator> codeGenerators;
public ModuleLoader() {
codeGenerators = new ArrayList<>();
}
public void generateCode() {
codeGenerators.forEach(CodeGenerator::apply);
}
public void addCodeGenerator(CodeGenerator codeGenerator) {
if (!codeGenerators.contains(codeGenerator)) {
codeGenerators.add(codeGenerator);
}
}
public void addManifestConfigs(List<ManifestConfig> configs) {
if (configs != null) {
configs.forEach(this::addConfig);
}
}
public void addJavaConfigs(List<JavaConfig> configs) {
if (configs != null) {
configs.forEach(this::addConfig);
}
}
public void addGradleConfigs(List<GradleConfig> configs) {
if (configs != null) {
configs.forEach(this::addConfig);
}
}
| private void addConfig(Config config) { |
kimkevin/AndroidStarterKit | ask-app/src/main/java/com/androidstarterkit/util/SyntaxUtils.java | // Path: ask-app/src/main/java/com/androidstarterkit/constraints/SyntaxConstraints.java
// public class SyntaxConstraints {
// public static final String IDENTIFIER_PACKAGE = "package";
// public static final String IDENTIFIER_IMPORT = "import";
//
// public static final String REPLACE_STRING = "%%";
// public static final String DEFAULT_INDENT = " ";
// public static final String NEWLINE = "\n";
// }
| import com.androidstarterkit.constraints.SyntaxConstraints;
import java.util.ArrayList;
import java.util.List; | package com.androidstarterkit.util;
public class SyntaxUtils {
public static String createStartElement(String elemetName) {
return "<" + elemetName + ">";
}
public static String createEndElement(String elementName) {
return "</" + elementName + ">";
}
public static boolean hasStartElement(String codeLine, String resourceTypeName) {
return codeLine.contains("<" + resourceTypeName);
}
public static boolean hasEndElement(String codeLine, String resourceTypeName) {
return codeLine.contains("</" + resourceTypeName) || codeLine.contains("/>");
}
public static List<String> appendIndentForPrefix(List<String> codelines, int indentCount) {
List<String> indentCodelines = new ArrayList<>();
for (String codeline : codelines) {
indentCodelines.add(appendIndentForPrefix(codeline, indentCount));
}
return indentCodelines;
}
public static String appendIndentForPrefix(String codeline, int indentCount) {
String indent = "";
for (int i = 0; i < indentCount; i++) { | // Path: ask-app/src/main/java/com/androidstarterkit/constraints/SyntaxConstraints.java
// public class SyntaxConstraints {
// public static final String IDENTIFIER_PACKAGE = "package";
// public static final String IDENTIFIER_IMPORT = "import";
//
// public static final String REPLACE_STRING = "%%";
// public static final String DEFAULT_INDENT = " ";
// public static final String NEWLINE = "\n";
// }
// Path: ask-app/src/main/java/com/androidstarterkit/util/SyntaxUtils.java
import com.androidstarterkit.constraints.SyntaxConstraints;
import java.util.ArrayList;
import java.util.List;
package com.androidstarterkit.util;
public class SyntaxUtils {
public static String createStartElement(String elemetName) {
return "<" + elemetName + ">";
}
public static String createEndElement(String elementName) {
return "</" + elementName + ">";
}
public static boolean hasStartElement(String codeLine, String resourceTypeName) {
return codeLine.contains("<" + resourceTypeName);
}
public static boolean hasEndElement(String codeLine, String resourceTypeName) {
return codeLine.contains("</" + resourceTypeName) || codeLine.contains("/>");
}
public static List<String> appendIndentForPrefix(List<String> codelines, int indentCount) {
List<String> indentCodelines = new ArrayList<>();
for (String codeline : codelines) {
indentCodelines.add(appendIndentForPrefix(codeline, indentCount));
}
return indentCodelines;
}
public static String appendIndentForPrefix(String codeline, int indentCount) {
String indent = "";
for (int i = 0; i < indentCount; i++) { | indent += SyntaxConstraints.DEFAULT_INDENT; |
kimkevin/AndroidStarterKit | ask-app/src/main/java/com/androidstarterkit/injection/file/android/InjectionXmlFile.java | // Path: ask-app/src/main/java/com/androidstarterkit/injection/file/base/InjectionBaseFile.java
// public class InjectionBaseFile<T extends Config> extends File implements CodeGenerator<T> {
// protected List<String> codelines;
// protected List<T> configs;
//
// public InjectionBaseFile(String fullPathname) {
// super(fullPathname);
//
// codelines = FileUtils.readFileAsString(this);
// configs = new ArrayList<>();
// }
//
// public List<String> getCodelines() {
// return codelines;
// }
//
// public void setCodelines(List<String> codelines) {
// this.codelines = codelines;
// }
//
// public void setCodeline(int index, String codeline) {
// codelines.set(index, codeline);
// }
//
// public void addCodeline(int index, String codeline) {
// codelines.add(index, codeline);
// }
//
// public void addCodelines(int index, List<String> codelines) {
// this.codelines.addAll(index, codelines);
// }
//
// public void removeCodeline(int index) {
// codelines.remove(index);
// }
//
// @Override
// public void addConfig(T config) {
// if (configs == null) {
// configs = new ArrayList<>();
// }
//
// configs.add(config);
// }
//
// @Override
// public void addConfig(List<T> configs) {
// if (this.configs == null) {
// this.configs = new ArrayList<>();
// }
//
// this.configs.addAll(configs);
// }
//
// @Override
// public List<T> getConfigs() {
// return configs;
// }
//
// @Override
// public void apply() {
// FileUtils.writeFile(this, codelines);
// }
//
// public void print() {
// codelines.forEach(System.out::println);
// }
// }
//
// Path: ask-app/src/main/java/com/androidstarterkit/injection/model/ManifestConfig.java
// public class ManifestConfig extends Config {
// @SerializedName("element")
// private List<ManifestElement> manifestElements;
//
// public ManifestConfig(String path, String fileNameEx) {
// super(path, fileNameEx);
// }
//
// public List<ManifestElement> getManifestElements() {
// return manifestElements;
// }
//
// @Override
// public String toString() {
// return "ManifestConfig{" +
// "manifestElements=" + manifestElements +
// '}';
// }
// }
//
// Path: ask-app/src/main/java/com/androidstarterkit/tool/XmlDomReader.java
// public class XmlDomReader {
// private static final String TAG = XmlDomReader.class.getSimpleName();
//
// private Document document;
//
// public XmlDomReader(File file) {
// DocumentBuilderFactory builderFactory = DocumentBuilderFactory.newInstance();
//
// DocumentBuilder documentBuilder;
// try {
// documentBuilder = builderFactory.newDocumentBuilder();
// document = documentBuilder.parse(file);
// } catch (ParserConfigurationException | SAXException | IOException e) {
// throw new IllegalDocumentException("failed to create document : " + file.getPath());
// }
// document.getDocumentElement().normalize();
// }
//
// public Document getDocument() {
// return document;
// }
//
// public Element getRootNode() {
// return document.getDocumentElement();
// }
// }
//
// Path: ask-app/src/main/java/com/androidstarterkit/tool/XmlDomWriter.java
// public class XmlDomWriter {
//
// public void writeDocument(File file, Document document) throws TransformerException, IOException {
// document.setXmlStandalone(true);
//
// TransformerFactory tf = TransformerFactory.newInstance();
// tf.setAttribute("indent-number", new Integer(4));
//
// Transformer transformer = tf.newTransformer();
// transformer.setOutputProperty(OutputKeys.INDENT, "yes");
// transformer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "4");
// DOMSource source = new DOMSource(document);
//
// FileWriter fileWriter = new FileWriter(file);
// StreamResult writeStream = new StreamResult(fileWriter);
//
// transformer.transform(source, writeStream);
// }
// }
| import com.androidstarterkit.injection.file.base.InjectionBaseFile;
import com.androidstarterkit.injection.model.ManifestConfig;
import com.androidstarterkit.tool.XmlDomReader;
import com.androidstarterkit.tool.XmlDomWriter;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import java.io.IOException;
import javax.xml.transform.TransformerException; | package com.androidstarterkit.injection.file.android;
public class InjectionXmlFile extends InjectionBaseFile<ManifestConfig> {
protected Document document;
protected Element rootElement;
public InjectionXmlFile(String fullPathname) {
super(fullPathname);
| // Path: ask-app/src/main/java/com/androidstarterkit/injection/file/base/InjectionBaseFile.java
// public class InjectionBaseFile<T extends Config> extends File implements CodeGenerator<T> {
// protected List<String> codelines;
// protected List<T> configs;
//
// public InjectionBaseFile(String fullPathname) {
// super(fullPathname);
//
// codelines = FileUtils.readFileAsString(this);
// configs = new ArrayList<>();
// }
//
// public List<String> getCodelines() {
// return codelines;
// }
//
// public void setCodelines(List<String> codelines) {
// this.codelines = codelines;
// }
//
// public void setCodeline(int index, String codeline) {
// codelines.set(index, codeline);
// }
//
// public void addCodeline(int index, String codeline) {
// codelines.add(index, codeline);
// }
//
// public void addCodelines(int index, List<String> codelines) {
// this.codelines.addAll(index, codelines);
// }
//
// public void removeCodeline(int index) {
// codelines.remove(index);
// }
//
// @Override
// public void addConfig(T config) {
// if (configs == null) {
// configs = new ArrayList<>();
// }
//
// configs.add(config);
// }
//
// @Override
// public void addConfig(List<T> configs) {
// if (this.configs == null) {
// this.configs = new ArrayList<>();
// }
//
// this.configs.addAll(configs);
// }
//
// @Override
// public List<T> getConfigs() {
// return configs;
// }
//
// @Override
// public void apply() {
// FileUtils.writeFile(this, codelines);
// }
//
// public void print() {
// codelines.forEach(System.out::println);
// }
// }
//
// Path: ask-app/src/main/java/com/androidstarterkit/injection/model/ManifestConfig.java
// public class ManifestConfig extends Config {
// @SerializedName("element")
// private List<ManifestElement> manifestElements;
//
// public ManifestConfig(String path, String fileNameEx) {
// super(path, fileNameEx);
// }
//
// public List<ManifestElement> getManifestElements() {
// return manifestElements;
// }
//
// @Override
// public String toString() {
// return "ManifestConfig{" +
// "manifestElements=" + manifestElements +
// '}';
// }
// }
//
// Path: ask-app/src/main/java/com/androidstarterkit/tool/XmlDomReader.java
// public class XmlDomReader {
// private static final String TAG = XmlDomReader.class.getSimpleName();
//
// private Document document;
//
// public XmlDomReader(File file) {
// DocumentBuilderFactory builderFactory = DocumentBuilderFactory.newInstance();
//
// DocumentBuilder documentBuilder;
// try {
// documentBuilder = builderFactory.newDocumentBuilder();
// document = documentBuilder.parse(file);
// } catch (ParserConfigurationException | SAXException | IOException e) {
// throw new IllegalDocumentException("failed to create document : " + file.getPath());
// }
// document.getDocumentElement().normalize();
// }
//
// public Document getDocument() {
// return document;
// }
//
// public Element getRootNode() {
// return document.getDocumentElement();
// }
// }
//
// Path: ask-app/src/main/java/com/androidstarterkit/tool/XmlDomWriter.java
// public class XmlDomWriter {
//
// public void writeDocument(File file, Document document) throws TransformerException, IOException {
// document.setXmlStandalone(true);
//
// TransformerFactory tf = TransformerFactory.newInstance();
// tf.setAttribute("indent-number", new Integer(4));
//
// Transformer transformer = tf.newTransformer();
// transformer.setOutputProperty(OutputKeys.INDENT, "yes");
// transformer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "4");
// DOMSource source = new DOMSource(document);
//
// FileWriter fileWriter = new FileWriter(file);
// StreamResult writeStream = new StreamResult(fileWriter);
//
// transformer.transform(source, writeStream);
// }
// }
// Path: ask-app/src/main/java/com/androidstarterkit/injection/file/android/InjectionXmlFile.java
import com.androidstarterkit.injection.file.base.InjectionBaseFile;
import com.androidstarterkit.injection.model.ManifestConfig;
import com.androidstarterkit.tool.XmlDomReader;
import com.androidstarterkit.tool.XmlDomWriter;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import java.io.IOException;
import javax.xml.transform.TransformerException;
package com.androidstarterkit.injection.file.android;
public class InjectionXmlFile extends InjectionBaseFile<ManifestConfig> {
protected Document document;
protected Element rootElement;
public InjectionXmlFile(String fullPathname) {
super(fullPathname);
| XmlDomReader xmlDomParser = new XmlDomReader(this); |
kimkevin/AndroidStarterKit | ask-app/src/main/java/com/androidstarterkit/injection/file/android/InjectionXmlFile.java | // Path: ask-app/src/main/java/com/androidstarterkit/injection/file/base/InjectionBaseFile.java
// public class InjectionBaseFile<T extends Config> extends File implements CodeGenerator<T> {
// protected List<String> codelines;
// protected List<T> configs;
//
// public InjectionBaseFile(String fullPathname) {
// super(fullPathname);
//
// codelines = FileUtils.readFileAsString(this);
// configs = new ArrayList<>();
// }
//
// public List<String> getCodelines() {
// return codelines;
// }
//
// public void setCodelines(List<String> codelines) {
// this.codelines = codelines;
// }
//
// public void setCodeline(int index, String codeline) {
// codelines.set(index, codeline);
// }
//
// public void addCodeline(int index, String codeline) {
// codelines.add(index, codeline);
// }
//
// public void addCodelines(int index, List<String> codelines) {
// this.codelines.addAll(index, codelines);
// }
//
// public void removeCodeline(int index) {
// codelines.remove(index);
// }
//
// @Override
// public void addConfig(T config) {
// if (configs == null) {
// configs = new ArrayList<>();
// }
//
// configs.add(config);
// }
//
// @Override
// public void addConfig(List<T> configs) {
// if (this.configs == null) {
// this.configs = new ArrayList<>();
// }
//
// this.configs.addAll(configs);
// }
//
// @Override
// public List<T> getConfigs() {
// return configs;
// }
//
// @Override
// public void apply() {
// FileUtils.writeFile(this, codelines);
// }
//
// public void print() {
// codelines.forEach(System.out::println);
// }
// }
//
// Path: ask-app/src/main/java/com/androidstarterkit/injection/model/ManifestConfig.java
// public class ManifestConfig extends Config {
// @SerializedName("element")
// private List<ManifestElement> manifestElements;
//
// public ManifestConfig(String path, String fileNameEx) {
// super(path, fileNameEx);
// }
//
// public List<ManifestElement> getManifestElements() {
// return manifestElements;
// }
//
// @Override
// public String toString() {
// return "ManifestConfig{" +
// "manifestElements=" + manifestElements +
// '}';
// }
// }
//
// Path: ask-app/src/main/java/com/androidstarterkit/tool/XmlDomReader.java
// public class XmlDomReader {
// private static final String TAG = XmlDomReader.class.getSimpleName();
//
// private Document document;
//
// public XmlDomReader(File file) {
// DocumentBuilderFactory builderFactory = DocumentBuilderFactory.newInstance();
//
// DocumentBuilder documentBuilder;
// try {
// documentBuilder = builderFactory.newDocumentBuilder();
// document = documentBuilder.parse(file);
// } catch (ParserConfigurationException | SAXException | IOException e) {
// throw new IllegalDocumentException("failed to create document : " + file.getPath());
// }
// document.getDocumentElement().normalize();
// }
//
// public Document getDocument() {
// return document;
// }
//
// public Element getRootNode() {
// return document.getDocumentElement();
// }
// }
//
// Path: ask-app/src/main/java/com/androidstarterkit/tool/XmlDomWriter.java
// public class XmlDomWriter {
//
// public void writeDocument(File file, Document document) throws TransformerException, IOException {
// document.setXmlStandalone(true);
//
// TransformerFactory tf = TransformerFactory.newInstance();
// tf.setAttribute("indent-number", new Integer(4));
//
// Transformer transformer = tf.newTransformer();
// transformer.setOutputProperty(OutputKeys.INDENT, "yes");
// transformer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "4");
// DOMSource source = new DOMSource(document);
//
// FileWriter fileWriter = new FileWriter(file);
// StreamResult writeStream = new StreamResult(fileWriter);
//
// transformer.transform(source, writeStream);
// }
// }
| import com.androidstarterkit.injection.file.base.InjectionBaseFile;
import com.androidstarterkit.injection.model.ManifestConfig;
import com.androidstarterkit.tool.XmlDomReader;
import com.androidstarterkit.tool.XmlDomWriter;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import java.io.IOException;
import javax.xml.transform.TransformerException; | package com.androidstarterkit.injection.file.android;
public class InjectionXmlFile extends InjectionBaseFile<ManifestConfig> {
protected Document document;
protected Element rootElement;
public InjectionXmlFile(String fullPathname) {
super(fullPathname);
XmlDomReader xmlDomParser = new XmlDomReader(this);
document = xmlDomParser.getDocument();
rootElement = document.getDocumentElement();
}
@Override
public void apply() { | // Path: ask-app/src/main/java/com/androidstarterkit/injection/file/base/InjectionBaseFile.java
// public class InjectionBaseFile<T extends Config> extends File implements CodeGenerator<T> {
// protected List<String> codelines;
// protected List<T> configs;
//
// public InjectionBaseFile(String fullPathname) {
// super(fullPathname);
//
// codelines = FileUtils.readFileAsString(this);
// configs = new ArrayList<>();
// }
//
// public List<String> getCodelines() {
// return codelines;
// }
//
// public void setCodelines(List<String> codelines) {
// this.codelines = codelines;
// }
//
// public void setCodeline(int index, String codeline) {
// codelines.set(index, codeline);
// }
//
// public void addCodeline(int index, String codeline) {
// codelines.add(index, codeline);
// }
//
// public void addCodelines(int index, List<String> codelines) {
// this.codelines.addAll(index, codelines);
// }
//
// public void removeCodeline(int index) {
// codelines.remove(index);
// }
//
// @Override
// public void addConfig(T config) {
// if (configs == null) {
// configs = new ArrayList<>();
// }
//
// configs.add(config);
// }
//
// @Override
// public void addConfig(List<T> configs) {
// if (this.configs == null) {
// this.configs = new ArrayList<>();
// }
//
// this.configs.addAll(configs);
// }
//
// @Override
// public List<T> getConfigs() {
// return configs;
// }
//
// @Override
// public void apply() {
// FileUtils.writeFile(this, codelines);
// }
//
// public void print() {
// codelines.forEach(System.out::println);
// }
// }
//
// Path: ask-app/src/main/java/com/androidstarterkit/injection/model/ManifestConfig.java
// public class ManifestConfig extends Config {
// @SerializedName("element")
// private List<ManifestElement> manifestElements;
//
// public ManifestConfig(String path, String fileNameEx) {
// super(path, fileNameEx);
// }
//
// public List<ManifestElement> getManifestElements() {
// return manifestElements;
// }
//
// @Override
// public String toString() {
// return "ManifestConfig{" +
// "manifestElements=" + manifestElements +
// '}';
// }
// }
//
// Path: ask-app/src/main/java/com/androidstarterkit/tool/XmlDomReader.java
// public class XmlDomReader {
// private static final String TAG = XmlDomReader.class.getSimpleName();
//
// private Document document;
//
// public XmlDomReader(File file) {
// DocumentBuilderFactory builderFactory = DocumentBuilderFactory.newInstance();
//
// DocumentBuilder documentBuilder;
// try {
// documentBuilder = builderFactory.newDocumentBuilder();
// document = documentBuilder.parse(file);
// } catch (ParserConfigurationException | SAXException | IOException e) {
// throw new IllegalDocumentException("failed to create document : " + file.getPath());
// }
// document.getDocumentElement().normalize();
// }
//
// public Document getDocument() {
// return document;
// }
//
// public Element getRootNode() {
// return document.getDocumentElement();
// }
// }
//
// Path: ask-app/src/main/java/com/androidstarterkit/tool/XmlDomWriter.java
// public class XmlDomWriter {
//
// public void writeDocument(File file, Document document) throws TransformerException, IOException {
// document.setXmlStandalone(true);
//
// TransformerFactory tf = TransformerFactory.newInstance();
// tf.setAttribute("indent-number", new Integer(4));
//
// Transformer transformer = tf.newTransformer();
// transformer.setOutputProperty(OutputKeys.INDENT, "yes");
// transformer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "4");
// DOMSource source = new DOMSource(document);
//
// FileWriter fileWriter = new FileWriter(file);
// StreamResult writeStream = new StreamResult(fileWriter);
//
// transformer.transform(source, writeStream);
// }
// }
// Path: ask-app/src/main/java/com/androidstarterkit/injection/file/android/InjectionXmlFile.java
import com.androidstarterkit.injection.file.base.InjectionBaseFile;
import com.androidstarterkit.injection.model.ManifestConfig;
import com.androidstarterkit.tool.XmlDomReader;
import com.androidstarterkit.tool.XmlDomWriter;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import java.io.IOException;
import javax.xml.transform.TransformerException;
package com.androidstarterkit.injection.file.android;
public class InjectionXmlFile extends InjectionBaseFile<ManifestConfig> {
protected Document document;
protected Element rootElement;
public InjectionXmlFile(String fullPathname) {
super(fullPathname);
XmlDomReader xmlDomParser = new XmlDomReader(this);
document = xmlDomParser.getDocument();
rootElement = document.getDocumentElement();
}
@Override
public void apply() { | XmlDomWriter xmlDomWriter = new XmlDomWriter(); |
kimkevin/AndroidStarterKit | ask-app/src/main/java/com/androidstarterkit/injection/model/Method.java | // Path: ask-app/src/main/java/com/androidstarterkit/util/SyntaxUtils.java
// public class SyntaxUtils {
// public static String createStartElement(String elemetName) {
// return "<" + elemetName + ">";
// }
//
// public static String createEndElement(String elementName) {
// return "</" + elementName + ">";
// }
//
// public static boolean hasStartElement(String codeLine, String resourceTypeName) {
// return codeLine.contains("<" + resourceTypeName);
// }
//
// public static boolean hasEndElement(String codeLine, String resourceTypeName) {
// return codeLine.contains("</" + resourceTypeName) || codeLine.contains("/>");
// }
//
// public static List<String> appendIndentForPrefix(List<String> codelines, int indentCount) {
// List<String> indentCodelines = new ArrayList<>();
//
// for (String codeline : codelines) {
// indentCodelines.add(appendIndentForPrefix(codeline, indentCount));
// }
//
// return indentCodelines;
// }
//
// public static String appendIndentForPrefix(String codeline, int indentCount) {
// String indent = "";
// for (int i = 0; i < indentCount; i++) {
// indent += SyntaxConstraints.DEFAULT_INDENT;
// }
//
// return indent + codeline;
// }
//
// public static String createIndentAsString(int depth) {
// String intent = "";
// for (int i = 0; i < depth; i++) {
// intent += " ";
// }
// return intent;
// }
// }
| import com.androidstarterkit.util.SyntaxUtils;
import com.google.gson.annotations.SerializedName;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors; | ", variable='" + variable + '\'' +
'}';
}
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public List<String> getLines() {
return lines;
}
public boolean isImported() {
return isImported;
}
public void setImported(boolean imported) {
isImported = imported;
}
public List<String> createMethodAsString(int indentCount) {
List<String> result = new ArrayList<>();
result.add("");
result.addAll(annotations.stream() | // Path: ask-app/src/main/java/com/androidstarterkit/util/SyntaxUtils.java
// public class SyntaxUtils {
// public static String createStartElement(String elemetName) {
// return "<" + elemetName + ">";
// }
//
// public static String createEndElement(String elementName) {
// return "</" + elementName + ">";
// }
//
// public static boolean hasStartElement(String codeLine, String resourceTypeName) {
// return codeLine.contains("<" + resourceTypeName);
// }
//
// public static boolean hasEndElement(String codeLine, String resourceTypeName) {
// return codeLine.contains("</" + resourceTypeName) || codeLine.contains("/>");
// }
//
// public static List<String> appendIndentForPrefix(List<String> codelines, int indentCount) {
// List<String> indentCodelines = new ArrayList<>();
//
// for (String codeline : codelines) {
// indentCodelines.add(appendIndentForPrefix(codeline, indentCount));
// }
//
// return indentCodelines;
// }
//
// public static String appendIndentForPrefix(String codeline, int indentCount) {
// String indent = "";
// for (int i = 0; i < indentCount; i++) {
// indent += SyntaxConstraints.DEFAULT_INDENT;
// }
//
// return indent + codeline;
// }
//
// public static String createIndentAsString(int depth) {
// String intent = "";
// for (int i = 0; i < depth; i++) {
// intent += " ";
// }
// return intent;
// }
// }
// Path: ask-app/src/main/java/com/androidstarterkit/injection/model/Method.java
import com.androidstarterkit.util.SyntaxUtils;
import com.google.gson.annotations.SerializedName;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
", variable='" + variable + '\'' +
'}';
}
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public List<String> getLines() {
return lines;
}
public boolean isImported() {
return isImported;
}
public void setImported(boolean imported) {
isImported = imported;
}
public List<String> createMethodAsString(int indentCount) {
List<String> result = new ArrayList<>();
result.add("");
result.addAll(annotations.stream() | .map(annotation -> SyntaxUtils.createIndentAsString(indentCount) + annotation) |
kimkevin/AndroidStarterKit | ask-remote-module/src/main/java/com/androidstarterkit/module/sample/activity/GridViewActivity.java | // Path: ask-remote-module/src/main/java/com/androidstarterkit/module/ui/view/GridViewFragment.java
// public class GridViewFragment extends Fragment {
// private static List<AndroidPlatform> platforms = new ArrayList<>();
//
// static {
// platforms.add(new AndroidPlatform("applepie", "1.0", 1));
// platforms.add(new AndroidPlatform("bananabread", "1.1", 2));
// platforms.add(new AndroidPlatform("cupcake", "1.5", 3));
// platforms.add(new AndroidPlatform("donut", "1.6", 4));
// platforms.add(new AndroidPlatform("eclair", "2.0", 5));
// platforms.add(new AndroidPlatform("froyo", "2.2", 8));
// platforms.add(new AndroidPlatform("gingerbread", "2.3", 9));
// platforms.add(new AndroidPlatform("honeycomb", "3.0", 11));
// platforms.add(new AndroidPlatform("icecreamsandwich", "4.0", 14));
// platforms.add(new AndroidPlatform("kitkat", "4.4", 19));
// platforms.add(new AndroidPlatform("lollipop", "5.0", 21));
// platforms.add(new AndroidPlatform("marshmallow", "6.0", 23));
// platforms.add(new AndroidPlatform("nougat", "7.0", 24));
// }
//
// @Nullable
// @Override
// public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
// View view = inflater.inflate(R.layout.fragment_gridview_main, null);
//
// final int colSize = 3;
// final int columnWidth = getScreenWidth() / colSize;
//
// GridView gridView = (GridView) view.findViewById(R.id.grid_view);
// gridView.setNumColumns(colSize);
// gridView.setColumnWidth(columnWidth);
// gridView.setAdapter(new GridViewAdapter(getActivity(), platforms, columnWidth));
// return view;
// }
//
// private int getScreenWidth() {
// DisplayMetrics metrics = new DisplayMetrics();
// getActivity().getWindowManager().getDefaultDisplay().getMetrics(metrics);
// return metrics.widthPixels;
// }
// }
| import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import com.androidstarterkit.module.R;
import com.androidstarterkit.module.ui.view.GridViewFragment; | package com.androidstarterkit.module.sample.activity;
public class GridViewActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_sample_main);
if (savedInstanceState == null) {
getSupportFragmentManager()
.beginTransaction() | // Path: ask-remote-module/src/main/java/com/androidstarterkit/module/ui/view/GridViewFragment.java
// public class GridViewFragment extends Fragment {
// private static List<AndroidPlatform> platforms = new ArrayList<>();
//
// static {
// platforms.add(new AndroidPlatform("applepie", "1.0", 1));
// platforms.add(new AndroidPlatform("bananabread", "1.1", 2));
// platforms.add(new AndroidPlatform("cupcake", "1.5", 3));
// platforms.add(new AndroidPlatform("donut", "1.6", 4));
// platforms.add(new AndroidPlatform("eclair", "2.0", 5));
// platforms.add(new AndroidPlatform("froyo", "2.2", 8));
// platforms.add(new AndroidPlatform("gingerbread", "2.3", 9));
// platforms.add(new AndroidPlatform("honeycomb", "3.0", 11));
// platforms.add(new AndroidPlatform("icecreamsandwich", "4.0", 14));
// platforms.add(new AndroidPlatform("kitkat", "4.4", 19));
// platforms.add(new AndroidPlatform("lollipop", "5.0", 21));
// platforms.add(new AndroidPlatform("marshmallow", "6.0", 23));
// platforms.add(new AndroidPlatform("nougat", "7.0", 24));
// }
//
// @Nullable
// @Override
// public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
// View view = inflater.inflate(R.layout.fragment_gridview_main, null);
//
// final int colSize = 3;
// final int columnWidth = getScreenWidth() / colSize;
//
// GridView gridView = (GridView) view.findViewById(R.id.grid_view);
// gridView.setNumColumns(colSize);
// gridView.setColumnWidth(columnWidth);
// gridView.setAdapter(new GridViewAdapter(getActivity(), platforms, columnWidth));
// return view;
// }
//
// private int getScreenWidth() {
// DisplayMetrics metrics = new DisplayMetrics();
// getActivity().getWindowManager().getDefaultDisplay().getMetrics(metrics);
// return metrics.widthPixels;
// }
// }
// Path: ask-remote-module/src/main/java/com/androidstarterkit/module/sample/activity/GridViewActivity.java
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import com.androidstarterkit.module.R;
import com.androidstarterkit.module.ui.view.GridViewFragment;
package com.androidstarterkit.module.sample.activity;
public class GridViewActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_sample_main);
if (savedInstanceState == null) {
getSupportFragmentManager()
.beginTransaction() | .add(R.id.container, new GridViewFragment()) |
kimkevin/AndroidStarterKit | ask-remote-module/src/main/java/com/androidstarterkit/module/ui/adapter/GridViewAdapter.java | // Path: ask-remote-module/src/main/java/com/androidstarterkit/module/data/AndroidPlatform.java
// public class AndroidPlatform {
// private static final String FILE_PATH = "https://raw.githubusercontent.com/kimkevin/AndroidStarterKit/master/assets/";
// private static final String EXTENSION_NAME = ".png";
//
// private String name;
// private String verCode;
// private int apiLevel;
// private String logoUrl;
//
// public AndroidPlatform(String name, String verCode, int apiLevel) {
// this.name = name;
// this.verCode = verCode;
// this.apiLevel = apiLevel;
// this.logoUrl = FILE_PATH + name + EXTENSION_NAME;
// }
//
// public String getName() {
// return name.toUpperCase() + " " + apiLevel;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getVerCode() {
// return "Android " + verCode;
// }
//
// public void setVerCode(String version) {
// this.verCode = version;
// }
//
// public int getApiLevel() {
// return apiLevel;
// }
//
// public void setApiLevel(int apiLevel) {
// this.apiLevel = apiLevel;
// }
//
// public String getLogoUrl() {
// return logoUrl;
// }
//
// public void setLogoUrl(String logoUrl) {
// this.logoUrl = logoUrl;
// }
// }
| import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AbsListView;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;
import com.androidstarterkit.module.R;
import com.androidstarterkit.module.data.AndroidPlatform;
import com.bumptech.glide.Glide;
import java.util.List; | package com.androidstarterkit.module.ui.adapter;
public class GridViewAdapter extends BaseAdapter {
private Context context; | // Path: ask-remote-module/src/main/java/com/androidstarterkit/module/data/AndroidPlatform.java
// public class AndroidPlatform {
// private static final String FILE_PATH = "https://raw.githubusercontent.com/kimkevin/AndroidStarterKit/master/assets/";
// private static final String EXTENSION_NAME = ".png";
//
// private String name;
// private String verCode;
// private int apiLevel;
// private String logoUrl;
//
// public AndroidPlatform(String name, String verCode, int apiLevel) {
// this.name = name;
// this.verCode = verCode;
// this.apiLevel = apiLevel;
// this.logoUrl = FILE_PATH + name + EXTENSION_NAME;
// }
//
// public String getName() {
// return name.toUpperCase() + " " + apiLevel;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getVerCode() {
// return "Android " + verCode;
// }
//
// public void setVerCode(String version) {
// this.verCode = version;
// }
//
// public int getApiLevel() {
// return apiLevel;
// }
//
// public void setApiLevel(int apiLevel) {
// this.apiLevel = apiLevel;
// }
//
// public String getLogoUrl() {
// return logoUrl;
// }
//
// public void setLogoUrl(String logoUrl) {
// this.logoUrl = logoUrl;
// }
// }
// Path: ask-remote-module/src/main/java/com/androidstarterkit/module/ui/adapter/GridViewAdapter.java
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AbsListView;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;
import com.androidstarterkit.module.R;
import com.androidstarterkit.module.data.AndroidPlatform;
import com.bumptech.glide.Glide;
import java.util.List;
package com.androidstarterkit.module.ui.adapter;
public class GridViewAdapter extends BaseAdapter {
private Context context; | private List<AndroidPlatform> platforms; |
kimkevin/AndroidStarterKit | ask-app/src/main/java/com/androidstarterkit/tool/ResourceMatcher.java | // Path: ask-app/src/main/java/com/androidstarterkit/android/api/resource/ResourceType.java
// public enum ResourceType {
// LAYOUT("layout")
// , MENU("menu")
// , DRAWABLE("drawable");
//
// private String name;
//
// ResourceType(String name) {
// this.name = name;
// }
//
// @Override
// public String toString() {
// return name.toLowerCase();
// }
// }
//
// Path: ask-app/src/main/java/com/androidstarterkit/android/api/resource/ValueType.java
// public enum ValueType {
// DIMEN("dimen")
// , STYLE("style")
// , STRING("string");
//
// private String name;
//
// ValueType(String name) {
// this.name = name;
// }
//
// @Override
// public String toString() {
// return name.toLowerCase();
// }
//
// public String fileName() {
// return name + "s";
// }
// }
| import com.androidstarterkit.android.api.resource.ResourceType;
import com.androidstarterkit.android.api.resource.ValueType;
import java.util.regex.Matcher;
import java.util.regex.Pattern; | package com.androidstarterkit.tool;
class ResourceMatcher {
private final Matcher matcher;
public interface Handler {
void handle(String type, String name);
}
public ResourceMatcher(String input, MatchType matchType) {
this.matcher = matchType.getMatchPattern().matcher(input);
}
public void match(Handler handler) {
matcher.reset();
while (matcher.find()) {
handler.handle(matcher.group(1), matcher.group(2));
}
}
public enum MatchType {
RES_FILE_IN_JAVA("R.(" | // Path: ask-app/src/main/java/com/androidstarterkit/android/api/resource/ResourceType.java
// public enum ResourceType {
// LAYOUT("layout")
// , MENU("menu")
// , DRAWABLE("drawable");
//
// private String name;
//
// ResourceType(String name) {
// this.name = name;
// }
//
// @Override
// public String toString() {
// return name.toLowerCase();
// }
// }
//
// Path: ask-app/src/main/java/com/androidstarterkit/android/api/resource/ValueType.java
// public enum ValueType {
// DIMEN("dimen")
// , STYLE("style")
// , STRING("string");
//
// private String name;
//
// ValueType(String name) {
// this.name = name;
// }
//
// @Override
// public String toString() {
// return name.toLowerCase();
// }
//
// public String fileName() {
// return name + "s";
// }
// }
// Path: ask-app/src/main/java/com/androidstarterkit/tool/ResourceMatcher.java
import com.androidstarterkit.android.api.resource.ResourceType;
import com.androidstarterkit.android.api.resource.ValueType;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
package com.androidstarterkit.tool;
class ResourceMatcher {
private final Matcher matcher;
public interface Handler {
void handle(String type, String name);
}
public ResourceMatcher(String input, MatchType matchType) {
this.matcher = matchType.getMatchPattern().matcher(input);
}
public void match(Handler handler) {
matcher.reset();
while (matcher.find()) {
handler.handle(matcher.group(1), matcher.group(2));
}
}
public enum MatchType {
RES_FILE_IN_JAVA("R.(" | + ResourceType.LAYOUT |
kimkevin/AndroidStarterKit | ask-app/src/main/java/com/androidstarterkit/tool/ResourceMatcher.java | // Path: ask-app/src/main/java/com/androidstarterkit/android/api/resource/ResourceType.java
// public enum ResourceType {
// LAYOUT("layout")
// , MENU("menu")
// , DRAWABLE("drawable");
//
// private String name;
//
// ResourceType(String name) {
// this.name = name;
// }
//
// @Override
// public String toString() {
// return name.toLowerCase();
// }
// }
//
// Path: ask-app/src/main/java/com/androidstarterkit/android/api/resource/ValueType.java
// public enum ValueType {
// DIMEN("dimen")
// , STYLE("style")
// , STRING("string");
//
// private String name;
//
// ValueType(String name) {
// this.name = name;
// }
//
// @Override
// public String toString() {
// return name.toLowerCase();
// }
//
// public String fileName() {
// return name + "s";
// }
// }
| import com.androidstarterkit.android.api.resource.ResourceType;
import com.androidstarterkit.android.api.resource.ValueType;
import java.util.regex.Matcher;
import java.util.regex.Pattern; | package com.androidstarterkit.tool;
class ResourceMatcher {
private final Matcher matcher;
public interface Handler {
void handle(String type, String name);
}
public ResourceMatcher(String input, MatchType matchType) {
this.matcher = matchType.getMatchPattern().matcher(input);
}
public void match(Handler handler) {
matcher.reset();
while (matcher.find()) {
handler.handle(matcher.group(1), matcher.group(2));
}
}
public enum MatchType {
RES_FILE_IN_JAVA("R.("
+ ResourceType.LAYOUT
+ "|" + ResourceType.MENU
+ "|" + ResourceType.DRAWABLE
+ ").([\\w_]*)"),
RES_VALUE_IN_JAVA("R.(" | // Path: ask-app/src/main/java/com/androidstarterkit/android/api/resource/ResourceType.java
// public enum ResourceType {
// LAYOUT("layout")
// , MENU("menu")
// , DRAWABLE("drawable");
//
// private String name;
//
// ResourceType(String name) {
// this.name = name;
// }
//
// @Override
// public String toString() {
// return name.toLowerCase();
// }
// }
//
// Path: ask-app/src/main/java/com/androidstarterkit/android/api/resource/ValueType.java
// public enum ValueType {
// DIMEN("dimen")
// , STYLE("style")
// , STRING("string");
//
// private String name;
//
// ValueType(String name) {
// this.name = name;
// }
//
// @Override
// public String toString() {
// return name.toLowerCase();
// }
//
// public String fileName() {
// return name + "s";
// }
// }
// Path: ask-app/src/main/java/com/androidstarterkit/tool/ResourceMatcher.java
import com.androidstarterkit.android.api.resource.ResourceType;
import com.androidstarterkit.android.api.resource.ValueType;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
package com.androidstarterkit.tool;
class ResourceMatcher {
private final Matcher matcher;
public interface Handler {
void handle(String type, String name);
}
public ResourceMatcher(String input, MatchType matchType) {
this.matcher = matchType.getMatchPattern().matcher(input);
}
public void match(Handler handler) {
matcher.reset();
while (matcher.find()) {
handler.handle(matcher.group(1), matcher.group(2));
}
}
public enum MatchType {
RES_FILE_IN_JAVA("R.("
+ ResourceType.LAYOUT
+ "|" + ResourceType.MENU
+ "|" + ResourceType.DRAWABLE
+ ").([\\w_]*)"),
RES_VALUE_IN_JAVA("R.(" | + ValueType.STRING |
kimkevin/AndroidStarterKit | ask-remote-module/src/main/java/com/androidstarterkit/module/sample/activity/ListViewActivity.java | // Path: ask-remote-module/src/main/java/com/androidstarterkit/module/ui/view/ListViewFragment.java
// public class ListViewFragment extends Fragment {
// private static List<AndroidPlatform> platforms = new ArrayList<>();
//
// static {
// platforms.add(new AndroidPlatform("applepie", "1.0", 1));
// platforms.add(new AndroidPlatform("bananabread", "1.1", 2));
// platforms.add(new AndroidPlatform("cupcake", "1.5", 3));
// platforms.add(new AndroidPlatform("donut", "1.6", 4));
// platforms.add(new AndroidPlatform("eclair", "2.0", 5));
// platforms.add(new AndroidPlatform("froyo", "2.2", 8));
// platforms.add(new AndroidPlatform("gingerbread", "2.3", 9));
// platforms.add(new AndroidPlatform("honeycomb", "3.0", 11));
// platforms.add(new AndroidPlatform("icecreamsandwich", "4.0", 14));
// platforms.add(new AndroidPlatform("kitkat", "4.4", 19));
// platforms.add(new AndroidPlatform("lollipop", "5.0", 21));
// platforms.add(new AndroidPlatform("marshmallow", "6.0", 23));
// platforms.add(new AndroidPlatform("nougat", "7.0", 24));
// }
//
// @Nullable
// @Override
// public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
// View view = inflater.inflate(R.layout.fragment_listview_main, null);
//
// ListView listView = (ListView) view.findViewById(R.id.list_view);
//
// ListViewAdapter adapter = new ListViewAdapter(getActivity(), platforms);
// listView.setAdapter(adapter);
//
// return view;
// }
// }
| import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import com.androidstarterkit.module.R;
import com.androidstarterkit.module.ui.view.ListViewFragment; | package com.androidstarterkit.module.sample.activity;
public class ListViewActivity extends AppCompatActivity{
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_sample_main);
if (savedInstanceState == null) {
getSupportFragmentManager()
.beginTransaction() | // Path: ask-remote-module/src/main/java/com/androidstarterkit/module/ui/view/ListViewFragment.java
// public class ListViewFragment extends Fragment {
// private static List<AndroidPlatform> platforms = new ArrayList<>();
//
// static {
// platforms.add(new AndroidPlatform("applepie", "1.0", 1));
// platforms.add(new AndroidPlatform("bananabread", "1.1", 2));
// platforms.add(new AndroidPlatform("cupcake", "1.5", 3));
// platforms.add(new AndroidPlatform("donut", "1.6", 4));
// platforms.add(new AndroidPlatform("eclair", "2.0", 5));
// platforms.add(new AndroidPlatform("froyo", "2.2", 8));
// platforms.add(new AndroidPlatform("gingerbread", "2.3", 9));
// platforms.add(new AndroidPlatform("honeycomb", "3.0", 11));
// platforms.add(new AndroidPlatform("icecreamsandwich", "4.0", 14));
// platforms.add(new AndroidPlatform("kitkat", "4.4", 19));
// platforms.add(new AndroidPlatform("lollipop", "5.0", 21));
// platforms.add(new AndroidPlatform("marshmallow", "6.0", 23));
// platforms.add(new AndroidPlatform("nougat", "7.0", 24));
// }
//
// @Nullable
// @Override
// public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
// View view = inflater.inflate(R.layout.fragment_listview_main, null);
//
// ListView listView = (ListView) view.findViewById(R.id.list_view);
//
// ListViewAdapter adapter = new ListViewAdapter(getActivity(), platforms);
// listView.setAdapter(adapter);
//
// return view;
// }
// }
// Path: ask-remote-module/src/main/java/com/androidstarterkit/module/sample/activity/ListViewActivity.java
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import com.androidstarterkit.module.R;
import com.androidstarterkit.module.ui.view.ListViewFragment;
package com.androidstarterkit.module.sample.activity;
public class ListViewActivity extends AppCompatActivity{
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_sample_main);
if (savedInstanceState == null) {
getSupportFragmentManager()
.beginTransaction() | .add(R.id.container, new ListViewFragment()) |
kimkevin/AndroidStarterKit | ask-remote-module/src/main/java/com/androidstarterkit/module/sample/activity/RecyclerViewActivity.java | // Path: ask-remote-module/src/main/java/com/androidstarterkit/module/ui/view/RecyclerViewFragment.java
// public class RecyclerViewFragment extends Fragment {
// private static List<AndroidPlatform> platforms = new ArrayList<>();
//
// static {
// platforms.add(new AndroidPlatform("applepie", "1.0", 1));
// platforms.add(new AndroidPlatform("bananabread", "1.1", 2));
// platforms.add(new AndroidPlatform("cupcake", "1.5", 3));
// platforms.add(new AndroidPlatform("donut", "1.6", 4));
// platforms.add(new AndroidPlatform("eclair", "2.0", 5));
// platforms.add(new AndroidPlatform("froyo", "2.2", 8));
// platforms.add(new AndroidPlatform("gingerbread", "2.3", 9));
// platforms.add(new AndroidPlatform("honeycomb", "3.0", 11));
// platforms.add(new AndroidPlatform("icecreamsandwich", "4.0", 14));
// platforms.add(new AndroidPlatform("kitkat", "4.4", 19));
// platforms.add(new AndroidPlatform("lollipop", "5.0", 21));
// platforms.add(new AndroidPlatform("marshmallow", "6.0", 23));
// platforms.add(new AndroidPlatform("nougat", "7.0", 24));
// }
//
// @Nullable
// @Override
// public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
// View view = inflater.inflate(R.layout.fragment_recyclerview_main, null);
//
// RecyclerView recyclerView = (RecyclerView) view.findViewById(R.id.recycler_view);
// recyclerView.setLayoutManager(new LinearLayoutManager(getActivity()));
//
// RecyclerViewAdapter recyclerViewAdapter = new RecyclerViewAdapter(getActivity(), platforms);
// recyclerView.setAdapter(recyclerViewAdapter);
// return view;
// }
// }
| import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import com.androidstarterkit.module.R;
import com.androidstarterkit.module.ui.view.RecyclerViewFragment; | package com.androidstarterkit.module.sample.activity;
public class RecyclerViewActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_sample_main);
if (savedInstanceState == null) {
getSupportFragmentManager()
.beginTransaction() | // Path: ask-remote-module/src/main/java/com/androidstarterkit/module/ui/view/RecyclerViewFragment.java
// public class RecyclerViewFragment extends Fragment {
// private static List<AndroidPlatform> platforms = new ArrayList<>();
//
// static {
// platforms.add(new AndroidPlatform("applepie", "1.0", 1));
// platforms.add(new AndroidPlatform("bananabread", "1.1", 2));
// platforms.add(new AndroidPlatform("cupcake", "1.5", 3));
// platforms.add(new AndroidPlatform("donut", "1.6", 4));
// platforms.add(new AndroidPlatform("eclair", "2.0", 5));
// platforms.add(new AndroidPlatform("froyo", "2.2", 8));
// platforms.add(new AndroidPlatform("gingerbread", "2.3", 9));
// platforms.add(new AndroidPlatform("honeycomb", "3.0", 11));
// platforms.add(new AndroidPlatform("icecreamsandwich", "4.0", 14));
// platforms.add(new AndroidPlatform("kitkat", "4.4", 19));
// platforms.add(new AndroidPlatform("lollipop", "5.0", 21));
// platforms.add(new AndroidPlatform("marshmallow", "6.0", 23));
// platforms.add(new AndroidPlatform("nougat", "7.0", 24));
// }
//
// @Nullable
// @Override
// public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
// View view = inflater.inflate(R.layout.fragment_recyclerview_main, null);
//
// RecyclerView recyclerView = (RecyclerView) view.findViewById(R.id.recycler_view);
// recyclerView.setLayoutManager(new LinearLayoutManager(getActivity()));
//
// RecyclerViewAdapter recyclerViewAdapter = new RecyclerViewAdapter(getActivity(), platforms);
// recyclerView.setAdapter(recyclerViewAdapter);
// return view;
// }
// }
// Path: ask-remote-module/src/main/java/com/androidstarterkit/module/sample/activity/RecyclerViewActivity.java
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import com.androidstarterkit.module.R;
import com.androidstarterkit.module.ui.view.RecyclerViewFragment;
package com.androidstarterkit.module.sample.activity;
public class RecyclerViewActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_sample_main);
if (savedInstanceState == null) {
getSupportFragmentManager()
.beginTransaction() | .add(R.id.container, new RecyclerViewFragment()) |
kimkevin/AndroidStarterKit | ask-remote-module/src/main/java/com/androidstarterkit/module/ui/adapter/SlidingTabAdapter.java | // Path: ask-remote-module/src/main/java/com/androidstarterkit/module/data/FragmentInfo.java
// public class FragmentInfo {
// private Class fragmentClass;
//
// public FragmentInfo(Class fragmentClass) {
// this.fragmentClass = fragmentClass;
// }
//
// public Class getFragmentClass() {
// return fragmentClass;
// }
//
// public int getIconResId() {
// return R.mipmap.ic_launcher;
// }
// }
//
// Path: ask-remote-module/src/main/java/com/androidstarterkit/module/ui/view/ScrollViewFragment.java
// public class ScrollViewFragment extends Fragment {
// private static final String ARG_POSITION = "position";
//
// public static ScrollViewFragment newInstance(int position) {
// ScrollViewFragment fragment = new ScrollViewFragment();
// Bundle args = new Bundle();
// args.putInt(ARG_POSITION, position);
// fragment.setArguments(args);
// return fragment;
// }
//
// @Override
// public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
// View view = inflater.inflate(R.layout.fragment_main, null);
// TextView posTxt = (TextView) view.findViewById(R.id.pos_txt);
// posTxt.setText("Hello, this's a ScrollView");
// return view;
// }
// }
| import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;
import com.androidstarterkit.module.data.FragmentInfo;
import com.androidstarterkit.module.ui.view.ScrollViewFragment;
import java.util.List; | package com.androidstarterkit.module.ui.adapter;
public class SlidingTabAdapter extends FragmentPagerAdapter {
private List<FragmentInfo> fragmentInfos;
public SlidingTabAdapter(FragmentManager fragmentManager, List<FragmentInfo> fragmentInfos) {
super(fragmentManager);
this.fragmentInfos = fragmentInfos;
}
@Override
public Fragment getItem(int position) {
try {
return (Fragment) Class.forName(fragmentInfos.get(position).getFragmentClass().getName())
.getConstructor().newInstance();
} catch (Exception e) { | // Path: ask-remote-module/src/main/java/com/androidstarterkit/module/data/FragmentInfo.java
// public class FragmentInfo {
// private Class fragmentClass;
//
// public FragmentInfo(Class fragmentClass) {
// this.fragmentClass = fragmentClass;
// }
//
// public Class getFragmentClass() {
// return fragmentClass;
// }
//
// public int getIconResId() {
// return R.mipmap.ic_launcher;
// }
// }
//
// Path: ask-remote-module/src/main/java/com/androidstarterkit/module/ui/view/ScrollViewFragment.java
// public class ScrollViewFragment extends Fragment {
// private static final String ARG_POSITION = "position";
//
// public static ScrollViewFragment newInstance(int position) {
// ScrollViewFragment fragment = new ScrollViewFragment();
// Bundle args = new Bundle();
// args.putInt(ARG_POSITION, position);
// fragment.setArguments(args);
// return fragment;
// }
//
// @Override
// public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
// View view = inflater.inflate(R.layout.fragment_main, null);
// TextView posTxt = (TextView) view.findViewById(R.id.pos_txt);
// posTxt.setText("Hello, this's a ScrollView");
// return view;
// }
// }
// Path: ask-remote-module/src/main/java/com/androidstarterkit/module/ui/adapter/SlidingTabAdapter.java
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;
import com.androidstarterkit.module.data.FragmentInfo;
import com.androidstarterkit.module.ui.view.ScrollViewFragment;
import java.util.List;
package com.androidstarterkit.module.ui.adapter;
public class SlidingTabAdapter extends FragmentPagerAdapter {
private List<FragmentInfo> fragmentInfos;
public SlidingTabAdapter(FragmentManager fragmentManager, List<FragmentInfo> fragmentInfos) {
super(fragmentManager);
this.fragmentInfos = fragmentInfos;
}
@Override
public Fragment getItem(int position) {
try {
return (Fragment) Class.forName(fragmentInfos.get(position).getFragmentClass().getName())
.getConstructor().newInstance();
} catch (Exception e) { | return new ScrollViewFragment(); |
kimkevin/AndroidStarterKit | ask-remote-module/src/main/java/com/androidstarterkit/module/SampleFragment.java | // Path: ask-remote-module/src/main/java/com/androidstarterkit/module/ui/adapter/MainBaseAdapter.java
// public class MainBaseAdapter extends BaseAdapter {
// private Context context;
// private List<SampleType> dataSet;
// private LayoutInflater inflater;
//
// public MainBaseAdapter(Context context, List<SampleType> dataSet) {
// this.context = context;
// this.dataSet = dataSet;
// this.inflater = (LayoutInflater) context.getSystemService(
// Context.LAYOUT_INFLATER_SERVICE);
// }
//
// @Override
// public int getCount() {
// return dataSet.size();
// }
//
// @Override
// public Object getItem(int position) {
// return dataSet.get(position);
// }
//
// @Override
// public long getItemId(int position) {
// return 0;
// }
//
// @Override
// public View getView(final int position, View convertView, ViewGroup parent) {
// ViewHolder viewHolder;
//
// if (convertView == null) {
// convertView = inflater.inflate(R.layout.layout_main_list_item, parent, false);
//
// viewHolder = new ViewHolder();
// viewHolder.title= (TextView) convertView.findViewById(R.id.title);
// convertView.setTag(viewHolder);
// } else {
// viewHolder = (ViewHolder) convertView.getTag();
// }
//
// viewHolder.title.setText(dataSet.get(position).name());
//
// convertView.setOnClickListener(new View.OnClickListener() {
// @Override
// public void onClick(View v) {
// SampleType sampleType = dataSet.get(position);
// Intent intent = null;
//
// switch (sampleType) {
// case ScrollView:
// intent = new Intent(context, ScrollViewActivity.class);
// break;
// case GridView:
// intent = new Intent(context, GridViewActivity.class);
// break;
// case RecyclerView:
// intent = new Intent(context, RecyclerViewActivity.class);
// break;
// case ListView:
// intent = new Intent(context, ListViewActivity.class);
// break;
// case SlidingTabLayout:
// intent = new Intent(context, SlidingTabActivity.class);
// break;
// case SlidingIconTabLayout:
// intent = new Intent(context, SlidingIconTabActivity.class);
// break;
// }
//
// context.startActivity(intent);
// }
// });
//
// return convertView;
// }
//
// static class ViewHolder {
// public TextView title;
// }
// }
//
// Path: ask-remote-module/src/main/java/com/androidstarterkit/module/sample/SampleType.java
// public enum SampleType {
// ScrollView, GridView, RecyclerView, ListView, SlidingTabLayout, SlidingIconTabLayout
// }
| import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.support.v4.app.Fragment;
import android.widget.ListView;
import com.androidstarterkit.module.ui.adapter.MainBaseAdapter;
import com.androidstarterkit.module.sample.SampleType;
import java.util.Arrays; | package com.androidstarterkit.module;
public class SampleFragment extends Fragment {
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_listview, container, false);
ListView listView = (ListView) view.findViewById(R.id.list_view);
| // Path: ask-remote-module/src/main/java/com/androidstarterkit/module/ui/adapter/MainBaseAdapter.java
// public class MainBaseAdapter extends BaseAdapter {
// private Context context;
// private List<SampleType> dataSet;
// private LayoutInflater inflater;
//
// public MainBaseAdapter(Context context, List<SampleType> dataSet) {
// this.context = context;
// this.dataSet = dataSet;
// this.inflater = (LayoutInflater) context.getSystemService(
// Context.LAYOUT_INFLATER_SERVICE);
// }
//
// @Override
// public int getCount() {
// return dataSet.size();
// }
//
// @Override
// public Object getItem(int position) {
// return dataSet.get(position);
// }
//
// @Override
// public long getItemId(int position) {
// return 0;
// }
//
// @Override
// public View getView(final int position, View convertView, ViewGroup parent) {
// ViewHolder viewHolder;
//
// if (convertView == null) {
// convertView = inflater.inflate(R.layout.layout_main_list_item, parent, false);
//
// viewHolder = new ViewHolder();
// viewHolder.title= (TextView) convertView.findViewById(R.id.title);
// convertView.setTag(viewHolder);
// } else {
// viewHolder = (ViewHolder) convertView.getTag();
// }
//
// viewHolder.title.setText(dataSet.get(position).name());
//
// convertView.setOnClickListener(new View.OnClickListener() {
// @Override
// public void onClick(View v) {
// SampleType sampleType = dataSet.get(position);
// Intent intent = null;
//
// switch (sampleType) {
// case ScrollView:
// intent = new Intent(context, ScrollViewActivity.class);
// break;
// case GridView:
// intent = new Intent(context, GridViewActivity.class);
// break;
// case RecyclerView:
// intent = new Intent(context, RecyclerViewActivity.class);
// break;
// case ListView:
// intent = new Intent(context, ListViewActivity.class);
// break;
// case SlidingTabLayout:
// intent = new Intent(context, SlidingTabActivity.class);
// break;
// case SlidingIconTabLayout:
// intent = new Intent(context, SlidingIconTabActivity.class);
// break;
// }
//
// context.startActivity(intent);
// }
// });
//
// return convertView;
// }
//
// static class ViewHolder {
// public TextView title;
// }
// }
//
// Path: ask-remote-module/src/main/java/com/androidstarterkit/module/sample/SampleType.java
// public enum SampleType {
// ScrollView, GridView, RecyclerView, ListView, SlidingTabLayout, SlidingIconTabLayout
// }
// Path: ask-remote-module/src/main/java/com/androidstarterkit/module/SampleFragment.java
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.support.v4.app.Fragment;
import android.widget.ListView;
import com.androidstarterkit.module.ui.adapter.MainBaseAdapter;
import com.androidstarterkit.module.sample.SampleType;
import java.util.Arrays;
package com.androidstarterkit.module;
public class SampleFragment extends Fragment {
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_listview, container, false);
ListView listView = (ListView) view.findViewById(R.id.list_view);
| MainBaseAdapter adapter = new MainBaseAdapter(getActivity(), |
kimkevin/AndroidStarterKit | ask-remote-module/src/main/java/com/androidstarterkit/module/SampleFragment.java | // Path: ask-remote-module/src/main/java/com/androidstarterkit/module/ui/adapter/MainBaseAdapter.java
// public class MainBaseAdapter extends BaseAdapter {
// private Context context;
// private List<SampleType> dataSet;
// private LayoutInflater inflater;
//
// public MainBaseAdapter(Context context, List<SampleType> dataSet) {
// this.context = context;
// this.dataSet = dataSet;
// this.inflater = (LayoutInflater) context.getSystemService(
// Context.LAYOUT_INFLATER_SERVICE);
// }
//
// @Override
// public int getCount() {
// return dataSet.size();
// }
//
// @Override
// public Object getItem(int position) {
// return dataSet.get(position);
// }
//
// @Override
// public long getItemId(int position) {
// return 0;
// }
//
// @Override
// public View getView(final int position, View convertView, ViewGroup parent) {
// ViewHolder viewHolder;
//
// if (convertView == null) {
// convertView = inflater.inflate(R.layout.layout_main_list_item, parent, false);
//
// viewHolder = new ViewHolder();
// viewHolder.title= (TextView) convertView.findViewById(R.id.title);
// convertView.setTag(viewHolder);
// } else {
// viewHolder = (ViewHolder) convertView.getTag();
// }
//
// viewHolder.title.setText(dataSet.get(position).name());
//
// convertView.setOnClickListener(new View.OnClickListener() {
// @Override
// public void onClick(View v) {
// SampleType sampleType = dataSet.get(position);
// Intent intent = null;
//
// switch (sampleType) {
// case ScrollView:
// intent = new Intent(context, ScrollViewActivity.class);
// break;
// case GridView:
// intent = new Intent(context, GridViewActivity.class);
// break;
// case RecyclerView:
// intent = new Intent(context, RecyclerViewActivity.class);
// break;
// case ListView:
// intent = new Intent(context, ListViewActivity.class);
// break;
// case SlidingTabLayout:
// intent = new Intent(context, SlidingTabActivity.class);
// break;
// case SlidingIconTabLayout:
// intent = new Intent(context, SlidingIconTabActivity.class);
// break;
// }
//
// context.startActivity(intent);
// }
// });
//
// return convertView;
// }
//
// static class ViewHolder {
// public TextView title;
// }
// }
//
// Path: ask-remote-module/src/main/java/com/androidstarterkit/module/sample/SampleType.java
// public enum SampleType {
// ScrollView, GridView, RecyclerView, ListView, SlidingTabLayout, SlidingIconTabLayout
// }
| import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.support.v4.app.Fragment;
import android.widget.ListView;
import com.androidstarterkit.module.ui.adapter.MainBaseAdapter;
import com.androidstarterkit.module.sample.SampleType;
import java.util.Arrays; | package com.androidstarterkit.module;
public class SampleFragment extends Fragment {
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_listview, container, false);
ListView listView = (ListView) view.findViewById(R.id.list_view);
MainBaseAdapter adapter = new MainBaseAdapter(getActivity(), | // Path: ask-remote-module/src/main/java/com/androidstarterkit/module/ui/adapter/MainBaseAdapter.java
// public class MainBaseAdapter extends BaseAdapter {
// private Context context;
// private List<SampleType> dataSet;
// private LayoutInflater inflater;
//
// public MainBaseAdapter(Context context, List<SampleType> dataSet) {
// this.context = context;
// this.dataSet = dataSet;
// this.inflater = (LayoutInflater) context.getSystemService(
// Context.LAYOUT_INFLATER_SERVICE);
// }
//
// @Override
// public int getCount() {
// return dataSet.size();
// }
//
// @Override
// public Object getItem(int position) {
// return dataSet.get(position);
// }
//
// @Override
// public long getItemId(int position) {
// return 0;
// }
//
// @Override
// public View getView(final int position, View convertView, ViewGroup parent) {
// ViewHolder viewHolder;
//
// if (convertView == null) {
// convertView = inflater.inflate(R.layout.layout_main_list_item, parent, false);
//
// viewHolder = new ViewHolder();
// viewHolder.title= (TextView) convertView.findViewById(R.id.title);
// convertView.setTag(viewHolder);
// } else {
// viewHolder = (ViewHolder) convertView.getTag();
// }
//
// viewHolder.title.setText(dataSet.get(position).name());
//
// convertView.setOnClickListener(new View.OnClickListener() {
// @Override
// public void onClick(View v) {
// SampleType sampleType = dataSet.get(position);
// Intent intent = null;
//
// switch (sampleType) {
// case ScrollView:
// intent = new Intent(context, ScrollViewActivity.class);
// break;
// case GridView:
// intent = new Intent(context, GridViewActivity.class);
// break;
// case RecyclerView:
// intent = new Intent(context, RecyclerViewActivity.class);
// break;
// case ListView:
// intent = new Intent(context, ListViewActivity.class);
// break;
// case SlidingTabLayout:
// intent = new Intent(context, SlidingTabActivity.class);
// break;
// case SlidingIconTabLayout:
// intent = new Intent(context, SlidingIconTabActivity.class);
// break;
// }
//
// context.startActivity(intent);
// }
// });
//
// return convertView;
// }
//
// static class ViewHolder {
// public TextView title;
// }
// }
//
// Path: ask-remote-module/src/main/java/com/androidstarterkit/module/sample/SampleType.java
// public enum SampleType {
// ScrollView, GridView, RecyclerView, ListView, SlidingTabLayout, SlidingIconTabLayout
// }
// Path: ask-remote-module/src/main/java/com/androidstarterkit/module/SampleFragment.java
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.support.v4.app.Fragment;
import android.widget.ListView;
import com.androidstarterkit.module.ui.adapter.MainBaseAdapter;
import com.androidstarterkit.module.sample.SampleType;
import java.util.Arrays;
package com.androidstarterkit.module;
public class SampleFragment extends Fragment {
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_listview, container, false);
ListView listView = (ListView) view.findViewById(R.id.list_view);
MainBaseAdapter adapter = new MainBaseAdapter(getActivity(), | Arrays.asList(SampleType.values())); |
kimkevin/AndroidStarterKit | ask-remote-module/src/main/java/com/androidstarterkit/module/ui/adapter/ListViewAdapter.java | // Path: ask-remote-module/src/main/java/com/androidstarterkit/module/data/AndroidPlatform.java
// public class AndroidPlatform {
// private static final String FILE_PATH = "https://raw.githubusercontent.com/kimkevin/AndroidStarterKit/master/assets/";
// private static final String EXTENSION_NAME = ".png";
//
// private String name;
// private String verCode;
// private int apiLevel;
// private String logoUrl;
//
// public AndroidPlatform(String name, String verCode, int apiLevel) {
// this.name = name;
// this.verCode = verCode;
// this.apiLevel = apiLevel;
// this.logoUrl = FILE_PATH + name + EXTENSION_NAME;
// }
//
// public String getName() {
// return name.toUpperCase() + " " + apiLevel;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getVerCode() {
// return "Android " + verCode;
// }
//
// public void setVerCode(String version) {
// this.verCode = version;
// }
//
// public int getApiLevel() {
// return apiLevel;
// }
//
// public void setApiLevel(int apiLevel) {
// this.apiLevel = apiLevel;
// }
//
// public String getLogoUrl() {
// return logoUrl;
// }
//
// public void setLogoUrl(String logoUrl) {
// this.logoUrl = logoUrl;
// }
// }
| import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;
import com.androidstarterkit.module.data.AndroidPlatform;
import com.androidstarterkit.module.R;
import com.bumptech.glide.Glide;
import java.util.List; | package com.androidstarterkit.module.ui.adapter;
public class ListViewAdapter extends BaseAdapter {
private static final String TAG = ListViewAdapter.class.getSimpleName();
private Context context; | // Path: ask-remote-module/src/main/java/com/androidstarterkit/module/data/AndroidPlatform.java
// public class AndroidPlatform {
// private static final String FILE_PATH = "https://raw.githubusercontent.com/kimkevin/AndroidStarterKit/master/assets/";
// private static final String EXTENSION_NAME = ".png";
//
// private String name;
// private String verCode;
// private int apiLevel;
// private String logoUrl;
//
// public AndroidPlatform(String name, String verCode, int apiLevel) {
// this.name = name;
// this.verCode = verCode;
// this.apiLevel = apiLevel;
// this.logoUrl = FILE_PATH + name + EXTENSION_NAME;
// }
//
// public String getName() {
// return name.toUpperCase() + " " + apiLevel;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getVerCode() {
// return "Android " + verCode;
// }
//
// public void setVerCode(String version) {
// this.verCode = version;
// }
//
// public int getApiLevel() {
// return apiLevel;
// }
//
// public void setApiLevel(int apiLevel) {
// this.apiLevel = apiLevel;
// }
//
// public String getLogoUrl() {
// return logoUrl;
// }
//
// public void setLogoUrl(String logoUrl) {
// this.logoUrl = logoUrl;
// }
// }
// Path: ask-remote-module/src/main/java/com/androidstarterkit/module/ui/adapter/ListViewAdapter.java
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;
import com.androidstarterkit.module.data.AndroidPlatform;
import com.androidstarterkit.module.R;
import com.bumptech.glide.Glide;
import java.util.List;
package com.androidstarterkit.module.ui.adapter;
public class ListViewAdapter extends BaseAdapter {
private static final String TAG = ListViewAdapter.class.getSimpleName();
private Context context; | private List<AndroidPlatform> platforms; |
kimkevin/AndroidStarterKit | ask-app/src/test/java/com/androidstarterkit/AskTest.java | // Path: ask-app/src/main/java/com/androidstarterkit/config/AskConfig.java
// public class AskConfig {
// public static final String DEFAULT_ASK_APP_NAME = "ask-app";
// public static final String DEFAULT_SAMPLE_MODULE_NAME = "ask-sample";
// public static final String DEFAULT_REMOTE_MODULE_NAME = "ask-remote-module";
//
// public static final int DEVELOPMENT = 0;
// public static final int PRODUCTION = 1;
//
// public static final int OUTPUT_PROD_PROJECT = 0;
// public static final int OUTPUT_DEV_ASK_SAMPLE = 1;
// }
| import com.androidstarterkit.config.AskConfig;
import org.junit.Test;
import static org.junit.Assert.assertEquals; | package com.androidstarterkit;
public class AskTest {
@Test
public void envTest() throws Exception { | // Path: ask-app/src/main/java/com/androidstarterkit/config/AskConfig.java
// public class AskConfig {
// public static final String DEFAULT_ASK_APP_NAME = "ask-app";
// public static final String DEFAULT_SAMPLE_MODULE_NAME = "ask-sample";
// public static final String DEFAULT_REMOTE_MODULE_NAME = "ask-remote-module";
//
// public static final int DEVELOPMENT = 0;
// public static final int PRODUCTION = 1;
//
// public static final int OUTPUT_PROD_PROJECT = 0;
// public static final int OUTPUT_DEV_ASK_SAMPLE = 1;
// }
// Path: ask-app/src/test/java/com/androidstarterkit/AskTest.java
import com.androidstarterkit.config.AskConfig;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
package com.androidstarterkit;
public class AskTest {
@Test
public void envTest() throws Exception { | assertEquals(Ask.env, AskConfig.PRODUCTION); |
kimkevin/AndroidStarterKit | ask-app/src/main/java/com/androidstarterkit/command/CommandParser.java | // Path: ask-app/src/main/java/com/androidstarterkit/exception/CommandException.java
// public class CommandException extends RuntimeException {
// public static final String ERROR_MESSAGE_PREFIX = "ask: ";
//
// public static final int INVALID_NO_OPTIONS = 1;
// public static final int FILE_NOT_FOUND = 2;
// public static final int APP_MODULE_NOT_FOUND = 3;
// public static final int WIDGET_NOT_FOUND = 4;
// public static final int INVALID_WIDGET = 5;
// public static final int OPTION_NOT_FOUND = 6;
// public static final int INVALID_MODULE = 7;
// public static final int NOT_FOUND_ASK_JSON = 8;
//
// private int errCode;
//
// public CommandException(String message) {
// this(0, message);
// }
//
// public CommandException(int errCode) {
// this(errCode, null);
// }
//
// public CommandException(int errCode, String message) {
// super(message);
//
// this.errCode = errCode;
// }
//
// @Override
// public String getMessage() {
// if (errCode == INVALID_NO_OPTIONS) {
// return ERROR_MESSAGE_PREFIX + "there is no options";
// } else if (errCode == FILE_NOT_FOUND) {
// return ERROR_MESSAGE_PREFIX + "failed to find project: " + super.getMessage();
// } else if (errCode == APP_MODULE_NOT_FOUND) {
// return ERROR_MESSAGE_PREFIX + "failed to find module: " + super.getMessage();
// } else if (errCode == WIDGET_NOT_FOUND) {
// return ERROR_MESSAGE_PREFIX + "failed to find widget: " + super.getMessage();
// } else if (errCode == INVALID_WIDGET) {
// return ERROR_MESSAGE_PREFIX + "there is no widgets";
// } else if (errCode == OPTION_NOT_FOUND) {
// return ERROR_MESSAGE_PREFIX + "failed to find option: " + super.getMessage();
// } else if (errCode == INVALID_MODULE) {
// return ERROR_MESSAGE_PREFIX + "failed to find module: " + super.getMessage();
// } else if (errCode == NOT_FOUND_ASK_JSON) {
// return ERROR_MESSAGE_PREFIX + "failed to find ask json file";
// }
//
// return super.getMessage();
// }
//
// public boolean shudShowHelp() {
// return errCode == INVALID_NO_OPTIONS
// || errCode == INVALID_WIDGET;
// }
// }
| import com.androidstarterkit.exception.CommandException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern; | package com.androidstarterkit.command;
public class CommandParser {
private String path;
private boolean hasIcon;
private boolean hasHelpCommand;
private List<String> layouts;
private List<String> modules;
| // Path: ask-app/src/main/java/com/androidstarterkit/exception/CommandException.java
// public class CommandException extends RuntimeException {
// public static final String ERROR_MESSAGE_PREFIX = "ask: ";
//
// public static final int INVALID_NO_OPTIONS = 1;
// public static final int FILE_NOT_FOUND = 2;
// public static final int APP_MODULE_NOT_FOUND = 3;
// public static final int WIDGET_NOT_FOUND = 4;
// public static final int INVALID_WIDGET = 5;
// public static final int OPTION_NOT_FOUND = 6;
// public static final int INVALID_MODULE = 7;
// public static final int NOT_FOUND_ASK_JSON = 8;
//
// private int errCode;
//
// public CommandException(String message) {
// this(0, message);
// }
//
// public CommandException(int errCode) {
// this(errCode, null);
// }
//
// public CommandException(int errCode, String message) {
// super(message);
//
// this.errCode = errCode;
// }
//
// @Override
// public String getMessage() {
// if (errCode == INVALID_NO_OPTIONS) {
// return ERROR_MESSAGE_PREFIX + "there is no options";
// } else if (errCode == FILE_NOT_FOUND) {
// return ERROR_MESSAGE_PREFIX + "failed to find project: " + super.getMessage();
// } else if (errCode == APP_MODULE_NOT_FOUND) {
// return ERROR_MESSAGE_PREFIX + "failed to find module: " + super.getMessage();
// } else if (errCode == WIDGET_NOT_FOUND) {
// return ERROR_MESSAGE_PREFIX + "failed to find widget: " + super.getMessage();
// } else if (errCode == INVALID_WIDGET) {
// return ERROR_MESSAGE_PREFIX + "there is no widgets";
// } else if (errCode == OPTION_NOT_FOUND) {
// return ERROR_MESSAGE_PREFIX + "failed to find option: " + super.getMessage();
// } else if (errCode == INVALID_MODULE) {
// return ERROR_MESSAGE_PREFIX + "failed to find module: " + super.getMessage();
// } else if (errCode == NOT_FOUND_ASK_JSON) {
// return ERROR_MESSAGE_PREFIX + "failed to find ask json file";
// }
//
// return super.getMessage();
// }
//
// public boolean shudShowHelp() {
// return errCode == INVALID_NO_OPTIONS
// || errCode == INVALID_WIDGET;
// }
// }
// Path: ask-app/src/main/java/com/androidstarterkit/command/CommandParser.java
import com.androidstarterkit.exception.CommandException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
package com.androidstarterkit.command;
public class CommandParser {
private String path;
private boolean hasIcon;
private boolean hasHelpCommand;
private List<String> layouts;
private List<String> modules;
| public CommandParser(String[] args) throws CommandException { |
kimkevin/AndroidStarterKit | ask-remote-module/src/main/java/com/androidstarterkit/module/sample/activity/SlidingIconTabActivity.java | // Path: ask-remote-module/src/main/java/com/androidstarterkit/module/ui/view/SlidingIconTabFragment.java
// public class SlidingIconTabFragment extends Fragment {
//
// @Nullable
// @Override
// public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
// View view = inflater.inflate(R.layout.fragment_slidingtablayout_main, null);
//
// List<FragmentInfo> fragmentInfos = new ArrayList<>();
// fragmentInfos.add(new FragmentInfo(ScrollViewFragment.class));
// fragmentInfos.add(new FragmentInfo(ScrollViewFragment.class));
//
// SlidingIconTabAdapter adapter = new SlidingIconTabAdapter(getActivity().getSupportFragmentManager(), fragmentInfos);
//
// ViewPager viewPager = (ViewPager) view.findViewById(R.id.pager);
// viewPager.setAdapter(adapter);
//
// SlidingTabLayout slidingTabLayout = (SlidingTabLayout) view.findViewById(R.id.tabs);
// slidingTabLayout.setCustomTabView(R.layout.tab_img_layout, R.id.tab_name_img);
// slidingTabLayout.setCustomTabColorizer(new SlidingTabLayout.TabColorizer() {
// @Override
// public int getIndicatorColor(int position) {
// return Color.WHITE;
// }
// });
//
// slidingTabLayout.setViewPager(viewPager);
// return view;
// }
// }
| import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import com.androidstarterkit.module.R;
import com.androidstarterkit.module.ui.view.SlidingIconTabFragment; | package com.androidstarterkit.module.sample.activity;
public class SlidingIconTabActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getSupportActionBar().setElevation(0);
setContentView(R.layout.activity_sample_main);
if (savedInstanceState == null) {
getSupportFragmentManager()
.beginTransaction() | // Path: ask-remote-module/src/main/java/com/androidstarterkit/module/ui/view/SlidingIconTabFragment.java
// public class SlidingIconTabFragment extends Fragment {
//
// @Nullable
// @Override
// public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
// View view = inflater.inflate(R.layout.fragment_slidingtablayout_main, null);
//
// List<FragmentInfo> fragmentInfos = new ArrayList<>();
// fragmentInfos.add(new FragmentInfo(ScrollViewFragment.class));
// fragmentInfos.add(new FragmentInfo(ScrollViewFragment.class));
//
// SlidingIconTabAdapter adapter = new SlidingIconTabAdapter(getActivity().getSupportFragmentManager(), fragmentInfos);
//
// ViewPager viewPager = (ViewPager) view.findViewById(R.id.pager);
// viewPager.setAdapter(adapter);
//
// SlidingTabLayout slidingTabLayout = (SlidingTabLayout) view.findViewById(R.id.tabs);
// slidingTabLayout.setCustomTabView(R.layout.tab_img_layout, R.id.tab_name_img);
// slidingTabLayout.setCustomTabColorizer(new SlidingTabLayout.TabColorizer() {
// @Override
// public int getIndicatorColor(int position) {
// return Color.WHITE;
// }
// });
//
// slidingTabLayout.setViewPager(viewPager);
// return view;
// }
// }
// Path: ask-remote-module/src/main/java/com/androidstarterkit/module/sample/activity/SlidingIconTabActivity.java
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import com.androidstarterkit.module.R;
import com.androidstarterkit.module.ui.view.SlidingIconTabFragment;
package com.androidstarterkit.module.sample.activity;
public class SlidingIconTabActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getSupportActionBar().setElevation(0);
setContentView(R.layout.activity_sample_main);
if (savedInstanceState == null) {
getSupportFragmentManager()
.beginTransaction() | .add(R.id.container, new SlidingIconTabFragment()) |
kimkevin/AndroidStarterKit | ask-app/src/main/java/com/androidstarterkit/Console.java | // Path: ask-app/src/main/java/com/androidstarterkit/config/AskConfig.java
// public class AskConfig {
// public static final String DEFAULT_ASK_APP_NAME = "ask-app";
// public static final String DEFAULT_SAMPLE_MODULE_NAME = "ask-sample";
// public static final String DEFAULT_REMOTE_MODULE_NAME = "ask-remote-module";
//
// public static final int DEVELOPMENT = 0;
// public static final int PRODUCTION = 1;
//
// public static final int OUTPUT_PROD_PROJECT = 0;
// public static final int OUTPUT_DEV_ASK_SAMPLE = 1;
// }
//
// Path: ask-app/src/main/java/com/androidstarterkit/exception/CommandException.java
// public class CommandException extends RuntimeException {
// public static final String ERROR_MESSAGE_PREFIX = "ask: ";
//
// public static final int INVALID_NO_OPTIONS = 1;
// public static final int FILE_NOT_FOUND = 2;
// public static final int APP_MODULE_NOT_FOUND = 3;
// public static final int WIDGET_NOT_FOUND = 4;
// public static final int INVALID_WIDGET = 5;
// public static final int OPTION_NOT_FOUND = 6;
// public static final int INVALID_MODULE = 7;
// public static final int NOT_FOUND_ASK_JSON = 8;
//
// private int errCode;
//
// public CommandException(String message) {
// this(0, message);
// }
//
// public CommandException(int errCode) {
// this(errCode, null);
// }
//
// public CommandException(int errCode, String message) {
// super(message);
//
// this.errCode = errCode;
// }
//
// @Override
// public String getMessage() {
// if (errCode == INVALID_NO_OPTIONS) {
// return ERROR_MESSAGE_PREFIX + "there is no options";
// } else if (errCode == FILE_NOT_FOUND) {
// return ERROR_MESSAGE_PREFIX + "failed to find project: " + super.getMessage();
// } else if (errCode == APP_MODULE_NOT_FOUND) {
// return ERROR_MESSAGE_PREFIX + "failed to find module: " + super.getMessage();
// } else if (errCode == WIDGET_NOT_FOUND) {
// return ERROR_MESSAGE_PREFIX + "failed to find widget: " + super.getMessage();
// } else if (errCode == INVALID_WIDGET) {
// return ERROR_MESSAGE_PREFIX + "there is no widgets";
// } else if (errCode == OPTION_NOT_FOUND) {
// return ERROR_MESSAGE_PREFIX + "failed to find option: " + super.getMessage();
// } else if (errCode == INVALID_MODULE) {
// return ERROR_MESSAGE_PREFIX + "failed to find module: " + super.getMessage();
// } else if (errCode == NOT_FOUND_ASK_JSON) {
// return ERROR_MESSAGE_PREFIX + "failed to find ask json file";
// }
//
// return super.getMessage();
// }
//
// public boolean shudShowHelp() {
// return errCode == INVALID_NO_OPTIONS
// || errCode == INVALID_WIDGET;
// }
// }
| import com.androidstarterkit.config.AskConfig;
import com.androidstarterkit.exception.CommandException; | package com.androidstarterkit;
public class Console {
public static void log(Exception e) { | // Path: ask-app/src/main/java/com/androidstarterkit/config/AskConfig.java
// public class AskConfig {
// public static final String DEFAULT_ASK_APP_NAME = "ask-app";
// public static final String DEFAULT_SAMPLE_MODULE_NAME = "ask-sample";
// public static final String DEFAULT_REMOTE_MODULE_NAME = "ask-remote-module";
//
// public static final int DEVELOPMENT = 0;
// public static final int PRODUCTION = 1;
//
// public static final int OUTPUT_PROD_PROJECT = 0;
// public static final int OUTPUT_DEV_ASK_SAMPLE = 1;
// }
//
// Path: ask-app/src/main/java/com/androidstarterkit/exception/CommandException.java
// public class CommandException extends RuntimeException {
// public static final String ERROR_MESSAGE_PREFIX = "ask: ";
//
// public static final int INVALID_NO_OPTIONS = 1;
// public static final int FILE_NOT_FOUND = 2;
// public static final int APP_MODULE_NOT_FOUND = 3;
// public static final int WIDGET_NOT_FOUND = 4;
// public static final int INVALID_WIDGET = 5;
// public static final int OPTION_NOT_FOUND = 6;
// public static final int INVALID_MODULE = 7;
// public static final int NOT_FOUND_ASK_JSON = 8;
//
// private int errCode;
//
// public CommandException(String message) {
// this(0, message);
// }
//
// public CommandException(int errCode) {
// this(errCode, null);
// }
//
// public CommandException(int errCode, String message) {
// super(message);
//
// this.errCode = errCode;
// }
//
// @Override
// public String getMessage() {
// if (errCode == INVALID_NO_OPTIONS) {
// return ERROR_MESSAGE_PREFIX + "there is no options";
// } else if (errCode == FILE_NOT_FOUND) {
// return ERROR_MESSAGE_PREFIX + "failed to find project: " + super.getMessage();
// } else if (errCode == APP_MODULE_NOT_FOUND) {
// return ERROR_MESSAGE_PREFIX + "failed to find module: " + super.getMessage();
// } else if (errCode == WIDGET_NOT_FOUND) {
// return ERROR_MESSAGE_PREFIX + "failed to find widget: " + super.getMessage();
// } else if (errCode == INVALID_WIDGET) {
// return ERROR_MESSAGE_PREFIX + "there is no widgets";
// } else if (errCode == OPTION_NOT_FOUND) {
// return ERROR_MESSAGE_PREFIX + "failed to find option: " + super.getMessage();
// } else if (errCode == INVALID_MODULE) {
// return ERROR_MESSAGE_PREFIX + "failed to find module: " + super.getMessage();
// } else if (errCode == NOT_FOUND_ASK_JSON) {
// return ERROR_MESSAGE_PREFIX + "failed to find ask json file";
// }
//
// return super.getMessage();
// }
//
// public boolean shudShowHelp() {
// return errCode == INVALID_NO_OPTIONS
// || errCode == INVALID_WIDGET;
// }
// }
// Path: ask-app/src/main/java/com/androidstarterkit/Console.java
import com.androidstarterkit.config.AskConfig;
import com.androidstarterkit.exception.CommandException;
package com.androidstarterkit;
public class Console {
public static void log(Exception e) { | if (e instanceof CommandException) { |
kimkevin/AndroidStarterKit | ask-app/src/main/java/com/androidstarterkit/Console.java | // Path: ask-app/src/main/java/com/androidstarterkit/config/AskConfig.java
// public class AskConfig {
// public static final String DEFAULT_ASK_APP_NAME = "ask-app";
// public static final String DEFAULT_SAMPLE_MODULE_NAME = "ask-sample";
// public static final String DEFAULT_REMOTE_MODULE_NAME = "ask-remote-module";
//
// public static final int DEVELOPMENT = 0;
// public static final int PRODUCTION = 1;
//
// public static final int OUTPUT_PROD_PROJECT = 0;
// public static final int OUTPUT_DEV_ASK_SAMPLE = 1;
// }
//
// Path: ask-app/src/main/java/com/androidstarterkit/exception/CommandException.java
// public class CommandException extends RuntimeException {
// public static final String ERROR_MESSAGE_PREFIX = "ask: ";
//
// public static final int INVALID_NO_OPTIONS = 1;
// public static final int FILE_NOT_FOUND = 2;
// public static final int APP_MODULE_NOT_FOUND = 3;
// public static final int WIDGET_NOT_FOUND = 4;
// public static final int INVALID_WIDGET = 5;
// public static final int OPTION_NOT_FOUND = 6;
// public static final int INVALID_MODULE = 7;
// public static final int NOT_FOUND_ASK_JSON = 8;
//
// private int errCode;
//
// public CommandException(String message) {
// this(0, message);
// }
//
// public CommandException(int errCode) {
// this(errCode, null);
// }
//
// public CommandException(int errCode, String message) {
// super(message);
//
// this.errCode = errCode;
// }
//
// @Override
// public String getMessage() {
// if (errCode == INVALID_NO_OPTIONS) {
// return ERROR_MESSAGE_PREFIX + "there is no options";
// } else if (errCode == FILE_NOT_FOUND) {
// return ERROR_MESSAGE_PREFIX + "failed to find project: " + super.getMessage();
// } else if (errCode == APP_MODULE_NOT_FOUND) {
// return ERROR_MESSAGE_PREFIX + "failed to find module: " + super.getMessage();
// } else if (errCode == WIDGET_NOT_FOUND) {
// return ERROR_MESSAGE_PREFIX + "failed to find widget: " + super.getMessage();
// } else if (errCode == INVALID_WIDGET) {
// return ERROR_MESSAGE_PREFIX + "there is no widgets";
// } else if (errCode == OPTION_NOT_FOUND) {
// return ERROR_MESSAGE_PREFIX + "failed to find option: " + super.getMessage();
// } else if (errCode == INVALID_MODULE) {
// return ERROR_MESSAGE_PREFIX + "failed to find module: " + super.getMessage();
// } else if (errCode == NOT_FOUND_ASK_JSON) {
// return ERROR_MESSAGE_PREFIX + "failed to find ask json file";
// }
//
// return super.getMessage();
// }
//
// public boolean shudShowHelp() {
// return errCode == INVALID_NO_OPTIONS
// || errCode == INVALID_WIDGET;
// }
// }
| import com.androidstarterkit.config.AskConfig;
import com.androidstarterkit.exception.CommandException; | package com.androidstarterkit;
public class Console {
public static void log(Exception e) {
if (e instanceof CommandException) {
CommandException exception = (CommandException) e;
System.out.println(e.getMessage());
| // Path: ask-app/src/main/java/com/androidstarterkit/config/AskConfig.java
// public class AskConfig {
// public static final String DEFAULT_ASK_APP_NAME = "ask-app";
// public static final String DEFAULT_SAMPLE_MODULE_NAME = "ask-sample";
// public static final String DEFAULT_REMOTE_MODULE_NAME = "ask-remote-module";
//
// public static final int DEVELOPMENT = 0;
// public static final int PRODUCTION = 1;
//
// public static final int OUTPUT_PROD_PROJECT = 0;
// public static final int OUTPUT_DEV_ASK_SAMPLE = 1;
// }
//
// Path: ask-app/src/main/java/com/androidstarterkit/exception/CommandException.java
// public class CommandException extends RuntimeException {
// public static final String ERROR_MESSAGE_PREFIX = "ask: ";
//
// public static final int INVALID_NO_OPTIONS = 1;
// public static final int FILE_NOT_FOUND = 2;
// public static final int APP_MODULE_NOT_FOUND = 3;
// public static final int WIDGET_NOT_FOUND = 4;
// public static final int INVALID_WIDGET = 5;
// public static final int OPTION_NOT_FOUND = 6;
// public static final int INVALID_MODULE = 7;
// public static final int NOT_FOUND_ASK_JSON = 8;
//
// private int errCode;
//
// public CommandException(String message) {
// this(0, message);
// }
//
// public CommandException(int errCode) {
// this(errCode, null);
// }
//
// public CommandException(int errCode, String message) {
// super(message);
//
// this.errCode = errCode;
// }
//
// @Override
// public String getMessage() {
// if (errCode == INVALID_NO_OPTIONS) {
// return ERROR_MESSAGE_PREFIX + "there is no options";
// } else if (errCode == FILE_NOT_FOUND) {
// return ERROR_MESSAGE_PREFIX + "failed to find project: " + super.getMessage();
// } else if (errCode == APP_MODULE_NOT_FOUND) {
// return ERROR_MESSAGE_PREFIX + "failed to find module: " + super.getMessage();
// } else if (errCode == WIDGET_NOT_FOUND) {
// return ERROR_MESSAGE_PREFIX + "failed to find widget: " + super.getMessage();
// } else if (errCode == INVALID_WIDGET) {
// return ERROR_MESSAGE_PREFIX + "there is no widgets";
// } else if (errCode == OPTION_NOT_FOUND) {
// return ERROR_MESSAGE_PREFIX + "failed to find option: " + super.getMessage();
// } else if (errCode == INVALID_MODULE) {
// return ERROR_MESSAGE_PREFIX + "failed to find module: " + super.getMessage();
// } else if (errCode == NOT_FOUND_ASK_JSON) {
// return ERROR_MESSAGE_PREFIX + "failed to find ask json file";
// }
//
// return super.getMessage();
// }
//
// public boolean shudShowHelp() {
// return errCode == INVALID_NO_OPTIONS
// || errCode == INVALID_WIDGET;
// }
// }
// Path: ask-app/src/main/java/com/androidstarterkit/Console.java
import com.androidstarterkit.config.AskConfig;
import com.androidstarterkit.exception.CommandException;
package com.androidstarterkit;
public class Console {
public static void log(Exception e) {
if (e instanceof CommandException) {
CommandException exception = (CommandException) e;
System.out.println(e.getMessage());
| if (Ask.env == AskConfig.DEVELOPMENT) { |
kimkevin/AndroidStarterKit | ask-remote-module/src/main/java/com/androidstarterkit/module/ui/view/ListViewFragment.java | // Path: ask-remote-module/src/main/java/com/androidstarterkit/module/ui/adapter/ListViewAdapter.java
// public class ListViewAdapter extends BaseAdapter {
// private static final String TAG = ListViewAdapter.class.getSimpleName();
//
// private Context context;
// private List<AndroidPlatform> platforms;
//
// public ListViewAdapter(Context context, List<AndroidPlatform> platforms) {
// this.context = context;
// this.platforms = platforms;
// }
//
// @Override
// public int getCount() {
// return platforms.size();
// }
//
// @Override
// public Object getItem(int position) {
// return platforms.get(position);
// }
//
// @Override
// public long getItemId(int position) {
// return 0;
// }
//
// @Override
// public View getView(int position, View convertView, ViewGroup parent) {
// AndroidPlatform platform = (AndroidPlatform) getItem(position);
//
// ViewHolder viewHolder;
//
// if (convertView == null) {
// LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
// convertView = inflater.inflate(R.layout.layout_list_item, parent, false);
//
// viewHolder = new ViewHolder();
// viewHolder.logo = (ImageView) convertView.findViewById(R.id.img);
// viewHolder.name = (TextView) convertView.findViewById(R.id.name);
// viewHolder.platformVer = (TextView) convertView.findViewById(R.id.platform_ver);
// convertView.setTag(viewHolder);
// } else {
// viewHolder = (ViewHolder) convertView.getTag();
// }
//
// Glide.with(context).load(platform.getLogoUrl()).into(viewHolder.logo);
// viewHolder.name.setText(platform.getName());
// viewHolder.platformVer.setText(platform.getVerCode());
//
// return convertView;
// }
//
// static class ViewHolder {
// public ImageView logo;
// public TextView name;
// public TextView platformVer;
// }
// }
//
// Path: ask-remote-module/src/main/java/com/androidstarterkit/module/data/AndroidPlatform.java
// public class AndroidPlatform {
// private static final String FILE_PATH = "https://raw.githubusercontent.com/kimkevin/AndroidStarterKit/master/assets/";
// private static final String EXTENSION_NAME = ".png";
//
// private String name;
// private String verCode;
// private int apiLevel;
// private String logoUrl;
//
// public AndroidPlatform(String name, String verCode, int apiLevel) {
// this.name = name;
// this.verCode = verCode;
// this.apiLevel = apiLevel;
// this.logoUrl = FILE_PATH + name + EXTENSION_NAME;
// }
//
// public String getName() {
// return name.toUpperCase() + " " + apiLevel;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getVerCode() {
// return "Android " + verCode;
// }
//
// public void setVerCode(String version) {
// this.verCode = version;
// }
//
// public int getApiLevel() {
// return apiLevel;
// }
//
// public void setApiLevel(int apiLevel) {
// this.apiLevel = apiLevel;
// }
//
// public String getLogoUrl() {
// return logoUrl;
// }
//
// public void setLogoUrl(String logoUrl) {
// this.logoUrl = logoUrl;
// }
// }
| import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ListView;
import com.androidstarterkit.module.R;
import com.androidstarterkit.module.ui.adapter.ListViewAdapter;
import com.androidstarterkit.module.data.AndroidPlatform;
import java.util.ArrayList;
import java.util.List; | package com.androidstarterkit.module.ui.view;
public class ListViewFragment extends Fragment {
private static List<AndroidPlatform> platforms = new ArrayList<>();
static {
platforms.add(new AndroidPlatform("applepie", "1.0", 1));
platforms.add(new AndroidPlatform("bananabread", "1.1", 2));
platforms.add(new AndroidPlatform("cupcake", "1.5", 3));
platforms.add(new AndroidPlatform("donut", "1.6", 4));
platforms.add(new AndroidPlatform("eclair", "2.0", 5));
platforms.add(new AndroidPlatform("froyo", "2.2", 8));
platforms.add(new AndroidPlatform("gingerbread", "2.3", 9));
platforms.add(new AndroidPlatform("honeycomb", "3.0", 11));
platforms.add(new AndroidPlatform("icecreamsandwich", "4.0", 14));
platforms.add(new AndroidPlatform("kitkat", "4.4", 19));
platforms.add(new AndroidPlatform("lollipop", "5.0", 21));
platforms.add(new AndroidPlatform("marshmallow", "6.0", 23));
platforms.add(new AndroidPlatform("nougat", "7.0", 24));
}
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_listview_main, null);
ListView listView = (ListView) view.findViewById(R.id.list_view);
| // Path: ask-remote-module/src/main/java/com/androidstarterkit/module/ui/adapter/ListViewAdapter.java
// public class ListViewAdapter extends BaseAdapter {
// private static final String TAG = ListViewAdapter.class.getSimpleName();
//
// private Context context;
// private List<AndroidPlatform> platforms;
//
// public ListViewAdapter(Context context, List<AndroidPlatform> platforms) {
// this.context = context;
// this.platforms = platforms;
// }
//
// @Override
// public int getCount() {
// return platforms.size();
// }
//
// @Override
// public Object getItem(int position) {
// return platforms.get(position);
// }
//
// @Override
// public long getItemId(int position) {
// return 0;
// }
//
// @Override
// public View getView(int position, View convertView, ViewGroup parent) {
// AndroidPlatform platform = (AndroidPlatform) getItem(position);
//
// ViewHolder viewHolder;
//
// if (convertView == null) {
// LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
// convertView = inflater.inflate(R.layout.layout_list_item, parent, false);
//
// viewHolder = new ViewHolder();
// viewHolder.logo = (ImageView) convertView.findViewById(R.id.img);
// viewHolder.name = (TextView) convertView.findViewById(R.id.name);
// viewHolder.platformVer = (TextView) convertView.findViewById(R.id.platform_ver);
// convertView.setTag(viewHolder);
// } else {
// viewHolder = (ViewHolder) convertView.getTag();
// }
//
// Glide.with(context).load(platform.getLogoUrl()).into(viewHolder.logo);
// viewHolder.name.setText(platform.getName());
// viewHolder.platformVer.setText(platform.getVerCode());
//
// return convertView;
// }
//
// static class ViewHolder {
// public ImageView logo;
// public TextView name;
// public TextView platformVer;
// }
// }
//
// Path: ask-remote-module/src/main/java/com/androidstarterkit/module/data/AndroidPlatform.java
// public class AndroidPlatform {
// private static final String FILE_PATH = "https://raw.githubusercontent.com/kimkevin/AndroidStarterKit/master/assets/";
// private static final String EXTENSION_NAME = ".png";
//
// private String name;
// private String verCode;
// private int apiLevel;
// private String logoUrl;
//
// public AndroidPlatform(String name, String verCode, int apiLevel) {
// this.name = name;
// this.verCode = verCode;
// this.apiLevel = apiLevel;
// this.logoUrl = FILE_PATH + name + EXTENSION_NAME;
// }
//
// public String getName() {
// return name.toUpperCase() + " " + apiLevel;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getVerCode() {
// return "Android " + verCode;
// }
//
// public void setVerCode(String version) {
// this.verCode = version;
// }
//
// public int getApiLevel() {
// return apiLevel;
// }
//
// public void setApiLevel(int apiLevel) {
// this.apiLevel = apiLevel;
// }
//
// public String getLogoUrl() {
// return logoUrl;
// }
//
// public void setLogoUrl(String logoUrl) {
// this.logoUrl = logoUrl;
// }
// }
// Path: ask-remote-module/src/main/java/com/androidstarterkit/module/ui/view/ListViewFragment.java
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ListView;
import com.androidstarterkit.module.R;
import com.androidstarterkit.module.ui.adapter.ListViewAdapter;
import com.androidstarterkit.module.data.AndroidPlatform;
import java.util.ArrayList;
import java.util.List;
package com.androidstarterkit.module.ui.view;
public class ListViewFragment extends Fragment {
private static List<AndroidPlatform> platforms = new ArrayList<>();
static {
platforms.add(new AndroidPlatform("applepie", "1.0", 1));
platforms.add(new AndroidPlatform("bananabread", "1.1", 2));
platforms.add(new AndroidPlatform("cupcake", "1.5", 3));
platforms.add(new AndroidPlatform("donut", "1.6", 4));
platforms.add(new AndroidPlatform("eclair", "2.0", 5));
platforms.add(new AndroidPlatform("froyo", "2.2", 8));
platforms.add(new AndroidPlatform("gingerbread", "2.3", 9));
platforms.add(new AndroidPlatform("honeycomb", "3.0", 11));
platforms.add(new AndroidPlatform("icecreamsandwich", "4.0", 14));
platforms.add(new AndroidPlatform("kitkat", "4.4", 19));
platforms.add(new AndroidPlatform("lollipop", "5.0", 21));
platforms.add(new AndroidPlatform("marshmallow", "6.0", 23));
platforms.add(new AndroidPlatform("nougat", "7.0", 24));
}
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_listview_main, null);
ListView listView = (ListView) view.findViewById(R.id.list_view);
| ListViewAdapter adapter = new ListViewAdapter(getActivity(), platforms); |
kimkevin/AndroidStarterKit | ask-remote-module/src/main/java/com/androidstarterkit/module/sample/activity/SlidingTabActivity.java | // Path: ask-remote-module/src/main/java/com/androidstarterkit/module/ui/view/SlidingTabFragment.java
// public class SlidingTabFragment extends Fragment{
//
// @Nullable
// @Override
// public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
// View view = inflater.inflate(R.layout.fragment_slidingtablayout_main, null);
//
// List<FragmentInfo> fragmentInfos = new ArrayList<>();
// fragmentInfos.add(new FragmentInfo(ScrollViewFragment.class));
// fragmentInfos.add(new FragmentInfo(ScrollViewFragment.class));
//
// SlidingTabAdapter adapter = new SlidingTabAdapter(getActivity().getSupportFragmentManager(),
// fragmentInfos);
//
// ViewPager viewPager = (ViewPager) view.findViewById(R.id.pager);
// viewPager.setAdapter(adapter);
//
// SlidingTabLayout slidingTabLayout = (SlidingTabLayout) view.findViewById(R.id.tabs);
// slidingTabLayout.setCustomTabView(R.layout.tab_txt_layout, R.id.tab_name_txt);
//
// slidingTabLayout.setCustomTabColorizer(new SlidingTabLayout.TabColorizer() {
// @Override
// public int getIndicatorColor(int position) {
// return Color.WHITE;
// }
// });
//
// slidingTabLayout.setViewPager(viewPager);
// return view;
// }
// }
| import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import com.androidstarterkit.module.R;
import com.androidstarterkit.module.ui.view.SlidingTabFragment; | package com.androidstarterkit.module.sample.activity;
public class SlidingTabActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getSupportActionBar().setElevation(0);
setContentView(R.layout.activity_sample_main);
if (savedInstanceState == null) {
getSupportFragmentManager()
.beginTransaction() | // Path: ask-remote-module/src/main/java/com/androidstarterkit/module/ui/view/SlidingTabFragment.java
// public class SlidingTabFragment extends Fragment{
//
// @Nullable
// @Override
// public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
// View view = inflater.inflate(R.layout.fragment_slidingtablayout_main, null);
//
// List<FragmentInfo> fragmentInfos = new ArrayList<>();
// fragmentInfos.add(new FragmentInfo(ScrollViewFragment.class));
// fragmentInfos.add(new FragmentInfo(ScrollViewFragment.class));
//
// SlidingTabAdapter adapter = new SlidingTabAdapter(getActivity().getSupportFragmentManager(),
// fragmentInfos);
//
// ViewPager viewPager = (ViewPager) view.findViewById(R.id.pager);
// viewPager.setAdapter(adapter);
//
// SlidingTabLayout slidingTabLayout = (SlidingTabLayout) view.findViewById(R.id.tabs);
// slidingTabLayout.setCustomTabView(R.layout.tab_txt_layout, R.id.tab_name_txt);
//
// slidingTabLayout.setCustomTabColorizer(new SlidingTabLayout.TabColorizer() {
// @Override
// public int getIndicatorColor(int position) {
// return Color.WHITE;
// }
// });
//
// slidingTabLayout.setViewPager(viewPager);
// return view;
// }
// }
// Path: ask-remote-module/src/main/java/com/androidstarterkit/module/sample/activity/SlidingTabActivity.java
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import com.androidstarterkit.module.R;
import com.androidstarterkit.module.ui.view.SlidingTabFragment;
package com.androidstarterkit.module.sample.activity;
public class SlidingTabActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getSupportActionBar().setElevation(0);
setContentView(R.layout.activity_sample_main);
if (savedInstanceState == null) {
getSupportFragmentManager()
.beginTransaction() | .add(R.id.container, new SlidingTabFragment()) |
kimkevin/AndroidStarterKit | ask-remote-module/src/main/java/com/androidstarterkit/module/ui/view/GridViewFragment.java | // Path: ask-remote-module/src/main/java/com/androidstarterkit/module/ui/adapter/GridViewAdapter.java
// public class GridViewAdapter extends BaseAdapter {
// private Context context;
// private List<AndroidPlatform> platforms;
// private int columnWidth;
//
// public GridViewAdapter(Context context, List<AndroidPlatform> platforms, int columnWidth) {
// this.context = context;
// this.platforms = platforms;
// this.columnWidth = columnWidth;
// }
//
// @Override
// public int getCount() {
// return platforms.size();
// }
//
// @Override
// public Object getItem(int position) {
// return platforms.get(position);
// }
//
// @Override
// public long getItemId(int position) {
// return 0;
// }
//
// @Override
// public View getView(int position, View convertView, ViewGroup parent) {
// AndroidPlatform platform = (AndroidPlatform) getItem(position);
//
// ViewHolder viewHolder;
//
// if (convertView == null) {
// LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
// convertView = inflater.inflate(R.layout.layout_grid_item, parent, false);
//
// ((AbsListView.LayoutParams) convertView.getLayoutParams()).height = columnWidth;
//
// viewHolder = new ViewHolder();
// viewHolder.img = (ImageView) convertView.findViewById(R.id.cell_img);
// viewHolder.txt = (TextView) convertView.findViewById(R.id.cell_txt);
// convertView.setTag(viewHolder);
// } else {
// viewHolder = (ViewHolder) convertView.getTag();
// }
//
// Glide.with(context).load(platform.getLogoUrl()).into(viewHolder.img);
// viewHolder.txt.setText(platform.getVerCode());
//
// return convertView;
// }
//
// static class ViewHolder {
// public ImageView img;
// public TextView txt;
// }
// }
//
// Path: ask-remote-module/src/main/java/com/androidstarterkit/module/data/AndroidPlatform.java
// public class AndroidPlatform {
// private static final String FILE_PATH = "https://raw.githubusercontent.com/kimkevin/AndroidStarterKit/master/assets/";
// private static final String EXTENSION_NAME = ".png";
//
// private String name;
// private String verCode;
// private int apiLevel;
// private String logoUrl;
//
// public AndroidPlatform(String name, String verCode, int apiLevel) {
// this.name = name;
// this.verCode = verCode;
// this.apiLevel = apiLevel;
// this.logoUrl = FILE_PATH + name + EXTENSION_NAME;
// }
//
// public String getName() {
// return name.toUpperCase() + " " + apiLevel;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getVerCode() {
// return "Android " + verCode;
// }
//
// public void setVerCode(String version) {
// this.verCode = version;
// }
//
// public int getApiLevel() {
// return apiLevel;
// }
//
// public void setApiLevel(int apiLevel) {
// this.apiLevel = apiLevel;
// }
//
// public String getLogoUrl() {
// return logoUrl;
// }
//
// public void setLogoUrl(String logoUrl) {
// this.logoUrl = logoUrl;
// }
// }
| import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.util.DisplayMetrics;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.GridView;
import com.androidstarterkit.module.R;
import com.androidstarterkit.module.ui.adapter.GridViewAdapter;
import com.androidstarterkit.module.data.AndroidPlatform;
import java.util.ArrayList;
import java.util.List; | package com.androidstarterkit.module.ui.view;
public class GridViewFragment extends Fragment {
private static List<AndroidPlatform> platforms = new ArrayList<>();
static {
platforms.add(new AndroidPlatform("applepie", "1.0", 1));
platforms.add(new AndroidPlatform("bananabread", "1.1", 2));
platforms.add(new AndroidPlatform("cupcake", "1.5", 3));
platforms.add(new AndroidPlatform("donut", "1.6", 4));
platforms.add(new AndroidPlatform("eclair", "2.0", 5));
platforms.add(new AndroidPlatform("froyo", "2.2", 8));
platforms.add(new AndroidPlatform("gingerbread", "2.3", 9));
platforms.add(new AndroidPlatform("honeycomb", "3.0", 11));
platforms.add(new AndroidPlatform("icecreamsandwich", "4.0", 14));
platforms.add(new AndroidPlatform("kitkat", "4.4", 19));
platforms.add(new AndroidPlatform("lollipop", "5.0", 21));
platforms.add(new AndroidPlatform("marshmallow", "6.0", 23));
platforms.add(new AndroidPlatform("nougat", "7.0", 24));
}
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_gridview_main, null);
final int colSize = 3;
final int columnWidth = getScreenWidth() / colSize;
GridView gridView = (GridView) view.findViewById(R.id.grid_view);
gridView.setNumColumns(colSize);
gridView.setColumnWidth(columnWidth); | // Path: ask-remote-module/src/main/java/com/androidstarterkit/module/ui/adapter/GridViewAdapter.java
// public class GridViewAdapter extends BaseAdapter {
// private Context context;
// private List<AndroidPlatform> platforms;
// private int columnWidth;
//
// public GridViewAdapter(Context context, List<AndroidPlatform> platforms, int columnWidth) {
// this.context = context;
// this.platforms = platforms;
// this.columnWidth = columnWidth;
// }
//
// @Override
// public int getCount() {
// return platforms.size();
// }
//
// @Override
// public Object getItem(int position) {
// return platforms.get(position);
// }
//
// @Override
// public long getItemId(int position) {
// return 0;
// }
//
// @Override
// public View getView(int position, View convertView, ViewGroup parent) {
// AndroidPlatform platform = (AndroidPlatform) getItem(position);
//
// ViewHolder viewHolder;
//
// if (convertView == null) {
// LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
// convertView = inflater.inflate(R.layout.layout_grid_item, parent, false);
//
// ((AbsListView.LayoutParams) convertView.getLayoutParams()).height = columnWidth;
//
// viewHolder = new ViewHolder();
// viewHolder.img = (ImageView) convertView.findViewById(R.id.cell_img);
// viewHolder.txt = (TextView) convertView.findViewById(R.id.cell_txt);
// convertView.setTag(viewHolder);
// } else {
// viewHolder = (ViewHolder) convertView.getTag();
// }
//
// Glide.with(context).load(platform.getLogoUrl()).into(viewHolder.img);
// viewHolder.txt.setText(platform.getVerCode());
//
// return convertView;
// }
//
// static class ViewHolder {
// public ImageView img;
// public TextView txt;
// }
// }
//
// Path: ask-remote-module/src/main/java/com/androidstarterkit/module/data/AndroidPlatform.java
// public class AndroidPlatform {
// private static final String FILE_PATH = "https://raw.githubusercontent.com/kimkevin/AndroidStarterKit/master/assets/";
// private static final String EXTENSION_NAME = ".png";
//
// private String name;
// private String verCode;
// private int apiLevel;
// private String logoUrl;
//
// public AndroidPlatform(String name, String verCode, int apiLevel) {
// this.name = name;
// this.verCode = verCode;
// this.apiLevel = apiLevel;
// this.logoUrl = FILE_PATH + name + EXTENSION_NAME;
// }
//
// public String getName() {
// return name.toUpperCase() + " " + apiLevel;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getVerCode() {
// return "Android " + verCode;
// }
//
// public void setVerCode(String version) {
// this.verCode = version;
// }
//
// public int getApiLevel() {
// return apiLevel;
// }
//
// public void setApiLevel(int apiLevel) {
// this.apiLevel = apiLevel;
// }
//
// public String getLogoUrl() {
// return logoUrl;
// }
//
// public void setLogoUrl(String logoUrl) {
// this.logoUrl = logoUrl;
// }
// }
// Path: ask-remote-module/src/main/java/com/androidstarterkit/module/ui/view/GridViewFragment.java
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.util.DisplayMetrics;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.GridView;
import com.androidstarterkit.module.R;
import com.androidstarterkit.module.ui.adapter.GridViewAdapter;
import com.androidstarterkit.module.data.AndroidPlatform;
import java.util.ArrayList;
import java.util.List;
package com.androidstarterkit.module.ui.view;
public class GridViewFragment extends Fragment {
private static List<AndroidPlatform> platforms = new ArrayList<>();
static {
platforms.add(new AndroidPlatform("applepie", "1.0", 1));
platforms.add(new AndroidPlatform("bananabread", "1.1", 2));
platforms.add(new AndroidPlatform("cupcake", "1.5", 3));
platforms.add(new AndroidPlatform("donut", "1.6", 4));
platforms.add(new AndroidPlatform("eclair", "2.0", 5));
platforms.add(new AndroidPlatform("froyo", "2.2", 8));
platforms.add(new AndroidPlatform("gingerbread", "2.3", 9));
platforms.add(new AndroidPlatform("honeycomb", "3.0", 11));
platforms.add(new AndroidPlatform("icecreamsandwich", "4.0", 14));
platforms.add(new AndroidPlatform("kitkat", "4.4", 19));
platforms.add(new AndroidPlatform("lollipop", "5.0", 21));
platforms.add(new AndroidPlatform("marshmallow", "6.0", 23));
platforms.add(new AndroidPlatform("nougat", "7.0", 24));
}
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_gridview_main, null);
final int colSize = 3;
final int columnWidth = getScreenWidth() / colSize;
GridView gridView = (GridView) view.findViewById(R.id.grid_view);
gridView.setNumColumns(colSize);
gridView.setColumnWidth(columnWidth); | gridView.setAdapter(new GridViewAdapter(getActivity(), platforms, columnWidth)); |
kimkevin/AndroidStarterKit | ask-app/src/main/java/com/androidstarterkit/tool/XmlDomReader.java | // Path: ask-app/src/main/java/com/androidstarterkit/exception/IllegalDocumentException.java
// public class IllegalDocumentException extends RuntimeException {
//
// public IllegalDocumentException(String msg) {
// super(msg);
// }
// }
| import com.androidstarterkit.exception.IllegalDocumentException;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.xml.sax.SAXException;
import java.io.File;
import java.io.IOException;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException; | package com.androidstarterkit.tool;
public class XmlDomReader {
private static final String TAG = XmlDomReader.class.getSimpleName();
private Document document;
public XmlDomReader(File file) {
DocumentBuilderFactory builderFactory = DocumentBuilderFactory.newInstance();
DocumentBuilder documentBuilder;
try {
documentBuilder = builderFactory.newDocumentBuilder();
document = documentBuilder.parse(file);
} catch (ParserConfigurationException | SAXException | IOException e) { | // Path: ask-app/src/main/java/com/androidstarterkit/exception/IllegalDocumentException.java
// public class IllegalDocumentException extends RuntimeException {
//
// public IllegalDocumentException(String msg) {
// super(msg);
// }
// }
// Path: ask-app/src/main/java/com/androidstarterkit/tool/XmlDomReader.java
import com.androidstarterkit.exception.IllegalDocumentException;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.xml.sax.SAXException;
import java.io.File;
import java.io.IOException;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
package com.androidstarterkit.tool;
public class XmlDomReader {
private static final String TAG = XmlDomReader.class.getSimpleName();
private Document document;
public XmlDomReader(File file) {
DocumentBuilderFactory builderFactory = DocumentBuilderFactory.newInstance();
DocumentBuilder documentBuilder;
try {
documentBuilder = builderFactory.newDocumentBuilder();
document = documentBuilder.parse(file);
} catch (ParserConfigurationException | SAXException | IOException e) { | throw new IllegalDocumentException("failed to create document : " + file.getPath()); |
kimkevin/AndroidStarterKit | ask-remote-module/src/main/java/com/androidstarterkit/module/ui/view/RecyclerViewFragment.java | // Path: ask-remote-module/src/main/java/com/androidstarterkit/module/ui/adapter/RecyclerViewAdapter.java
// public class RecyclerViewAdapter extends RecyclerView.Adapter<RecyclerViewAdapter.ViewHolder> {
// private Context context;
// private List<AndroidPlatform> platforms;
//
// public RecyclerViewAdapter(Context context, List<AndroidPlatform> platforms) {
// this.context = context;
// this.platforms = platforms;
// }
//
// @Override
// public RecyclerViewAdapter.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
// View v = LayoutInflater.from(context).inflate(R.layout.layout_list_item, parent, false);
// return new ViewHolder(v);
// }
//
// @Override
// public void onBindViewHolder(final RecyclerViewAdapter.ViewHolder holder, final int position) {
// AndroidPlatform platform = platforms.get(position);
//
// Glide.with(context).load(platform.getLogoUrl()).into(holder.logo);
// holder.name.setText(platform.getName());
// holder.platformVer.setText(platform.getVerCode());
// }
//
// @Override
// public int getItemCount() {
// return platforms.size();
// }
//
// static class ViewHolder extends RecyclerView.ViewHolder {
// public ImageView logo;
// public TextView name;
// public TextView platformVer;
//
// ViewHolder(View itemView) {
// super(itemView);
//
// logo = (ImageView) itemView.findViewById(R.id.img);
// name = (TextView) itemView.findViewById(R.id.name);
// platformVer = (TextView) itemView.findViewById(R.id.platform_ver);
// }
// }
// }
//
// Path: ask-remote-module/src/main/java/com/androidstarterkit/module/data/AndroidPlatform.java
// public class AndroidPlatform {
// private static final String FILE_PATH = "https://raw.githubusercontent.com/kimkevin/AndroidStarterKit/master/assets/";
// private static final String EXTENSION_NAME = ".png";
//
// private String name;
// private String verCode;
// private int apiLevel;
// private String logoUrl;
//
// public AndroidPlatform(String name, String verCode, int apiLevel) {
// this.name = name;
// this.verCode = verCode;
// this.apiLevel = apiLevel;
// this.logoUrl = FILE_PATH + name + EXTENSION_NAME;
// }
//
// public String getName() {
// return name.toUpperCase() + " " + apiLevel;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getVerCode() {
// return "Android " + verCode;
// }
//
// public void setVerCode(String version) {
// this.verCode = version;
// }
//
// public int getApiLevel() {
// return apiLevel;
// }
//
// public void setApiLevel(int apiLevel) {
// this.apiLevel = apiLevel;
// }
//
// public String getLogoUrl() {
// return logoUrl;
// }
//
// public void setLogoUrl(String logoUrl) {
// this.logoUrl = logoUrl;
// }
// }
| import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import com.androidstarterkit.module.R;
import com.androidstarterkit.module.ui.adapter.RecyclerViewAdapter;
import com.androidstarterkit.module.data.AndroidPlatform;
import java.util.ArrayList;
import java.util.List; | package com.androidstarterkit.module.ui.view;
public class RecyclerViewFragment extends Fragment {
private static List<AndroidPlatform> platforms = new ArrayList<>();
static {
platforms.add(new AndroidPlatform("applepie", "1.0", 1));
platforms.add(new AndroidPlatform("bananabread", "1.1", 2));
platforms.add(new AndroidPlatform("cupcake", "1.5", 3));
platforms.add(new AndroidPlatform("donut", "1.6", 4));
platforms.add(new AndroidPlatform("eclair", "2.0", 5));
platforms.add(new AndroidPlatform("froyo", "2.2", 8));
platforms.add(new AndroidPlatform("gingerbread", "2.3", 9));
platforms.add(new AndroidPlatform("honeycomb", "3.0", 11));
platforms.add(new AndroidPlatform("icecreamsandwich", "4.0", 14));
platforms.add(new AndroidPlatform("kitkat", "4.4", 19));
platforms.add(new AndroidPlatform("lollipop", "5.0", 21));
platforms.add(new AndroidPlatform("marshmallow", "6.0", 23));
platforms.add(new AndroidPlatform("nougat", "7.0", 24));
}
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_recyclerview_main, null);
RecyclerView recyclerView = (RecyclerView) view.findViewById(R.id.recycler_view);
recyclerView.setLayoutManager(new LinearLayoutManager(getActivity()));
| // Path: ask-remote-module/src/main/java/com/androidstarterkit/module/ui/adapter/RecyclerViewAdapter.java
// public class RecyclerViewAdapter extends RecyclerView.Adapter<RecyclerViewAdapter.ViewHolder> {
// private Context context;
// private List<AndroidPlatform> platforms;
//
// public RecyclerViewAdapter(Context context, List<AndroidPlatform> platforms) {
// this.context = context;
// this.platforms = platforms;
// }
//
// @Override
// public RecyclerViewAdapter.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
// View v = LayoutInflater.from(context).inflate(R.layout.layout_list_item, parent, false);
// return new ViewHolder(v);
// }
//
// @Override
// public void onBindViewHolder(final RecyclerViewAdapter.ViewHolder holder, final int position) {
// AndroidPlatform platform = platforms.get(position);
//
// Glide.with(context).load(platform.getLogoUrl()).into(holder.logo);
// holder.name.setText(platform.getName());
// holder.platformVer.setText(platform.getVerCode());
// }
//
// @Override
// public int getItemCount() {
// return platforms.size();
// }
//
// static class ViewHolder extends RecyclerView.ViewHolder {
// public ImageView logo;
// public TextView name;
// public TextView platformVer;
//
// ViewHolder(View itemView) {
// super(itemView);
//
// logo = (ImageView) itemView.findViewById(R.id.img);
// name = (TextView) itemView.findViewById(R.id.name);
// platformVer = (TextView) itemView.findViewById(R.id.platform_ver);
// }
// }
// }
//
// Path: ask-remote-module/src/main/java/com/androidstarterkit/module/data/AndroidPlatform.java
// public class AndroidPlatform {
// private static final String FILE_PATH = "https://raw.githubusercontent.com/kimkevin/AndroidStarterKit/master/assets/";
// private static final String EXTENSION_NAME = ".png";
//
// private String name;
// private String verCode;
// private int apiLevel;
// private String logoUrl;
//
// public AndroidPlatform(String name, String verCode, int apiLevel) {
// this.name = name;
// this.verCode = verCode;
// this.apiLevel = apiLevel;
// this.logoUrl = FILE_PATH + name + EXTENSION_NAME;
// }
//
// public String getName() {
// return name.toUpperCase() + " " + apiLevel;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getVerCode() {
// return "Android " + verCode;
// }
//
// public void setVerCode(String version) {
// this.verCode = version;
// }
//
// public int getApiLevel() {
// return apiLevel;
// }
//
// public void setApiLevel(int apiLevel) {
// this.apiLevel = apiLevel;
// }
//
// public String getLogoUrl() {
// return logoUrl;
// }
//
// public void setLogoUrl(String logoUrl) {
// this.logoUrl = logoUrl;
// }
// }
// Path: ask-remote-module/src/main/java/com/androidstarterkit/module/ui/view/RecyclerViewFragment.java
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import com.androidstarterkit.module.R;
import com.androidstarterkit.module.ui.adapter.RecyclerViewAdapter;
import com.androidstarterkit.module.data.AndroidPlatform;
import java.util.ArrayList;
import java.util.List;
package com.androidstarterkit.module.ui.view;
public class RecyclerViewFragment extends Fragment {
private static List<AndroidPlatform> platforms = new ArrayList<>();
static {
platforms.add(new AndroidPlatform("applepie", "1.0", 1));
platforms.add(new AndroidPlatform("bananabread", "1.1", 2));
platforms.add(new AndroidPlatform("cupcake", "1.5", 3));
platforms.add(new AndroidPlatform("donut", "1.6", 4));
platforms.add(new AndroidPlatform("eclair", "2.0", 5));
platforms.add(new AndroidPlatform("froyo", "2.2", 8));
platforms.add(new AndroidPlatform("gingerbread", "2.3", 9));
platforms.add(new AndroidPlatform("honeycomb", "3.0", 11));
platforms.add(new AndroidPlatform("icecreamsandwich", "4.0", 14));
platforms.add(new AndroidPlatform("kitkat", "4.4", 19));
platforms.add(new AndroidPlatform("lollipop", "5.0", 21));
platforms.add(new AndroidPlatform("marshmallow", "6.0", 23));
platforms.add(new AndroidPlatform("nougat", "7.0", 24));
}
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_recyclerview_main, null);
RecyclerView recyclerView = (RecyclerView) view.findViewById(R.id.recycler_view);
recyclerView.setLayoutManager(new LinearLayoutManager(getActivity()));
| RecyclerViewAdapter recyclerViewAdapter = new RecyclerViewAdapter(getActivity(), platforms); |
kimkevin/AndroidStarterKit | ask-app/src/main/java/com/androidstarterkit/tool/ExternalLibrary.java | // Path: ask-app/src/main/java/com/androidstarterkit/android/api/manifest/Permission.java
// public enum Permission {
// INTERNET;
//
// @Override
// public String toString() {
// return "android.permission." + name();
// }
// }
| import com.androidstarterkit.android.api.manifest.Permission;
import java.util.HashMap;
import java.util.Map;
import java.util.Set; | package com.androidstarterkit.tool;
public class ExternalLibrary {
protected Map<String, Info> dictionary;
public ExternalLibrary(String supportLibraryVersion) {
dictionary = new HashMap<>();
dictionary.put("CardView", new Info("com.android.support:cardview-v7:" + supportLibraryVersion));
dictionary.put("RecyclerView", new Info("com.android.support:recyclerview-v7:" + supportLibraryVersion)); | // Path: ask-app/src/main/java/com/androidstarterkit/android/api/manifest/Permission.java
// public enum Permission {
// INTERNET;
//
// @Override
// public String toString() {
// return "android.permission." + name();
// }
// }
// Path: ask-app/src/main/java/com/androidstarterkit/tool/ExternalLibrary.java
import com.androidstarterkit.android.api.manifest.Permission;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
package com.androidstarterkit.tool;
public class ExternalLibrary {
protected Map<String, Info> dictionary;
public ExternalLibrary(String supportLibraryVersion) {
dictionary = new HashMap<>();
dictionary.put("CardView", new Info("com.android.support:cardview-v7:" + supportLibraryVersion));
dictionary.put("RecyclerView", new Info("com.android.support:recyclerview-v7:" + supportLibraryVersion)); | dictionary.put("Glide", new Info("com.github.bumptech.glide:glide:3.7.0", Permission.INTERNET)); |
jakenjarvis/Android-OrmLiteContentProvider | ormlite-content-provider-sample/src/com/tojc/ormlite/android/ormlitecontentprovider/sample/MainActivity.java | // Path: ormlite-content-provider-sample/src/com/tojc/ormlite/android/ormlitecontentprovider/sample/provider/AccountContract.java
// public final class AccountContract implements BaseColumns {
//
// private AccountContract() {
// // Utility constructor
// }
//
// public static final String TABLE_NAME = "Account";
//
// public static final String AUTHORITY = "com.tojc.ormlite.android.ormlitecontentprovider.sample";
//
// public static final String CONTENT_URI_PATH = "accounts";
//
// public static final String MIMETYPE_TYPE = "accounts";
// public static final String MIMETYPE_NAME = "com.tojc.ormlite.android.ormlitecontentprovider.sample.provider";
//
// public static final int CONTENT_URI_PATTERN_MANY = 1;
// public static final int CONTENT_URI_PATTERN_ONE = 2;
//
// public static final Uri CONTENT_URI = new Uri.Builder().scheme(ContentResolver.SCHEME_CONTENT).authority(AUTHORITY).appendPath(CONTENT_URI_PATH).build();
//
// public static final String NAME = "name";
// }
| import android.util.Log;
import android.view.Menu;
import com.tojc.ormlite.android.ormlitecontentprovider.sample.provider.AccountContract;
import java.util.ArrayList;
import android.app.Activity;
import android.content.ContentProviderClient;
import android.content.ContentProviderOperation;
import android.content.ContentValues;
import android.database.Cursor;
import android.os.Bundle;
import android.os.RemoteException; | /*
* This file is part of the Android-OrmLiteContentProvider package.
*
* Copyright (c) 2012, Android-OrmLiteContentProvider Team.
* Jaken Jarvis (jaken.jarvis@gmail.com)
*
* 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.
*
* The author may be contacted via
* https://github.com/jakenjarvis/Android-OrmLiteContentProvider
*/
package com.tojc.ormlite.android.ormlitecontentprovider.sample;
public class MainActivity extends Activity {
private static final int TEST_ENTRY_COUNT = 10;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
// insert test
ContentValues values = new ContentValues();
values.clear(); | // Path: ormlite-content-provider-sample/src/com/tojc/ormlite/android/ormlitecontentprovider/sample/provider/AccountContract.java
// public final class AccountContract implements BaseColumns {
//
// private AccountContract() {
// // Utility constructor
// }
//
// public static final String TABLE_NAME = "Account";
//
// public static final String AUTHORITY = "com.tojc.ormlite.android.ormlitecontentprovider.sample";
//
// public static final String CONTENT_URI_PATH = "accounts";
//
// public static final String MIMETYPE_TYPE = "accounts";
// public static final String MIMETYPE_NAME = "com.tojc.ormlite.android.ormlitecontentprovider.sample.provider";
//
// public static final int CONTENT_URI_PATTERN_MANY = 1;
// public static final int CONTENT_URI_PATTERN_ONE = 2;
//
// public static final Uri CONTENT_URI = new Uri.Builder().scheme(ContentResolver.SCHEME_CONTENT).authority(AUTHORITY).appendPath(CONTENT_URI_PATH).build();
//
// public static final String NAME = "name";
// }
// Path: ormlite-content-provider-sample/src/com/tojc/ormlite/android/ormlitecontentprovider/sample/MainActivity.java
import android.util.Log;
import android.view.Menu;
import com.tojc.ormlite.android.ormlitecontentprovider.sample.provider.AccountContract;
import java.util.ArrayList;
import android.app.Activity;
import android.content.ContentProviderClient;
import android.content.ContentProviderOperation;
import android.content.ContentValues;
import android.database.Cursor;
import android.os.Bundle;
import android.os.RemoteException;
/*
* This file is part of the Android-OrmLiteContentProvider package.
*
* Copyright (c) 2012, Android-OrmLiteContentProvider Team.
* Jaken Jarvis (jaken.jarvis@gmail.com)
*
* 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.
*
* The author may be contacted via
* https://github.com/jakenjarvis/Android-OrmLiteContentProvider
*/
package com.tojc.ormlite.android.ormlitecontentprovider.sample;
public class MainActivity extends Activity {
private static final int TEST_ENTRY_COUNT = 10;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
// insert test
ContentValues values = new ContentValues();
values.clear(); | values.put(AccountContract.NAME, "Yamada Tarou"); |
jakenjarvis/Android-OrmLiteContentProvider | ormlite-content-provider-library/src/com/tojc/ormlite/android/framework/MatcherPattern.java | // Path: ormlite-content-provider-library/src/com/tojc/ormlite/android/annotation/info/ContentUriInfo.java
// public class ContentUriInfo extends AnnotationInfoBase {
// // ----------------------------------
// // ATTRIBUTES
// // ----------------------------------
// private String authority;
// private String path;
//
// // ----------------------------------
// // CONSTRUCTORS
// // ----------------------------------
// public ContentUriInfo(AnnotatedElement element) {
// DefaultContentUri contentUri = element.getAnnotation(DefaultContentUri.class);
// String authority = null;
// String path = null;
// if (contentUri != null) {
// authority = contentUri.authority();
// path = contentUri.path();
// }
//
// if (element instanceof Class<?>) {
// Class<?> clazz = (Class<?>) element;
// if (TextUtils.isEmpty(authority)) {
// authority = clazz.getPackage().getName();
// }
// if (TextUtils.isEmpty(path)) {
// // TODO use DataBase annotation
// path = clazz.getSimpleName().toLowerCase();
// }
// }
//
// initialize(authority, path);
// }
//
// public ContentUriInfo(String authority, String path) {
// initialize(authority, path);
// }
//
// // ----------------------------------
// // PUBLIC METHODS
// // ----------------------------------
// public String getAuthority() {
// return this.authority;
// }
//
// public String getPath() {
// return this.path;
// }
//
// public Uri getContentUri() {
// return new Uri.Builder().scheme(ContentResolver.SCHEME_CONTENT).authority(this.authority).appendPath(this.path).build();
// }
//
// @Override
// protected boolean isValidValue() {
// return !TextUtils.isEmpty(this.authority) && !TextUtils.isEmpty(this.path);
// }
//
// // ----------------------------------
// // PRIVATE METHODS
// // ----------------------------------
// private void initialize(String authority, String path) {
// this.authority = authority;
// this.path = path;
// validFlagOn();
// }
//
// @Override
// public String toString() {
// return "ContentUriInfo{"
// + "authority='" + authority + '\''
// + ", path='" + path + '\''
// + "} " + super.toString();
// }
// }
| import com.tojc.ormlite.android.annotation.info.ContentMimeTypeVndInfo;
import com.tojc.ormlite.android.annotation.info.ContentUriInfo;
import com.tojc.ormlite.android.framework.MimeTypeVnd.SubType;
import android.net.Uri; | /*
* This file is part of the Android-OrmLiteContentProvider package.
*
* Copyright (c) 2012, Android-OrmLiteContentProvider Team.
* Jaken Jarvis (jaken.jarvis@gmail.com)
*
* 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.
*
* The author may be contacted via
* https://github.com/jakenjarvis/Android-OrmLiteContentProvider
*/
package com.tojc.ormlite.android.framework;
/**
* Manage the UriMatcher pattern. It holds information related to the pattern code.
* @author Jaken
*/
public class MatcherPattern implements Validity {
private boolean initialized = false;
private TableInfo tableInfo;
private SubType subType;
private String pattern;
private int patternCode;
| // Path: ormlite-content-provider-library/src/com/tojc/ormlite/android/annotation/info/ContentUriInfo.java
// public class ContentUriInfo extends AnnotationInfoBase {
// // ----------------------------------
// // ATTRIBUTES
// // ----------------------------------
// private String authority;
// private String path;
//
// // ----------------------------------
// // CONSTRUCTORS
// // ----------------------------------
// public ContentUriInfo(AnnotatedElement element) {
// DefaultContentUri contentUri = element.getAnnotation(DefaultContentUri.class);
// String authority = null;
// String path = null;
// if (contentUri != null) {
// authority = contentUri.authority();
// path = contentUri.path();
// }
//
// if (element instanceof Class<?>) {
// Class<?> clazz = (Class<?>) element;
// if (TextUtils.isEmpty(authority)) {
// authority = clazz.getPackage().getName();
// }
// if (TextUtils.isEmpty(path)) {
// // TODO use DataBase annotation
// path = clazz.getSimpleName().toLowerCase();
// }
// }
//
// initialize(authority, path);
// }
//
// public ContentUriInfo(String authority, String path) {
// initialize(authority, path);
// }
//
// // ----------------------------------
// // PUBLIC METHODS
// // ----------------------------------
// public String getAuthority() {
// return this.authority;
// }
//
// public String getPath() {
// return this.path;
// }
//
// public Uri getContentUri() {
// return new Uri.Builder().scheme(ContentResolver.SCHEME_CONTENT).authority(this.authority).appendPath(this.path).build();
// }
//
// @Override
// protected boolean isValidValue() {
// return !TextUtils.isEmpty(this.authority) && !TextUtils.isEmpty(this.path);
// }
//
// // ----------------------------------
// // PRIVATE METHODS
// // ----------------------------------
// private void initialize(String authority, String path) {
// this.authority = authority;
// this.path = path;
// validFlagOn();
// }
//
// @Override
// public String toString() {
// return "ContentUriInfo{"
// + "authority='" + authority + '\''
// + ", path='" + path + '\''
// + "} " + super.toString();
// }
// }
// Path: ormlite-content-provider-library/src/com/tojc/ormlite/android/framework/MatcherPattern.java
import com.tojc.ormlite.android.annotation.info.ContentMimeTypeVndInfo;
import com.tojc.ormlite.android.annotation.info.ContentUriInfo;
import com.tojc.ormlite.android.framework.MimeTypeVnd.SubType;
import android.net.Uri;
/*
* This file is part of the Android-OrmLiteContentProvider package.
*
* Copyright (c) 2012, Android-OrmLiteContentProvider Team.
* Jaken Jarvis (jaken.jarvis@gmail.com)
*
* 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.
*
* The author may be contacted via
* https://github.com/jakenjarvis/Android-OrmLiteContentProvider
*/
package com.tojc.ormlite.android.framework;
/**
* Manage the UriMatcher pattern. It holds information related to the pattern code.
* @author Jaken
*/
public class MatcherPattern implements Validity {
private boolean initialized = false;
private TableInfo tableInfo;
private SubType subType;
private String pattern;
private int patternCode;
| private ContentUriInfo contentUriInfo; |
jakenjarvis/Android-OrmLiteContentProvider | ormlite-content-provider-library/src/com/tojc/ormlite/android/framework/TableInfo.java | // Path: ormlite-content-provider-library/src/com/tojc/ormlite/android/annotation/OrmLiteAnnotationAccessor.java
// public final class OrmLiteAnnotationAccessor {
//
// private OrmLiteAnnotationAccessor() {
// // utility constructor
// }
//
// /**
// * Gets the table name from DatabaseTable annotation. If the DatabaseTable#tableName is not
// * specified, returns the class name.
// * @param element
// * Element to be evaluated.
// * @return Returns the table name.
// */
// public static String getAnnotationTableName(AnnotatedElement element) {
// String result = "";
// result = DatabaseTableConfig.extractTableName((Class<?>) element);
// return result;
// }
//
// /**
// * Gets the column name from DatabaseField annotation. If the DatabaseField#columnName is not
// * specified, returns the field name.
// * @param element
// * Element to be evaluated.
// * @return Returns the column name.
// */
// public static String getAnnotationColumnName(AnnotatedElement element) {
// String result = "";
// DatabaseField databaseField = element.getAnnotation(DatabaseField.class);
// if (databaseField != null) {
// result = databaseField.columnName();
// if (TextUtils.isEmpty(result)) {
// result = ((Field) element).getName();
// }
// }
// return result;
// }
// }
//
// Path: ormlite-content-provider-library/src/com/tojc/ormlite/android/annotation/info/ContentUriInfo.java
// public class ContentUriInfo extends AnnotationInfoBase {
// // ----------------------------------
// // ATTRIBUTES
// // ----------------------------------
// private String authority;
// private String path;
//
// // ----------------------------------
// // CONSTRUCTORS
// // ----------------------------------
// public ContentUriInfo(AnnotatedElement element) {
// DefaultContentUri contentUri = element.getAnnotation(DefaultContentUri.class);
// String authority = null;
// String path = null;
// if (contentUri != null) {
// authority = contentUri.authority();
// path = contentUri.path();
// }
//
// if (element instanceof Class<?>) {
// Class<?> clazz = (Class<?>) element;
// if (TextUtils.isEmpty(authority)) {
// authority = clazz.getPackage().getName();
// }
// if (TextUtils.isEmpty(path)) {
// // TODO use DataBase annotation
// path = clazz.getSimpleName().toLowerCase();
// }
// }
//
// initialize(authority, path);
// }
//
// public ContentUriInfo(String authority, String path) {
// initialize(authority, path);
// }
//
// // ----------------------------------
// // PUBLIC METHODS
// // ----------------------------------
// public String getAuthority() {
// return this.authority;
// }
//
// public String getPath() {
// return this.path;
// }
//
// public Uri getContentUri() {
// return new Uri.Builder().scheme(ContentResolver.SCHEME_CONTENT).authority(this.authority).appendPath(this.path).build();
// }
//
// @Override
// protected boolean isValidValue() {
// return !TextUtils.isEmpty(this.authority) && !TextUtils.isEmpty(this.path);
// }
//
// // ----------------------------------
// // PRIVATE METHODS
// // ----------------------------------
// private void initialize(String authority, String path) {
// this.authority = authority;
// this.path = path;
// validFlagOn();
// }
//
// @Override
// public String toString() {
// return "ContentUriInfo{"
// + "authority='" + authority + '\''
// + ", path='" + path + '\''
// + "} " + super.toString();
// }
// }
| import com.j256.ormlite.field.DatabaseField;
import com.tojc.ormlite.android.annotation.OrmLiteAnnotationAccessor;
import com.tojc.ormlite.android.annotation.info.ContentMimeTypeVndInfo;
import com.tojc.ormlite.android.annotation.info.ContentUriInfo;
import com.tojc.ormlite.android.annotation.info.SortOrderInfo;
import java.lang.reflect.Field;
import java.util.HashMap;
import java.util.Map;
import java.util.SortedMap;
import java.util.TreeMap;
import android.text.TextUtils;
import android.provider.BaseColumns; | /*
* This file is part of the Android-OrmLiteContentProvider package.
*
* Copyright (c) 2012, Android-OrmLiteContentProvider Team.
* Jaken Jarvis (jaken.jarvis@gmail.com)
*
* 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.
*
* The author may be contacted via
* https://github.com/jakenjarvis/Android-OrmLiteContentProvider
*/
package com.tojc.ormlite.android.framework;
/**
* Manage the database table information.
* @author Jaken
*/
public class TableInfo implements Validity {
private Class<?> classType;
private String name;
| // Path: ormlite-content-provider-library/src/com/tojc/ormlite/android/annotation/OrmLiteAnnotationAccessor.java
// public final class OrmLiteAnnotationAccessor {
//
// private OrmLiteAnnotationAccessor() {
// // utility constructor
// }
//
// /**
// * Gets the table name from DatabaseTable annotation. If the DatabaseTable#tableName is not
// * specified, returns the class name.
// * @param element
// * Element to be evaluated.
// * @return Returns the table name.
// */
// public static String getAnnotationTableName(AnnotatedElement element) {
// String result = "";
// result = DatabaseTableConfig.extractTableName((Class<?>) element);
// return result;
// }
//
// /**
// * Gets the column name from DatabaseField annotation. If the DatabaseField#columnName is not
// * specified, returns the field name.
// * @param element
// * Element to be evaluated.
// * @return Returns the column name.
// */
// public static String getAnnotationColumnName(AnnotatedElement element) {
// String result = "";
// DatabaseField databaseField = element.getAnnotation(DatabaseField.class);
// if (databaseField != null) {
// result = databaseField.columnName();
// if (TextUtils.isEmpty(result)) {
// result = ((Field) element).getName();
// }
// }
// return result;
// }
// }
//
// Path: ormlite-content-provider-library/src/com/tojc/ormlite/android/annotation/info/ContentUriInfo.java
// public class ContentUriInfo extends AnnotationInfoBase {
// // ----------------------------------
// // ATTRIBUTES
// // ----------------------------------
// private String authority;
// private String path;
//
// // ----------------------------------
// // CONSTRUCTORS
// // ----------------------------------
// public ContentUriInfo(AnnotatedElement element) {
// DefaultContentUri contentUri = element.getAnnotation(DefaultContentUri.class);
// String authority = null;
// String path = null;
// if (contentUri != null) {
// authority = contentUri.authority();
// path = contentUri.path();
// }
//
// if (element instanceof Class<?>) {
// Class<?> clazz = (Class<?>) element;
// if (TextUtils.isEmpty(authority)) {
// authority = clazz.getPackage().getName();
// }
// if (TextUtils.isEmpty(path)) {
// // TODO use DataBase annotation
// path = clazz.getSimpleName().toLowerCase();
// }
// }
//
// initialize(authority, path);
// }
//
// public ContentUriInfo(String authority, String path) {
// initialize(authority, path);
// }
//
// // ----------------------------------
// // PUBLIC METHODS
// // ----------------------------------
// public String getAuthority() {
// return this.authority;
// }
//
// public String getPath() {
// return this.path;
// }
//
// public Uri getContentUri() {
// return new Uri.Builder().scheme(ContentResolver.SCHEME_CONTENT).authority(this.authority).appendPath(this.path).build();
// }
//
// @Override
// protected boolean isValidValue() {
// return !TextUtils.isEmpty(this.authority) && !TextUtils.isEmpty(this.path);
// }
//
// // ----------------------------------
// // PRIVATE METHODS
// // ----------------------------------
// private void initialize(String authority, String path) {
// this.authority = authority;
// this.path = path;
// validFlagOn();
// }
//
// @Override
// public String toString() {
// return "ContentUriInfo{"
// + "authority='" + authority + '\''
// + ", path='" + path + '\''
// + "} " + super.toString();
// }
// }
// Path: ormlite-content-provider-library/src/com/tojc/ormlite/android/framework/TableInfo.java
import com.j256.ormlite.field.DatabaseField;
import com.tojc.ormlite.android.annotation.OrmLiteAnnotationAccessor;
import com.tojc.ormlite.android.annotation.info.ContentMimeTypeVndInfo;
import com.tojc.ormlite.android.annotation.info.ContentUriInfo;
import com.tojc.ormlite.android.annotation.info.SortOrderInfo;
import java.lang.reflect.Field;
import java.util.HashMap;
import java.util.Map;
import java.util.SortedMap;
import java.util.TreeMap;
import android.text.TextUtils;
import android.provider.BaseColumns;
/*
* This file is part of the Android-OrmLiteContentProvider package.
*
* Copyright (c) 2012, Android-OrmLiteContentProvider Team.
* Jaken Jarvis (jaken.jarvis@gmail.com)
*
* 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.
*
* The author may be contacted via
* https://github.com/jakenjarvis/Android-OrmLiteContentProvider
*/
package com.tojc.ormlite.android.framework;
/**
* Manage the database table information.
* @author Jaken
*/
public class TableInfo implements Validity {
private Class<?> classType;
private String name;
| private ContentUriInfo defaultContentUriInfo; |
jakenjarvis/Android-OrmLiteContentProvider | ormlite-content-provider-library/src/com/tojc/ormlite/android/framework/TableInfo.java | // Path: ormlite-content-provider-library/src/com/tojc/ormlite/android/annotation/OrmLiteAnnotationAccessor.java
// public final class OrmLiteAnnotationAccessor {
//
// private OrmLiteAnnotationAccessor() {
// // utility constructor
// }
//
// /**
// * Gets the table name from DatabaseTable annotation. If the DatabaseTable#tableName is not
// * specified, returns the class name.
// * @param element
// * Element to be evaluated.
// * @return Returns the table name.
// */
// public static String getAnnotationTableName(AnnotatedElement element) {
// String result = "";
// result = DatabaseTableConfig.extractTableName((Class<?>) element);
// return result;
// }
//
// /**
// * Gets the column name from DatabaseField annotation. If the DatabaseField#columnName is not
// * specified, returns the field name.
// * @param element
// * Element to be evaluated.
// * @return Returns the column name.
// */
// public static String getAnnotationColumnName(AnnotatedElement element) {
// String result = "";
// DatabaseField databaseField = element.getAnnotation(DatabaseField.class);
// if (databaseField != null) {
// result = databaseField.columnName();
// if (TextUtils.isEmpty(result)) {
// result = ((Field) element).getName();
// }
// }
// return result;
// }
// }
//
// Path: ormlite-content-provider-library/src/com/tojc/ormlite/android/annotation/info/ContentUriInfo.java
// public class ContentUriInfo extends AnnotationInfoBase {
// // ----------------------------------
// // ATTRIBUTES
// // ----------------------------------
// private String authority;
// private String path;
//
// // ----------------------------------
// // CONSTRUCTORS
// // ----------------------------------
// public ContentUriInfo(AnnotatedElement element) {
// DefaultContentUri contentUri = element.getAnnotation(DefaultContentUri.class);
// String authority = null;
// String path = null;
// if (contentUri != null) {
// authority = contentUri.authority();
// path = contentUri.path();
// }
//
// if (element instanceof Class<?>) {
// Class<?> clazz = (Class<?>) element;
// if (TextUtils.isEmpty(authority)) {
// authority = clazz.getPackage().getName();
// }
// if (TextUtils.isEmpty(path)) {
// // TODO use DataBase annotation
// path = clazz.getSimpleName().toLowerCase();
// }
// }
//
// initialize(authority, path);
// }
//
// public ContentUriInfo(String authority, String path) {
// initialize(authority, path);
// }
//
// // ----------------------------------
// // PUBLIC METHODS
// // ----------------------------------
// public String getAuthority() {
// return this.authority;
// }
//
// public String getPath() {
// return this.path;
// }
//
// public Uri getContentUri() {
// return new Uri.Builder().scheme(ContentResolver.SCHEME_CONTENT).authority(this.authority).appendPath(this.path).build();
// }
//
// @Override
// protected boolean isValidValue() {
// return !TextUtils.isEmpty(this.authority) && !TextUtils.isEmpty(this.path);
// }
//
// // ----------------------------------
// // PRIVATE METHODS
// // ----------------------------------
// private void initialize(String authority, String path) {
// this.authority = authority;
// this.path = path;
// validFlagOn();
// }
//
// @Override
// public String toString() {
// return "ContentUriInfo{"
// + "authority='" + authority + '\''
// + ", path='" + path + '\''
// + "} " + super.toString();
// }
// }
| import com.j256.ormlite.field.DatabaseField;
import com.tojc.ormlite.android.annotation.OrmLiteAnnotationAccessor;
import com.tojc.ormlite.android.annotation.info.ContentMimeTypeVndInfo;
import com.tojc.ormlite.android.annotation.info.ContentUriInfo;
import com.tojc.ormlite.android.annotation.info.SortOrderInfo;
import java.lang.reflect.Field;
import java.util.HashMap;
import java.util.Map;
import java.util.SortedMap;
import java.util.TreeMap;
import android.text.TextUtils;
import android.provider.BaseColumns; | /*
* This file is part of the Android-OrmLiteContentProvider package.
*
* Copyright (c) 2012, Android-OrmLiteContentProvider Team.
* Jaken Jarvis (jaken.jarvis@gmail.com)
*
* 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.
*
* The author may be contacted via
* https://github.com/jakenjarvis/Android-OrmLiteContentProvider
*/
package com.tojc.ormlite.android.framework;
/**
* Manage the database table information.
* @author Jaken
*/
public class TableInfo implements Validity {
private Class<?> classType;
private String name;
private ContentUriInfo defaultContentUriInfo;
private ContentMimeTypeVndInfo defaultContentMimeTypeVndInfo;
private Map<String, ColumnInfo> columns = null;
private Map<String, String> projectionMap = null;
private ColumnInfo idColumnInfo = null;
private String defaultSortOrder = "";
public TableInfo(Class<?> tableClassType) {
// can't happen
// keep a while, May 18th 2013
// TODO remove after a while
// if (!(tableClassType instanceof Class<?>)) {
// throw new IllegalArgumentException("Parameter is not a Class<?>.");
// }
this.classType = tableClassType; | // Path: ormlite-content-provider-library/src/com/tojc/ormlite/android/annotation/OrmLiteAnnotationAccessor.java
// public final class OrmLiteAnnotationAccessor {
//
// private OrmLiteAnnotationAccessor() {
// // utility constructor
// }
//
// /**
// * Gets the table name from DatabaseTable annotation. If the DatabaseTable#tableName is not
// * specified, returns the class name.
// * @param element
// * Element to be evaluated.
// * @return Returns the table name.
// */
// public static String getAnnotationTableName(AnnotatedElement element) {
// String result = "";
// result = DatabaseTableConfig.extractTableName((Class<?>) element);
// return result;
// }
//
// /**
// * Gets the column name from DatabaseField annotation. If the DatabaseField#columnName is not
// * specified, returns the field name.
// * @param element
// * Element to be evaluated.
// * @return Returns the column name.
// */
// public static String getAnnotationColumnName(AnnotatedElement element) {
// String result = "";
// DatabaseField databaseField = element.getAnnotation(DatabaseField.class);
// if (databaseField != null) {
// result = databaseField.columnName();
// if (TextUtils.isEmpty(result)) {
// result = ((Field) element).getName();
// }
// }
// return result;
// }
// }
//
// Path: ormlite-content-provider-library/src/com/tojc/ormlite/android/annotation/info/ContentUriInfo.java
// public class ContentUriInfo extends AnnotationInfoBase {
// // ----------------------------------
// // ATTRIBUTES
// // ----------------------------------
// private String authority;
// private String path;
//
// // ----------------------------------
// // CONSTRUCTORS
// // ----------------------------------
// public ContentUriInfo(AnnotatedElement element) {
// DefaultContentUri contentUri = element.getAnnotation(DefaultContentUri.class);
// String authority = null;
// String path = null;
// if (contentUri != null) {
// authority = contentUri.authority();
// path = contentUri.path();
// }
//
// if (element instanceof Class<?>) {
// Class<?> clazz = (Class<?>) element;
// if (TextUtils.isEmpty(authority)) {
// authority = clazz.getPackage().getName();
// }
// if (TextUtils.isEmpty(path)) {
// // TODO use DataBase annotation
// path = clazz.getSimpleName().toLowerCase();
// }
// }
//
// initialize(authority, path);
// }
//
// public ContentUriInfo(String authority, String path) {
// initialize(authority, path);
// }
//
// // ----------------------------------
// // PUBLIC METHODS
// // ----------------------------------
// public String getAuthority() {
// return this.authority;
// }
//
// public String getPath() {
// return this.path;
// }
//
// public Uri getContentUri() {
// return new Uri.Builder().scheme(ContentResolver.SCHEME_CONTENT).authority(this.authority).appendPath(this.path).build();
// }
//
// @Override
// protected boolean isValidValue() {
// return !TextUtils.isEmpty(this.authority) && !TextUtils.isEmpty(this.path);
// }
//
// // ----------------------------------
// // PRIVATE METHODS
// // ----------------------------------
// private void initialize(String authority, String path) {
// this.authority = authority;
// this.path = path;
// validFlagOn();
// }
//
// @Override
// public String toString() {
// return "ContentUriInfo{"
// + "authority='" + authority + '\''
// + ", path='" + path + '\''
// + "} " + super.toString();
// }
// }
// Path: ormlite-content-provider-library/src/com/tojc/ormlite/android/framework/TableInfo.java
import com.j256.ormlite.field.DatabaseField;
import com.tojc.ormlite.android.annotation.OrmLiteAnnotationAccessor;
import com.tojc.ormlite.android.annotation.info.ContentMimeTypeVndInfo;
import com.tojc.ormlite.android.annotation.info.ContentUriInfo;
import com.tojc.ormlite.android.annotation.info.SortOrderInfo;
import java.lang.reflect.Field;
import java.util.HashMap;
import java.util.Map;
import java.util.SortedMap;
import java.util.TreeMap;
import android.text.TextUtils;
import android.provider.BaseColumns;
/*
* This file is part of the Android-OrmLiteContentProvider package.
*
* Copyright (c) 2012, Android-OrmLiteContentProvider Team.
* Jaken Jarvis (jaken.jarvis@gmail.com)
*
* 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.
*
* The author may be contacted via
* https://github.com/jakenjarvis/Android-OrmLiteContentProvider
*/
package com.tojc.ormlite.android.framework;
/**
* Manage the database table information.
* @author Jaken
*/
public class TableInfo implements Validity {
private Class<?> classType;
private String name;
private ContentUriInfo defaultContentUriInfo;
private ContentMimeTypeVndInfo defaultContentMimeTypeVndInfo;
private Map<String, ColumnInfo> columns = null;
private Map<String, String> projectionMap = null;
private ColumnInfo idColumnInfo = null;
private String defaultSortOrder = "";
public TableInfo(Class<?> tableClassType) {
// can't happen
// keep a while, May 18th 2013
// TODO remove after a while
// if (!(tableClassType instanceof Class<?>)) {
// throw new IllegalArgumentException("Parameter is not a Class<?>.");
// }
this.classType = tableClassType; | this.name = OrmLiteAnnotationAccessor.getAnnotationTableName(tableClassType); |
jakenjarvis/Android-OrmLiteContentProvider | ormlite-content-provider-library-test/src/com/tojc/ormlite/android/TestOrmLiteSimpleProvider.java | // Path: ormlite-content-provider-library-test/src/com/tojc/ormlite/android/test/provider/AccountContract.java
// public final class AccountContract implements BaseColumns {
//
// private AccountContract() {
// // utility constructor
// }
//
// public static final String AUTHORITY = "com.tojc.ormlite.android.test";
//
// public static final String CONTENT_URI_PATH = "accounts";
//
// public static final String MIMETYPE_TYPE = "accounts";
// public static final String MIMETYPE_NAME = "com.tojc.ormlite.android.test.provider";
//
// public static final Uri CONTENT_URI = new Uri.Builder().scheme(ContentResolver.SCHEME_CONTENT).authority(AUTHORITY).appendPath(CONTENT_URI_PATH).build();
//
// public static final String NAME = "name";
// }
//
// Path: ormlite-content-provider-library-test/src/com/tojc/ormlite/android/test/provider/SampleHelper.java
// public class SampleHelper extends OrmLiteSqliteOpenHelper {
//
// /* package-private */static final Class<?>[] CLASS_LIST = new Class<?>[] {Account.class, Membership.class};
//
// public SampleHelper(Context context) {
// super(context, "MyDatabase", null, 1);
// }
//
// @Override
// public void onCreate(SQLiteDatabase database, ConnectionSource connectionSource) {
// try {
// resetAllTables();
// } catch (SQLException e) {
// e.printStackTrace();
// }
// }
//
// @Override
// public void onUpgrade(SQLiteDatabase database, ConnectionSource connectionSource, int oldVersion, int newVersion) {
// try {
// resetAllTables();
// } catch (SQLException e) {
// e.printStackTrace();
// }
// }
//
// public void resetAllTables() throws SQLException {
// for (Class<?> clazz : CLASS_LIST) {
// TableUtils.dropTable(connectionSource, clazz, true);
// TableUtils.createTable(connectionSource, clazz);
// }
// }
// }
//
// Path: ormlite-content-provider-library-test/src/com/tojc/ormlite/android/test/provider/UnderTestSampleProvider.java
// public class UnderTestSampleProvider extends OrmLiteSimpleContentProvider<SampleHelper> {
// @Override
// protected Class<SampleHelper> getHelperClass() {
// return SampleHelper.class;
// }
//
// @Override
// public boolean onCreate() {
// int patternCode = 1;
// setMatcherController(new MatcherController()//
// .add(Account.class, SubType.DIRECTORY, "", patternCode++)//
// .add(Account.class, SubType.ITEM, "#", patternCode++)//
// .add(Membership.class, SubType.DIRECTORY, "", patternCode++)//
// .add(Membership.class, SubType.ITEM, "#", patternCode++));
// return true;
// }
// }
| import android.provider.BaseColumns;
import android.test.InstrumentationTestCase;
import android.test.mock.MockContentResolver;
import android.test.suitebuilder.annotation.MediumTest;
import com.j256.ormlite.dao.RuntimeExceptionDao;
import com.tojc.ormlite.android.test.model.Account;
import com.tojc.ormlite.android.test.provider.AccountContract;
import com.tojc.ormlite.android.test.provider.SampleHelper;
import com.tojc.ormlite.android.test.provider.UnderTestSampleProvider;
import java.util.ArrayList;
import java.util.List;
import android.content.ContentProviderClient;
import android.content.ContentProviderOperation;
import android.content.ContentValues;
import android.content.OperationApplicationException;
import android.database.Cursor;
import android.os.RemoteException; | /*
* This file is part of the Android-OrmLiteContentProvider package.
*
* Copyright (c) 2012, Android-OrmLiteContentProvider Team.
* Jaken Jarvis (jaken.jarvis@gmail.com)
*
* 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.
*
* The author may be contacted via
* https://github.com/jakenjarvis/Android-OrmLiteContentProvider
*/
package com.tojc.ormlite.android;
@MediumTest
public class TestOrmLiteSimpleProvider extends InstrumentationTestCase {
private static final String TEST_NAME_1 = "Yamada Tarou";
private static final String TEST_NAME_2 = "Stephane Nicolas";
private MockContentResolver resolver;
@Override
protected void setUp() throws Exception {
super.setUp();
getHelper().resetAllTables();
| // Path: ormlite-content-provider-library-test/src/com/tojc/ormlite/android/test/provider/AccountContract.java
// public final class AccountContract implements BaseColumns {
//
// private AccountContract() {
// // utility constructor
// }
//
// public static final String AUTHORITY = "com.tojc.ormlite.android.test";
//
// public static final String CONTENT_URI_PATH = "accounts";
//
// public static final String MIMETYPE_TYPE = "accounts";
// public static final String MIMETYPE_NAME = "com.tojc.ormlite.android.test.provider";
//
// public static final Uri CONTENT_URI = new Uri.Builder().scheme(ContentResolver.SCHEME_CONTENT).authority(AUTHORITY).appendPath(CONTENT_URI_PATH).build();
//
// public static final String NAME = "name";
// }
//
// Path: ormlite-content-provider-library-test/src/com/tojc/ormlite/android/test/provider/SampleHelper.java
// public class SampleHelper extends OrmLiteSqliteOpenHelper {
//
// /* package-private */static final Class<?>[] CLASS_LIST = new Class<?>[] {Account.class, Membership.class};
//
// public SampleHelper(Context context) {
// super(context, "MyDatabase", null, 1);
// }
//
// @Override
// public void onCreate(SQLiteDatabase database, ConnectionSource connectionSource) {
// try {
// resetAllTables();
// } catch (SQLException e) {
// e.printStackTrace();
// }
// }
//
// @Override
// public void onUpgrade(SQLiteDatabase database, ConnectionSource connectionSource, int oldVersion, int newVersion) {
// try {
// resetAllTables();
// } catch (SQLException e) {
// e.printStackTrace();
// }
// }
//
// public void resetAllTables() throws SQLException {
// for (Class<?> clazz : CLASS_LIST) {
// TableUtils.dropTable(connectionSource, clazz, true);
// TableUtils.createTable(connectionSource, clazz);
// }
// }
// }
//
// Path: ormlite-content-provider-library-test/src/com/tojc/ormlite/android/test/provider/UnderTestSampleProvider.java
// public class UnderTestSampleProvider extends OrmLiteSimpleContentProvider<SampleHelper> {
// @Override
// protected Class<SampleHelper> getHelperClass() {
// return SampleHelper.class;
// }
//
// @Override
// public boolean onCreate() {
// int patternCode = 1;
// setMatcherController(new MatcherController()//
// .add(Account.class, SubType.DIRECTORY, "", patternCode++)//
// .add(Account.class, SubType.ITEM, "#", patternCode++)//
// .add(Membership.class, SubType.DIRECTORY, "", patternCode++)//
// .add(Membership.class, SubType.ITEM, "#", patternCode++));
// return true;
// }
// }
// Path: ormlite-content-provider-library-test/src/com/tojc/ormlite/android/TestOrmLiteSimpleProvider.java
import android.provider.BaseColumns;
import android.test.InstrumentationTestCase;
import android.test.mock.MockContentResolver;
import android.test.suitebuilder.annotation.MediumTest;
import com.j256.ormlite.dao.RuntimeExceptionDao;
import com.tojc.ormlite.android.test.model.Account;
import com.tojc.ormlite.android.test.provider.AccountContract;
import com.tojc.ormlite.android.test.provider.SampleHelper;
import com.tojc.ormlite.android.test.provider.UnderTestSampleProvider;
import java.util.ArrayList;
import java.util.List;
import android.content.ContentProviderClient;
import android.content.ContentProviderOperation;
import android.content.ContentValues;
import android.content.OperationApplicationException;
import android.database.Cursor;
import android.os.RemoteException;
/*
* This file is part of the Android-OrmLiteContentProvider package.
*
* Copyright (c) 2012, Android-OrmLiteContentProvider Team.
* Jaken Jarvis (jaken.jarvis@gmail.com)
*
* 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.
*
* The author may be contacted via
* https://github.com/jakenjarvis/Android-OrmLiteContentProvider
*/
package com.tojc.ormlite.android;
@MediumTest
public class TestOrmLiteSimpleProvider extends InstrumentationTestCase {
private static final String TEST_NAME_1 = "Yamada Tarou";
private static final String TEST_NAME_2 = "Stephane Nicolas";
private MockContentResolver resolver;
@Override
protected void setUp() throws Exception {
super.setUp();
getHelper().resetAllTables();
| UnderTestSampleProvider provider = new UnderTestSampleProvider(); |
jakenjarvis/Android-OrmLiteContentProvider | ormlite-content-provider-library-test/src/com/tojc/ormlite/android/TestOrmLiteSimpleProvider.java | // Path: ormlite-content-provider-library-test/src/com/tojc/ormlite/android/test/provider/AccountContract.java
// public final class AccountContract implements BaseColumns {
//
// private AccountContract() {
// // utility constructor
// }
//
// public static final String AUTHORITY = "com.tojc.ormlite.android.test";
//
// public static final String CONTENT_URI_PATH = "accounts";
//
// public static final String MIMETYPE_TYPE = "accounts";
// public static final String MIMETYPE_NAME = "com.tojc.ormlite.android.test.provider";
//
// public static final Uri CONTENT_URI = new Uri.Builder().scheme(ContentResolver.SCHEME_CONTENT).authority(AUTHORITY).appendPath(CONTENT_URI_PATH).build();
//
// public static final String NAME = "name";
// }
//
// Path: ormlite-content-provider-library-test/src/com/tojc/ormlite/android/test/provider/SampleHelper.java
// public class SampleHelper extends OrmLiteSqliteOpenHelper {
//
// /* package-private */static final Class<?>[] CLASS_LIST = new Class<?>[] {Account.class, Membership.class};
//
// public SampleHelper(Context context) {
// super(context, "MyDatabase", null, 1);
// }
//
// @Override
// public void onCreate(SQLiteDatabase database, ConnectionSource connectionSource) {
// try {
// resetAllTables();
// } catch (SQLException e) {
// e.printStackTrace();
// }
// }
//
// @Override
// public void onUpgrade(SQLiteDatabase database, ConnectionSource connectionSource, int oldVersion, int newVersion) {
// try {
// resetAllTables();
// } catch (SQLException e) {
// e.printStackTrace();
// }
// }
//
// public void resetAllTables() throws SQLException {
// for (Class<?> clazz : CLASS_LIST) {
// TableUtils.dropTable(connectionSource, clazz, true);
// TableUtils.createTable(connectionSource, clazz);
// }
// }
// }
//
// Path: ormlite-content-provider-library-test/src/com/tojc/ormlite/android/test/provider/UnderTestSampleProvider.java
// public class UnderTestSampleProvider extends OrmLiteSimpleContentProvider<SampleHelper> {
// @Override
// protected Class<SampleHelper> getHelperClass() {
// return SampleHelper.class;
// }
//
// @Override
// public boolean onCreate() {
// int patternCode = 1;
// setMatcherController(new MatcherController()//
// .add(Account.class, SubType.DIRECTORY, "", patternCode++)//
// .add(Account.class, SubType.ITEM, "#", patternCode++)//
// .add(Membership.class, SubType.DIRECTORY, "", patternCode++)//
// .add(Membership.class, SubType.ITEM, "#", patternCode++));
// return true;
// }
// }
| import android.provider.BaseColumns;
import android.test.InstrumentationTestCase;
import android.test.mock.MockContentResolver;
import android.test.suitebuilder.annotation.MediumTest;
import com.j256.ormlite.dao.RuntimeExceptionDao;
import com.tojc.ormlite.android.test.model.Account;
import com.tojc.ormlite.android.test.provider.AccountContract;
import com.tojc.ormlite.android.test.provider.SampleHelper;
import com.tojc.ormlite.android.test.provider.UnderTestSampleProvider;
import java.util.ArrayList;
import java.util.List;
import android.content.ContentProviderClient;
import android.content.ContentProviderOperation;
import android.content.ContentValues;
import android.content.OperationApplicationException;
import android.database.Cursor;
import android.os.RemoteException; | /*
* This file is part of the Android-OrmLiteContentProvider package.
*
* Copyright (c) 2012, Android-OrmLiteContentProvider Team.
* Jaken Jarvis (jaken.jarvis@gmail.com)
*
* 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.
*
* The author may be contacted via
* https://github.com/jakenjarvis/Android-OrmLiteContentProvider
*/
package com.tojc.ormlite.android;
@MediumTest
public class TestOrmLiteSimpleProvider extends InstrumentationTestCase {
private static final String TEST_NAME_1 = "Yamada Tarou";
private static final String TEST_NAME_2 = "Stephane Nicolas";
private MockContentResolver resolver;
@Override
protected void setUp() throws Exception {
super.setUp();
getHelper().resetAllTables();
UnderTestSampleProvider provider = new UnderTestSampleProvider();
provider.attachInfo(getInstrumentation().getContext(), null);
this.resolver = new MockContentResolver(); | // Path: ormlite-content-provider-library-test/src/com/tojc/ormlite/android/test/provider/AccountContract.java
// public final class AccountContract implements BaseColumns {
//
// private AccountContract() {
// // utility constructor
// }
//
// public static final String AUTHORITY = "com.tojc.ormlite.android.test";
//
// public static final String CONTENT_URI_PATH = "accounts";
//
// public static final String MIMETYPE_TYPE = "accounts";
// public static final String MIMETYPE_NAME = "com.tojc.ormlite.android.test.provider";
//
// public static final Uri CONTENT_URI = new Uri.Builder().scheme(ContentResolver.SCHEME_CONTENT).authority(AUTHORITY).appendPath(CONTENT_URI_PATH).build();
//
// public static final String NAME = "name";
// }
//
// Path: ormlite-content-provider-library-test/src/com/tojc/ormlite/android/test/provider/SampleHelper.java
// public class SampleHelper extends OrmLiteSqliteOpenHelper {
//
// /* package-private */static final Class<?>[] CLASS_LIST = new Class<?>[] {Account.class, Membership.class};
//
// public SampleHelper(Context context) {
// super(context, "MyDatabase", null, 1);
// }
//
// @Override
// public void onCreate(SQLiteDatabase database, ConnectionSource connectionSource) {
// try {
// resetAllTables();
// } catch (SQLException e) {
// e.printStackTrace();
// }
// }
//
// @Override
// public void onUpgrade(SQLiteDatabase database, ConnectionSource connectionSource, int oldVersion, int newVersion) {
// try {
// resetAllTables();
// } catch (SQLException e) {
// e.printStackTrace();
// }
// }
//
// public void resetAllTables() throws SQLException {
// for (Class<?> clazz : CLASS_LIST) {
// TableUtils.dropTable(connectionSource, clazz, true);
// TableUtils.createTable(connectionSource, clazz);
// }
// }
// }
//
// Path: ormlite-content-provider-library-test/src/com/tojc/ormlite/android/test/provider/UnderTestSampleProvider.java
// public class UnderTestSampleProvider extends OrmLiteSimpleContentProvider<SampleHelper> {
// @Override
// protected Class<SampleHelper> getHelperClass() {
// return SampleHelper.class;
// }
//
// @Override
// public boolean onCreate() {
// int patternCode = 1;
// setMatcherController(new MatcherController()//
// .add(Account.class, SubType.DIRECTORY, "", patternCode++)//
// .add(Account.class, SubType.ITEM, "#", patternCode++)//
// .add(Membership.class, SubType.DIRECTORY, "", patternCode++)//
// .add(Membership.class, SubType.ITEM, "#", patternCode++));
// return true;
// }
// }
// Path: ormlite-content-provider-library-test/src/com/tojc/ormlite/android/TestOrmLiteSimpleProvider.java
import android.provider.BaseColumns;
import android.test.InstrumentationTestCase;
import android.test.mock.MockContentResolver;
import android.test.suitebuilder.annotation.MediumTest;
import com.j256.ormlite.dao.RuntimeExceptionDao;
import com.tojc.ormlite.android.test.model.Account;
import com.tojc.ormlite.android.test.provider.AccountContract;
import com.tojc.ormlite.android.test.provider.SampleHelper;
import com.tojc.ormlite.android.test.provider.UnderTestSampleProvider;
import java.util.ArrayList;
import java.util.List;
import android.content.ContentProviderClient;
import android.content.ContentProviderOperation;
import android.content.ContentValues;
import android.content.OperationApplicationException;
import android.database.Cursor;
import android.os.RemoteException;
/*
* This file is part of the Android-OrmLiteContentProvider package.
*
* Copyright (c) 2012, Android-OrmLiteContentProvider Team.
* Jaken Jarvis (jaken.jarvis@gmail.com)
*
* 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.
*
* The author may be contacted via
* https://github.com/jakenjarvis/Android-OrmLiteContentProvider
*/
package com.tojc.ormlite.android;
@MediumTest
public class TestOrmLiteSimpleProvider extends InstrumentationTestCase {
private static final String TEST_NAME_1 = "Yamada Tarou";
private static final String TEST_NAME_2 = "Stephane Nicolas";
private MockContentResolver resolver;
@Override
protected void setUp() throws Exception {
super.setUp();
getHelper().resetAllTables();
UnderTestSampleProvider provider = new UnderTestSampleProvider();
provider.attachInfo(getInstrumentation().getContext(), null);
this.resolver = new MockContentResolver(); | this.resolver.addProvider(AccountContract.AUTHORITY, provider); |
jakenjarvis/Android-OrmLiteContentProvider | ormlite-content-provider-library-test/src/com/tojc/ormlite/android/TestOrmLiteSimpleProvider.java | // Path: ormlite-content-provider-library-test/src/com/tojc/ormlite/android/test/provider/AccountContract.java
// public final class AccountContract implements BaseColumns {
//
// private AccountContract() {
// // utility constructor
// }
//
// public static final String AUTHORITY = "com.tojc.ormlite.android.test";
//
// public static final String CONTENT_URI_PATH = "accounts";
//
// public static final String MIMETYPE_TYPE = "accounts";
// public static final String MIMETYPE_NAME = "com.tojc.ormlite.android.test.provider";
//
// public static final Uri CONTENT_URI = new Uri.Builder().scheme(ContentResolver.SCHEME_CONTENT).authority(AUTHORITY).appendPath(CONTENT_URI_PATH).build();
//
// public static final String NAME = "name";
// }
//
// Path: ormlite-content-provider-library-test/src/com/tojc/ormlite/android/test/provider/SampleHelper.java
// public class SampleHelper extends OrmLiteSqliteOpenHelper {
//
// /* package-private */static final Class<?>[] CLASS_LIST = new Class<?>[] {Account.class, Membership.class};
//
// public SampleHelper(Context context) {
// super(context, "MyDatabase", null, 1);
// }
//
// @Override
// public void onCreate(SQLiteDatabase database, ConnectionSource connectionSource) {
// try {
// resetAllTables();
// } catch (SQLException e) {
// e.printStackTrace();
// }
// }
//
// @Override
// public void onUpgrade(SQLiteDatabase database, ConnectionSource connectionSource, int oldVersion, int newVersion) {
// try {
// resetAllTables();
// } catch (SQLException e) {
// e.printStackTrace();
// }
// }
//
// public void resetAllTables() throws SQLException {
// for (Class<?> clazz : CLASS_LIST) {
// TableUtils.dropTable(connectionSource, clazz, true);
// TableUtils.createTable(connectionSource, clazz);
// }
// }
// }
//
// Path: ormlite-content-provider-library-test/src/com/tojc/ormlite/android/test/provider/UnderTestSampleProvider.java
// public class UnderTestSampleProvider extends OrmLiteSimpleContentProvider<SampleHelper> {
// @Override
// protected Class<SampleHelper> getHelperClass() {
// return SampleHelper.class;
// }
//
// @Override
// public boolean onCreate() {
// int patternCode = 1;
// setMatcherController(new MatcherController()//
// .add(Account.class, SubType.DIRECTORY, "", patternCode++)//
// .add(Account.class, SubType.ITEM, "#", patternCode++)//
// .add(Membership.class, SubType.DIRECTORY, "", patternCode++)//
// .add(Membership.class, SubType.ITEM, "#", patternCode++));
// return true;
// }
// }
| import android.provider.BaseColumns;
import android.test.InstrumentationTestCase;
import android.test.mock.MockContentResolver;
import android.test.suitebuilder.annotation.MediumTest;
import com.j256.ormlite.dao.RuntimeExceptionDao;
import com.tojc.ormlite.android.test.model.Account;
import com.tojc.ormlite.android.test.provider.AccountContract;
import com.tojc.ormlite.android.test.provider.SampleHelper;
import com.tojc.ormlite.android.test.provider.UnderTestSampleProvider;
import java.util.ArrayList;
import java.util.List;
import android.content.ContentProviderClient;
import android.content.ContentProviderOperation;
import android.content.ContentValues;
import android.content.OperationApplicationException;
import android.database.Cursor;
import android.os.RemoteException; | // when
this.resolver.bulkInsert(AccountContract.CONTENT_URI, contentValues);
// then
RuntimeExceptionDao<Account, Integer> simpleDao = getHelper().getRuntimeExceptionDao(Account.class);
List<Account> accountList = simpleDao.queryForAll();
assertEquals(testAccountCount, accountList.size());
int accountIndex = 0;
for (Account account : accountList) {
assertEquals(TEST_NAME_1 + accountIndex++, account.getName());
}
}
public void testApplyBatch() throws RemoteException, OperationApplicationException {
// given
ArrayList<ContentProviderOperation> operations = new ArrayList<ContentProviderOperation>();
operations.add(ContentProviderOperation.newInsert(AccountContract.CONTENT_URI).withValue(AccountContract.NAME, TEST_NAME_1).build());
operations.add(ContentProviderOperation.newInsert(AccountContract.CONTENT_URI).withValue(AccountContract.NAME, TEST_NAME_2).build());
// when
this.resolver.applyBatch(AccountContract.AUTHORITY, operations);
// then
RuntimeExceptionDao<Account, Integer> simpleDao = getHelper().getRuntimeExceptionDao(Account.class);
List<Account> accountList = simpleDao.queryForAll();
assertEquals(2, accountList.size());
assertEquals(TEST_NAME_1, accountList.get(0).getName());
assertEquals(TEST_NAME_2, accountList.get(1).getName());
}
| // Path: ormlite-content-provider-library-test/src/com/tojc/ormlite/android/test/provider/AccountContract.java
// public final class AccountContract implements BaseColumns {
//
// private AccountContract() {
// // utility constructor
// }
//
// public static final String AUTHORITY = "com.tojc.ormlite.android.test";
//
// public static final String CONTENT_URI_PATH = "accounts";
//
// public static final String MIMETYPE_TYPE = "accounts";
// public static final String MIMETYPE_NAME = "com.tojc.ormlite.android.test.provider";
//
// public static final Uri CONTENT_URI = new Uri.Builder().scheme(ContentResolver.SCHEME_CONTENT).authority(AUTHORITY).appendPath(CONTENT_URI_PATH).build();
//
// public static final String NAME = "name";
// }
//
// Path: ormlite-content-provider-library-test/src/com/tojc/ormlite/android/test/provider/SampleHelper.java
// public class SampleHelper extends OrmLiteSqliteOpenHelper {
//
// /* package-private */static final Class<?>[] CLASS_LIST = new Class<?>[] {Account.class, Membership.class};
//
// public SampleHelper(Context context) {
// super(context, "MyDatabase", null, 1);
// }
//
// @Override
// public void onCreate(SQLiteDatabase database, ConnectionSource connectionSource) {
// try {
// resetAllTables();
// } catch (SQLException e) {
// e.printStackTrace();
// }
// }
//
// @Override
// public void onUpgrade(SQLiteDatabase database, ConnectionSource connectionSource, int oldVersion, int newVersion) {
// try {
// resetAllTables();
// } catch (SQLException e) {
// e.printStackTrace();
// }
// }
//
// public void resetAllTables() throws SQLException {
// for (Class<?> clazz : CLASS_LIST) {
// TableUtils.dropTable(connectionSource, clazz, true);
// TableUtils.createTable(connectionSource, clazz);
// }
// }
// }
//
// Path: ormlite-content-provider-library-test/src/com/tojc/ormlite/android/test/provider/UnderTestSampleProvider.java
// public class UnderTestSampleProvider extends OrmLiteSimpleContentProvider<SampleHelper> {
// @Override
// protected Class<SampleHelper> getHelperClass() {
// return SampleHelper.class;
// }
//
// @Override
// public boolean onCreate() {
// int patternCode = 1;
// setMatcherController(new MatcherController()//
// .add(Account.class, SubType.DIRECTORY, "", patternCode++)//
// .add(Account.class, SubType.ITEM, "#", patternCode++)//
// .add(Membership.class, SubType.DIRECTORY, "", patternCode++)//
// .add(Membership.class, SubType.ITEM, "#", patternCode++));
// return true;
// }
// }
// Path: ormlite-content-provider-library-test/src/com/tojc/ormlite/android/TestOrmLiteSimpleProvider.java
import android.provider.BaseColumns;
import android.test.InstrumentationTestCase;
import android.test.mock.MockContentResolver;
import android.test.suitebuilder.annotation.MediumTest;
import com.j256.ormlite.dao.RuntimeExceptionDao;
import com.tojc.ormlite.android.test.model.Account;
import com.tojc.ormlite.android.test.provider.AccountContract;
import com.tojc.ormlite.android.test.provider.SampleHelper;
import com.tojc.ormlite.android.test.provider.UnderTestSampleProvider;
import java.util.ArrayList;
import java.util.List;
import android.content.ContentProviderClient;
import android.content.ContentProviderOperation;
import android.content.ContentValues;
import android.content.OperationApplicationException;
import android.database.Cursor;
import android.os.RemoteException;
// when
this.resolver.bulkInsert(AccountContract.CONTENT_URI, contentValues);
// then
RuntimeExceptionDao<Account, Integer> simpleDao = getHelper().getRuntimeExceptionDao(Account.class);
List<Account> accountList = simpleDao.queryForAll();
assertEquals(testAccountCount, accountList.size());
int accountIndex = 0;
for (Account account : accountList) {
assertEquals(TEST_NAME_1 + accountIndex++, account.getName());
}
}
public void testApplyBatch() throws RemoteException, OperationApplicationException {
// given
ArrayList<ContentProviderOperation> operations = new ArrayList<ContentProviderOperation>();
operations.add(ContentProviderOperation.newInsert(AccountContract.CONTENT_URI).withValue(AccountContract.NAME, TEST_NAME_1).build());
operations.add(ContentProviderOperation.newInsert(AccountContract.CONTENT_URI).withValue(AccountContract.NAME, TEST_NAME_2).build());
// when
this.resolver.applyBatch(AccountContract.AUTHORITY, operations);
// then
RuntimeExceptionDao<Account, Integer> simpleDao = getHelper().getRuntimeExceptionDao(Account.class);
List<Account> accountList = simpleDao.queryForAll();
assertEquals(2, accountList.size());
assertEquals(TEST_NAME_1, accountList.get(0).getName());
assertEquals(TEST_NAME_2, accountList.get(1).getName());
}
| private SampleHelper getHelper() { |
jakenjarvis/Android-OrmLiteContentProvider | ormlite-content-provider-library/src/com/tojc/ormlite/android/framework/MatcherController.java | // Path: ormlite-content-provider-library/src/com/tojc/ormlite/android/annotation/info/ContentUriInfo.java
// public class ContentUriInfo extends AnnotationInfoBase {
// // ----------------------------------
// // ATTRIBUTES
// // ----------------------------------
// private String authority;
// private String path;
//
// // ----------------------------------
// // CONSTRUCTORS
// // ----------------------------------
// public ContentUriInfo(AnnotatedElement element) {
// DefaultContentUri contentUri = element.getAnnotation(DefaultContentUri.class);
// String authority = null;
// String path = null;
// if (contentUri != null) {
// authority = contentUri.authority();
// path = contentUri.path();
// }
//
// if (element instanceof Class<?>) {
// Class<?> clazz = (Class<?>) element;
// if (TextUtils.isEmpty(authority)) {
// authority = clazz.getPackage().getName();
// }
// if (TextUtils.isEmpty(path)) {
// // TODO use DataBase annotation
// path = clazz.getSimpleName().toLowerCase();
// }
// }
//
// initialize(authority, path);
// }
//
// public ContentUriInfo(String authority, String path) {
// initialize(authority, path);
// }
//
// // ----------------------------------
// // PUBLIC METHODS
// // ----------------------------------
// public String getAuthority() {
// return this.authority;
// }
//
// public String getPath() {
// return this.path;
// }
//
// public Uri getContentUri() {
// return new Uri.Builder().scheme(ContentResolver.SCHEME_CONTENT).authority(this.authority).appendPath(this.path).build();
// }
//
// @Override
// protected boolean isValidValue() {
// return !TextUtils.isEmpty(this.authority) && !TextUtils.isEmpty(this.path);
// }
//
// // ----------------------------------
// // PRIVATE METHODS
// // ----------------------------------
// private void initialize(String authority, String path) {
// this.authority = authority;
// this.path = path;
// validFlagOn();
// }
//
// @Override
// public String toString() {
// return "ContentUriInfo{"
// + "authority='" + authority + '\''
// + ", path='" + path + '\''
// + "} " + super.toString();
// }
// }
| import com.tojc.ormlite.android.framework.MimeTypeVnd.SubType;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import android.content.UriMatcher;
import com.tojc.ormlite.android.annotation.info.ContentMimeTypeVndInfo;
import com.tojc.ormlite.android.annotation.info.ContentUriInfo; | * register MatcherPattern.
* @return Instance of the MatcherController class.
*/
public MatcherController add(MatcherPattern matcherPattern) {
int patternCode = matcherPattern.getPatternCode();
if (this.lastAddTableInfo == null) {
throw new IllegalStateException("There is a problem with the order of function call.");
}
if (findMatcherPattern(patternCode) != null) {
throw new IllegalArgumentException("patternCode has been specified already exists.");
}
this.matcherPatterns.add(matcherPattern);
return this;
}
/**
* Set the DefaultContentUri. If you did not use the DefaultContentUri annotation, you must call
* this method.
* @see com.tojc.ormlite.android.annotation.AdditionalAnnotation.DefaultContentUri
* @param authority
* @param path
* @return Instance of the MatcherController class.
*/
public MatcherController setDefaultContentUri(String authority, String path) {
if (this.lastAddTableInfo == null) {
throw new IllegalStateException("There is a problem with the order of function call.");
} | // Path: ormlite-content-provider-library/src/com/tojc/ormlite/android/annotation/info/ContentUriInfo.java
// public class ContentUriInfo extends AnnotationInfoBase {
// // ----------------------------------
// // ATTRIBUTES
// // ----------------------------------
// private String authority;
// private String path;
//
// // ----------------------------------
// // CONSTRUCTORS
// // ----------------------------------
// public ContentUriInfo(AnnotatedElement element) {
// DefaultContentUri contentUri = element.getAnnotation(DefaultContentUri.class);
// String authority = null;
// String path = null;
// if (contentUri != null) {
// authority = contentUri.authority();
// path = contentUri.path();
// }
//
// if (element instanceof Class<?>) {
// Class<?> clazz = (Class<?>) element;
// if (TextUtils.isEmpty(authority)) {
// authority = clazz.getPackage().getName();
// }
// if (TextUtils.isEmpty(path)) {
// // TODO use DataBase annotation
// path = clazz.getSimpleName().toLowerCase();
// }
// }
//
// initialize(authority, path);
// }
//
// public ContentUriInfo(String authority, String path) {
// initialize(authority, path);
// }
//
// // ----------------------------------
// // PUBLIC METHODS
// // ----------------------------------
// public String getAuthority() {
// return this.authority;
// }
//
// public String getPath() {
// return this.path;
// }
//
// public Uri getContentUri() {
// return new Uri.Builder().scheme(ContentResolver.SCHEME_CONTENT).authority(this.authority).appendPath(this.path).build();
// }
//
// @Override
// protected boolean isValidValue() {
// return !TextUtils.isEmpty(this.authority) && !TextUtils.isEmpty(this.path);
// }
//
// // ----------------------------------
// // PRIVATE METHODS
// // ----------------------------------
// private void initialize(String authority, String path) {
// this.authority = authority;
// this.path = path;
// validFlagOn();
// }
//
// @Override
// public String toString() {
// return "ContentUriInfo{"
// + "authority='" + authority + '\''
// + ", path='" + path + '\''
// + "} " + super.toString();
// }
// }
// Path: ormlite-content-provider-library/src/com/tojc/ormlite/android/framework/MatcherController.java
import com.tojc.ormlite.android.framework.MimeTypeVnd.SubType;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import android.content.UriMatcher;
import com.tojc.ormlite.android.annotation.info.ContentMimeTypeVndInfo;
import com.tojc.ormlite.android.annotation.info.ContentUriInfo;
* register MatcherPattern.
* @return Instance of the MatcherController class.
*/
public MatcherController add(MatcherPattern matcherPattern) {
int patternCode = matcherPattern.getPatternCode();
if (this.lastAddTableInfo == null) {
throw new IllegalStateException("There is a problem with the order of function call.");
}
if (findMatcherPattern(patternCode) != null) {
throw new IllegalArgumentException("patternCode has been specified already exists.");
}
this.matcherPatterns.add(matcherPattern);
return this;
}
/**
* Set the DefaultContentUri. If you did not use the DefaultContentUri annotation, you must call
* this method.
* @see com.tojc.ormlite.android.annotation.AdditionalAnnotation.DefaultContentUri
* @param authority
* @param path
* @return Instance of the MatcherController class.
*/
public MatcherController setDefaultContentUri(String authority, String path) {
if (this.lastAddTableInfo == null) {
throw new IllegalStateException("There is a problem with the order of function call.");
} | this.lastAddTableInfo.setDefaultContentUriInfo(new ContentUriInfo(authority, path)); |
angelozerr/eclipse-wtp-webresources | org.eclipse.a.wst.html.webresources.core/src/org/eclipse/wst/html/webresources/internal/core/HTMLWebResourcesFinderTypeProvider.java | // Path: org.eclipse.a.wst.html.webresources.core/src/org/eclipse/wst/html/webresources/core/WebResourcesFinderType.java
// public enum WebResourcesFinderType {
//
// CSS_ID(WebResourceType.css), CSS_CLASS_NAME(WebResourceType.css), SCRIPT_SRC(
// WebResourceType.js), LINK_HREF(WebResourceType.css), IMG_SRC(
// WebResourceType.img);
//
// private final WebResourceType type;
//
// private WebResourcesFinderType(WebResourceType type) {
// this.type = type;
// }
//
// public WebResourceType getType() {
// return type;
// }
//
// public static WebResourcesFinderType get(String value) {
// WebResourcesFinderType[] types = WebResourcesFinderType.values();
// WebResourcesFinderType type;
// for (int i = 0; i < types.length; i++) {
// type = types[i];
// if (type.name().equalsIgnoreCase(value)) {
// return type;
// }
// }
// return null;
// }
//
// }
| import org.eclipse.wst.html.core.internal.provisional.HTML40Namespace;
import org.eclipse.wst.html.webresources.core.IWebResourcesFinderTypeProvider;
import org.eclipse.wst.html.webresources.core.WebResourcesFinderType;
import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion;
| /**
* Copyright (c) 2013-2014 Angelo ZERR.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Angelo Zerr <angelo.zerr@gmail.com> - initial API and implementation
*/
package org.eclipse.wst.html.webresources.internal.core;
/**
* Standard HTML web resources finder type.
*
*/
public class HTMLWebResourcesFinderTypeProvider implements
IWebResourcesFinderTypeProvider {
@Override
| // Path: org.eclipse.a.wst.html.webresources.core/src/org/eclipse/wst/html/webresources/core/WebResourcesFinderType.java
// public enum WebResourcesFinderType {
//
// CSS_ID(WebResourceType.css), CSS_CLASS_NAME(WebResourceType.css), SCRIPT_SRC(
// WebResourceType.js), LINK_HREF(WebResourceType.css), IMG_SRC(
// WebResourceType.img);
//
// private final WebResourceType type;
//
// private WebResourcesFinderType(WebResourceType type) {
// this.type = type;
// }
//
// public WebResourceType getType() {
// return type;
// }
//
// public static WebResourcesFinderType get(String value) {
// WebResourcesFinderType[] types = WebResourcesFinderType.values();
// WebResourcesFinderType type;
// for (int i = 0; i < types.length; i++) {
// type = types[i];
// if (type.name().equalsIgnoreCase(value)) {
// return type;
// }
// }
// return null;
// }
//
// }
// Path: org.eclipse.a.wst.html.webresources.core/src/org/eclipse/wst/html/webresources/internal/core/HTMLWebResourcesFinderTypeProvider.java
import org.eclipse.wst.html.core.internal.provisional.HTML40Namespace;
import org.eclipse.wst.html.webresources.core.IWebResourcesFinderTypeProvider;
import org.eclipse.wst.html.webresources.core.WebResourcesFinderType;
import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion;
/**
* Copyright (c) 2013-2014 Angelo ZERR.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Angelo Zerr <angelo.zerr@gmail.com> - initial API and implementation
*/
package org.eclipse.wst.html.webresources.internal.core;
/**
* Standard HTML web resources finder type.
*
*/
public class HTMLWebResourcesFinderTypeProvider implements
IWebResourcesFinderTypeProvider {
@Override
| public WebResourcesFinderType getWebResourcesFinderType(String elementName,
|
angelozerr/eclipse-wtp-webresources | org.eclipse.a.wst.html.webresources.ui/src/org/eclipse/wst/html/webresources/internal/ui/utils/ResourceUIHelper.java | // Path: org.eclipse.a.wst.html.webresources.ui/src/org/eclipse/wst/html/webresources/internal/ui/Trace.java
// public class Trace {
// public static final byte CONFIG = 0;
// public static final byte INFO = 1;
// public static final byte WARNING = 2;
// public static final byte SEVERE = 3;
// public static final byte FINEST = 4;
// public static final byte FINER = 5;
// public static final byte PERFORMANCE = 6;
// public static final byte EXTENSION_POINT = 7;
//
// private static final String[] levelNames = new String[] { "CONFIG ",
// "INFO ", "WARNING", "SEVERE ", "FINER ", "FINEST ", "PERF ",
// "EXTENSION" };
//
// private static final SimpleDateFormat sdf = new SimpleDateFormat(
// "dd/MM/yy HH:mm.ss.SSS");
//
// /**
// * Trace constructor comment.
// */
// private Trace() {
// super();
// }
//
// /**
// * Trace the given text.
// *
// * @param level
// * a trace level
// * @param s
// * a message
// */
// public static void trace(byte level, String s) {
// trace(level, s, null);
// }
//
// /**
// * Trace the given message and exception.
// *
// * @param level
// * a trace level
// * @param s
// * a message
// * @param t
// * a throwable
// */
// public static void trace(byte level, String s, Throwable t) {
// if (s == null)
// return;
//
// if (level == SEVERE) {
// WebResourcesUIPlugin
// .getDefault()
// .getLog()
// .log(new Status(IStatus.ERROR, WebResourcesUIPlugin.PLUGIN_ID,
// s, t));
// }
//
// if (!WebResourcesUIPlugin.getDefault().isDebugging())
// return;
//
// StringBuilder sb = new StringBuilder(WebResourcesUIPlugin.PLUGIN_ID);
// sb.append(" ");
// sb.append(levelNames[level]);
// sb.append(" ");
// sb.append(sdf.format(new Date()));
// sb.append(" ");
// sb.append(s);
// System.out.println(sb.toString());
// if (t != null)
// t.printStackTrace();
// }
// }
| import org.eclipse.core.resources.IResource;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.graphics.ImageData;
import org.eclipse.ui.model.IWorkbenchAdapter;
import org.eclipse.ui.model.WorkbenchLabelProvider;
import org.eclipse.wst.html.webresources.internal.ui.Trace;
| /**
* Copyright (c) 2013-2014 Angelo ZERR.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Angelo Zerr <angelo.zerr@gmail.com> - initial API and implementation
*/
package org.eclipse.wst.html.webresources.internal.ui.utils;
/**
* Helper for {@link IResource}.
*/
public class ResourceUIHelper {
private static final ResourceLabelProvider LABEL_PROVIDER = new ResourceLabelProvider();
static class ResourceLabelProvider extends WorkbenchLabelProvider {
public ImageDescriptor getImageDescriptor(IResource resource) {
IWorkbenchAdapter adapter = super.getAdapter(resource);
if (adapter == null) {
return null;
}
return adapter.getImageDescriptor(resource);
}
};
private ResourceUIHelper() {}
/**
* Returns the image file type of the given file.
*
* @param resource
* @return
*/
public static Image getFileTypeImage(IResource resource) {
return LABEL_PROVIDER.getImage(resource);
}
/**
* Returns the image descriptor file type of the given file.
*
* @param resource
* @return
*/
public static ImageDescriptor getFileTypeImageDescriptor(IResource resource) {
return LABEL_PROVIDER.getImageDescriptor(resource);
}
/**
* Returns the image height of the given image resource and null if the
* height cannot be retrieved.
*
* @param resource
* @return the image height of the given image resource and null if the
* height cannot be retrieved.
*/
public static Integer getImageHeight(IResource resource) {
String filename = null;
try {
filename = resource.getLocation().toOSString();
ImageData data = new ImageData(filename);
return data.height;
} catch (Throwable e) {
| // Path: org.eclipse.a.wst.html.webresources.ui/src/org/eclipse/wst/html/webresources/internal/ui/Trace.java
// public class Trace {
// public static final byte CONFIG = 0;
// public static final byte INFO = 1;
// public static final byte WARNING = 2;
// public static final byte SEVERE = 3;
// public static final byte FINEST = 4;
// public static final byte FINER = 5;
// public static final byte PERFORMANCE = 6;
// public static final byte EXTENSION_POINT = 7;
//
// private static final String[] levelNames = new String[] { "CONFIG ",
// "INFO ", "WARNING", "SEVERE ", "FINER ", "FINEST ", "PERF ",
// "EXTENSION" };
//
// private static final SimpleDateFormat sdf = new SimpleDateFormat(
// "dd/MM/yy HH:mm.ss.SSS");
//
// /**
// * Trace constructor comment.
// */
// private Trace() {
// super();
// }
//
// /**
// * Trace the given text.
// *
// * @param level
// * a trace level
// * @param s
// * a message
// */
// public static void trace(byte level, String s) {
// trace(level, s, null);
// }
//
// /**
// * Trace the given message and exception.
// *
// * @param level
// * a trace level
// * @param s
// * a message
// * @param t
// * a throwable
// */
// public static void trace(byte level, String s, Throwable t) {
// if (s == null)
// return;
//
// if (level == SEVERE) {
// WebResourcesUIPlugin
// .getDefault()
// .getLog()
// .log(new Status(IStatus.ERROR, WebResourcesUIPlugin.PLUGIN_ID,
// s, t));
// }
//
// if (!WebResourcesUIPlugin.getDefault().isDebugging())
// return;
//
// StringBuilder sb = new StringBuilder(WebResourcesUIPlugin.PLUGIN_ID);
// sb.append(" ");
// sb.append(levelNames[level]);
// sb.append(" ");
// sb.append(sdf.format(new Date()));
// sb.append(" ");
// sb.append(s);
// System.out.println(sb.toString());
// if (t != null)
// t.printStackTrace();
// }
// }
// Path: org.eclipse.a.wst.html.webresources.ui/src/org/eclipse/wst/html/webresources/internal/ui/utils/ResourceUIHelper.java
import org.eclipse.core.resources.IResource;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.graphics.ImageData;
import org.eclipse.ui.model.IWorkbenchAdapter;
import org.eclipse.ui.model.WorkbenchLabelProvider;
import org.eclipse.wst.html.webresources.internal.ui.Trace;
/**
* Copyright (c) 2013-2014 Angelo ZERR.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Angelo Zerr <angelo.zerr@gmail.com> - initial API and implementation
*/
package org.eclipse.wst.html.webresources.internal.ui.utils;
/**
* Helper for {@link IResource}.
*/
public class ResourceUIHelper {
private static final ResourceLabelProvider LABEL_PROVIDER = new ResourceLabelProvider();
static class ResourceLabelProvider extends WorkbenchLabelProvider {
public ImageDescriptor getImageDescriptor(IResource resource) {
IWorkbenchAdapter adapter = super.getAdapter(resource);
if (adapter == null) {
return null;
}
return adapter.getImageDescriptor(resource);
}
};
private ResourceUIHelper() {}
/**
* Returns the image file type of the given file.
*
* @param resource
* @return
*/
public static Image getFileTypeImage(IResource resource) {
return LABEL_PROVIDER.getImage(resource);
}
/**
* Returns the image descriptor file type of the given file.
*
* @param resource
* @return
*/
public static ImageDescriptor getFileTypeImageDescriptor(IResource resource) {
return LABEL_PROVIDER.getImageDescriptor(resource);
}
/**
* Returns the image height of the given image resource and null if the
* height cannot be retrieved.
*
* @param resource
* @return the image height of the given image resource and null if the
* height cannot be retrieved.
*/
public static Integer getImageHeight(IResource resource) {
String filename = null;
try {
filename = resource.getLocation().toOSString();
ImageData data = new ImageData(filename);
return data.height;
} catch (Throwable e) {
| Trace.trace(Trace.INFO, "Error while getting image height of "
|
angelozerr/eclipse-wtp-webresources | org.eclipse.a.wst.html.webresources.ui/src/org/eclipse/wst/html/webresources/internal/ui/text/correction/CreateFileCompletionProposal.java | // Path: org.eclipse.a.wst.html.webresources.core/src/org/eclipse/wst/html/webresources/core/WebResourceType.java
// public enum WebResourceType {
//
// css, js, img;
//
// public static WebResourceType get(String value) {
// WebResourceType[] types = WebResourceType.values();
// WebResourceType type;
// for (int i = 0; i < types.length; i++) {
// type = types[i];
// if (type.name().equalsIgnoreCase(value)) {
// return type;
// }
// }
// return null;
// }
//
// }
//
// Path: org.eclipse.a.wst.html.webresources.ui/src/org/eclipse/wst/html/webresources/internal/ui/WebResourcesUIPlugin.java
// public class WebResourcesUIPlugin extends AbstractUIPlugin {
//
// // The plug-in ID
// public static final String PLUGIN_ID = "org.eclipse.a.wst.html.webresources.ui"; //$NON-NLS-1$
//
// // The shared instance
// private static WebResourcesUIPlugin plugin;
//
// /**
// * The constructor
// */
// public WebResourcesUIPlugin() {
// }
//
// /*
// * (non-Javadoc)
// *
// * @see
// * org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext
// * )
// */
// public void start(BundleContext context) throws Exception {
// super.start(context);
// setPlugin(this);
// }
//
// /*
// * (non-Javadoc)
// *
// * @see
// * org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext
// * )
// */
// public void stop(BundleContext context) throws Exception {
// ImageResource.dispose();
// setPlugin(null);
// super.stop(context);
// }
//
// /**
// * Returns the shared instance
// *
// * @return the shared instance
// */
// public static WebResourcesUIPlugin getDefault() {
// return plugin;
// }
//
// /**
// * Logs the given <code>Throwable</code>.
// *
// * @param t the <code>Throwable</code>
// */
// public static void log(Throwable t) {
// plugin.getLog().log(new Status(IStatus.ERROR, PLUGIN_ID, t.getMessage(), t));
// }
//
// public static IWorkbenchWindow getActiveWorkbenchWindow() {
// return getDefault().getWorkbench().getActiveWorkbenchWindow();
// }
//
// public static Shell getActiveWorkbenchShell() {
// IWorkbenchWindow window = getActiveWorkbenchWindow();
// if (window != null) {
// return window.getShell();
// }
// return null;
// }
//
// /**
// * @return Returns the active workbench window's currrent page.
// */
// public static IWorkbenchPage getActivePage() {
// return getActiveWorkbenchWindow().getActivePage();
// }
//
// public static void setPlugin(WebResourcesUIPlugin plugin) {
// WebResourcesUIPlugin.plugin = plugin;
// }
//
// }
| import java.io.ByteArrayInputStream;
import org.eclipse.core.resources.IContainer;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IFolder;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.Status;
import org.eclipse.jface.dialogs.ErrorDialog;
import org.eclipse.jface.text.IDocument;
import org.eclipse.jface.text.contentassist.ICompletionProposal;
import org.eclipse.jface.text.contentassist.IContextInformation;
import org.eclipse.osgi.util.NLS;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.wst.html.ui.internal.HTMLUIPlugin;
import org.eclipse.wst.html.webresources.core.WebResourceType;
import org.eclipse.wst.html.webresources.internal.ui.ImageResource;
import org.eclipse.wst.html.webresources.internal.ui.WebResourcesUIMessages;
import org.eclipse.wst.html.webresources.internal.ui.WebResourcesUIPlugin;
import org.eclipse.wst.xml.core.internal.provisional.document.IDOMAttr;
| .openError(
getShell(),
WebResourcesUIMessages.CreateFileCompletionProposal_errorTitle,
NLS.bind(
WebResourcesUIMessages.CreateFileCompletionProposal_errorMessage,
path), status);
}
}
}
@Override
public String getAdditionalProposalInfo() {
// TODO Auto-generated method stub
return null;
}
@Override
public IContextInformation getContextInformation() {
return null;
}
@Override
public String getDisplayString() {
return NLS
.bind(WebResourcesUIMessages.CreateFileCompletionProposal_displayString,
attr.getValue());
}
@Override
public Image getImage() {
| // Path: org.eclipse.a.wst.html.webresources.core/src/org/eclipse/wst/html/webresources/core/WebResourceType.java
// public enum WebResourceType {
//
// css, js, img;
//
// public static WebResourceType get(String value) {
// WebResourceType[] types = WebResourceType.values();
// WebResourceType type;
// for (int i = 0; i < types.length; i++) {
// type = types[i];
// if (type.name().equalsIgnoreCase(value)) {
// return type;
// }
// }
// return null;
// }
//
// }
//
// Path: org.eclipse.a.wst.html.webresources.ui/src/org/eclipse/wst/html/webresources/internal/ui/WebResourcesUIPlugin.java
// public class WebResourcesUIPlugin extends AbstractUIPlugin {
//
// // The plug-in ID
// public static final String PLUGIN_ID = "org.eclipse.a.wst.html.webresources.ui"; //$NON-NLS-1$
//
// // The shared instance
// private static WebResourcesUIPlugin plugin;
//
// /**
// * The constructor
// */
// public WebResourcesUIPlugin() {
// }
//
// /*
// * (non-Javadoc)
// *
// * @see
// * org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext
// * )
// */
// public void start(BundleContext context) throws Exception {
// super.start(context);
// setPlugin(this);
// }
//
// /*
// * (non-Javadoc)
// *
// * @see
// * org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext
// * )
// */
// public void stop(BundleContext context) throws Exception {
// ImageResource.dispose();
// setPlugin(null);
// super.stop(context);
// }
//
// /**
// * Returns the shared instance
// *
// * @return the shared instance
// */
// public static WebResourcesUIPlugin getDefault() {
// return plugin;
// }
//
// /**
// * Logs the given <code>Throwable</code>.
// *
// * @param t the <code>Throwable</code>
// */
// public static void log(Throwable t) {
// plugin.getLog().log(new Status(IStatus.ERROR, PLUGIN_ID, t.getMessage(), t));
// }
//
// public static IWorkbenchWindow getActiveWorkbenchWindow() {
// return getDefault().getWorkbench().getActiveWorkbenchWindow();
// }
//
// public static Shell getActiveWorkbenchShell() {
// IWorkbenchWindow window = getActiveWorkbenchWindow();
// if (window != null) {
// return window.getShell();
// }
// return null;
// }
//
// /**
// * @return Returns the active workbench window's currrent page.
// */
// public static IWorkbenchPage getActivePage() {
// return getActiveWorkbenchWindow().getActivePage();
// }
//
// public static void setPlugin(WebResourcesUIPlugin plugin) {
// WebResourcesUIPlugin.plugin = plugin;
// }
//
// }
// Path: org.eclipse.a.wst.html.webresources.ui/src/org/eclipse/wst/html/webresources/internal/ui/text/correction/CreateFileCompletionProposal.java
import java.io.ByteArrayInputStream;
import org.eclipse.core.resources.IContainer;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IFolder;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.Status;
import org.eclipse.jface.dialogs.ErrorDialog;
import org.eclipse.jface.text.IDocument;
import org.eclipse.jface.text.contentassist.ICompletionProposal;
import org.eclipse.jface.text.contentassist.IContextInformation;
import org.eclipse.osgi.util.NLS;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.wst.html.ui.internal.HTMLUIPlugin;
import org.eclipse.wst.html.webresources.core.WebResourceType;
import org.eclipse.wst.html.webresources.internal.ui.ImageResource;
import org.eclipse.wst.html.webresources.internal.ui.WebResourcesUIMessages;
import org.eclipse.wst.html.webresources.internal.ui.WebResourcesUIPlugin;
import org.eclipse.wst.xml.core.internal.provisional.document.IDOMAttr;
.openError(
getShell(),
WebResourcesUIMessages.CreateFileCompletionProposal_errorTitle,
NLS.bind(
WebResourcesUIMessages.CreateFileCompletionProposal_errorMessage,
path), status);
}
}
}
@Override
public String getAdditionalProposalInfo() {
// TODO Auto-generated method stub
return null;
}
@Override
public IContextInformation getContextInformation() {
return null;
}
@Override
public String getDisplayString() {
return NLS
.bind(WebResourcesUIMessages.CreateFileCompletionProposal_displayString,
attr.getValue());
}
@Override
public Image getImage() {
| if (attr.getValue().endsWith(WebResourceType.css.name())) {
|
angelozerr/eclipse-wtp-webresources | org.eclipse.a.wst.html.webresources.ui/src/org/eclipse/wst/html/webresources/internal/ui/utils/EditorUtils.java | // Path: org.eclipse.a.wst.html.webresources.ui/src/org/eclipse/wst/html/webresources/internal/ui/WebResourcesUIPlugin.java
// public class WebResourcesUIPlugin extends AbstractUIPlugin {
//
// // The plug-in ID
// public static final String PLUGIN_ID = "org.eclipse.a.wst.html.webresources.ui"; //$NON-NLS-1$
//
// // The shared instance
// private static WebResourcesUIPlugin plugin;
//
// /**
// * The constructor
// */
// public WebResourcesUIPlugin() {
// }
//
// /*
// * (non-Javadoc)
// *
// * @see
// * org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext
// * )
// */
// public void start(BundleContext context) throws Exception {
// super.start(context);
// setPlugin(this);
// }
//
// /*
// * (non-Javadoc)
// *
// * @see
// * org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext
// * )
// */
// public void stop(BundleContext context) throws Exception {
// ImageResource.dispose();
// setPlugin(null);
// super.stop(context);
// }
//
// /**
// * Returns the shared instance
// *
// * @return the shared instance
// */
// public static WebResourcesUIPlugin getDefault() {
// return plugin;
// }
//
// /**
// * Logs the given <code>Throwable</code>.
// *
// * @param t the <code>Throwable</code>
// */
// public static void log(Throwable t) {
// plugin.getLog().log(new Status(IStatus.ERROR, PLUGIN_ID, t.getMessage(), t));
// }
//
// public static IWorkbenchWindow getActiveWorkbenchWindow() {
// return getDefault().getWorkbench().getActiveWorkbenchWindow();
// }
//
// public static Shell getActiveWorkbenchShell() {
// IWorkbenchWindow window = getActiveWorkbenchWindow();
// if (window != null) {
// return window.getShell();
// }
// return null;
// }
//
// /**
// * @return Returns the active workbench window's currrent page.
// */
// public static IWorkbenchPage getActivePage() {
// return getActiveWorkbenchWindow().getActivePage();
// }
//
// public static void setPlugin(WebResourcesUIPlugin plugin) {
// WebResourcesUIPlugin.plugin = plugin;
// }
//
// }
| import java.io.File;
import org.eclipse.core.filebuffers.FileBuffers;
import org.eclipse.core.filebuffers.ITextFileBufferManager;
import org.eclipse.core.filesystem.EFS;
import org.eclipse.core.filesystem.IFileStore;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IMarker;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.core.runtime.IPath;
import org.eclipse.jface.text.IDocument;
import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.ide.IDE;
import org.eclipse.ui.texteditor.ITextEditor;
import org.eclipse.wst.html.webresources.internal.ui.WebResourcesUIPlugin;
| /**
* Copyright (c) 2013-2014 Angelo ZERR.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Angelo Zerr <angelo.zerr@gmail.com> - initial API and implementation
*/
package org.eclipse.wst.html.webresources.internal.ui.utils;
/**
* Editor utilities.
*
*/
public class EditorUtils {
private EditorUtils() {}
public static IEditorPart openInEditor(IFile file, int start, int length,
boolean activate) {
IEditorPart editor = null;
| // Path: org.eclipse.a.wst.html.webresources.ui/src/org/eclipse/wst/html/webresources/internal/ui/WebResourcesUIPlugin.java
// public class WebResourcesUIPlugin extends AbstractUIPlugin {
//
// // The plug-in ID
// public static final String PLUGIN_ID = "org.eclipse.a.wst.html.webresources.ui"; //$NON-NLS-1$
//
// // The shared instance
// private static WebResourcesUIPlugin plugin;
//
// /**
// * The constructor
// */
// public WebResourcesUIPlugin() {
// }
//
// /*
// * (non-Javadoc)
// *
// * @see
// * org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext
// * )
// */
// public void start(BundleContext context) throws Exception {
// super.start(context);
// setPlugin(this);
// }
//
// /*
// * (non-Javadoc)
// *
// * @see
// * org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext
// * )
// */
// public void stop(BundleContext context) throws Exception {
// ImageResource.dispose();
// setPlugin(null);
// super.stop(context);
// }
//
// /**
// * Returns the shared instance
// *
// * @return the shared instance
// */
// public static WebResourcesUIPlugin getDefault() {
// return plugin;
// }
//
// /**
// * Logs the given <code>Throwable</code>.
// *
// * @param t the <code>Throwable</code>
// */
// public static void log(Throwable t) {
// plugin.getLog().log(new Status(IStatus.ERROR, PLUGIN_ID, t.getMessage(), t));
// }
//
// public static IWorkbenchWindow getActiveWorkbenchWindow() {
// return getDefault().getWorkbench().getActiveWorkbenchWindow();
// }
//
// public static Shell getActiveWorkbenchShell() {
// IWorkbenchWindow window = getActiveWorkbenchWindow();
// if (window != null) {
// return window.getShell();
// }
// return null;
// }
//
// /**
// * @return Returns the active workbench window's currrent page.
// */
// public static IWorkbenchPage getActivePage() {
// return getActiveWorkbenchWindow().getActivePage();
// }
//
// public static void setPlugin(WebResourcesUIPlugin plugin) {
// WebResourcesUIPlugin.plugin = plugin;
// }
//
// }
// Path: org.eclipse.a.wst.html.webresources.ui/src/org/eclipse/wst/html/webresources/internal/ui/utils/EditorUtils.java
import java.io.File;
import org.eclipse.core.filebuffers.FileBuffers;
import org.eclipse.core.filebuffers.ITextFileBufferManager;
import org.eclipse.core.filesystem.EFS;
import org.eclipse.core.filesystem.IFileStore;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IMarker;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.core.runtime.IPath;
import org.eclipse.jface.text.IDocument;
import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.ide.IDE;
import org.eclipse.ui.texteditor.ITextEditor;
import org.eclipse.wst.html.webresources.internal.ui.WebResourcesUIPlugin;
/**
* Copyright (c) 2013-2014 Angelo ZERR.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Angelo Zerr <angelo.zerr@gmail.com> - initial API and implementation
*/
package org.eclipse.wst.html.webresources.internal.ui.utils;
/**
* Editor utilities.
*
*/
public class EditorUtils {
private EditorUtils() {}
public static IEditorPart openInEditor(IFile file, int start, int length,
boolean activate) {
IEditorPart editor = null;
| IWorkbenchPage page = WebResourcesUIPlugin.getActivePage();
|
angelozerr/eclipse-wtp-webresources | org.eclipse.a.wst.html.webresources.core/src/org/eclipse/wst/html/webresources/core/utils/ResourceHelper.java | // Path: org.eclipse.a.wst.html.webresources.core/src/org/eclipse/wst/html/webresources/core/WebResourceType.java
// public enum WebResourceType {
//
// css, js, img;
//
// public static WebResourceType get(String value) {
// WebResourceType[] types = WebResourceType.values();
// WebResourceType type;
// for (int i = 0; i < types.length; i++) {
// type = types[i];
// if (type.name().equalsIgnoreCase(value)) {
// return type;
// }
// }
// return null;
// }
//
// }
| import java.io.File;
import java.util.ArrayList;
import java.util.Collection;
import org.eclipse.core.resources.IResource;
import org.eclipse.wst.html.webresources.core.WebResourceType;
| /**
* Copyright (c) 2013-2014 Angelo ZERR.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Angelo Zerr <angelo.zerr@gmail.com> - initial API and implementation
*/
package org.eclipse.wst.html.webresources.core.utils;
/**
* Helper for {@link IResource}.
*/
public class ResourceHelper {
private final static Collection<String> IMG_EXTENSIONS;
static {
IMG_EXTENSIONS = new ArrayList<String>();
IMG_EXTENSIONS.add("bmp");
IMG_EXTENSIONS.add("gif");
IMG_EXTENSIONS.add("jif");
IMG_EXTENSIONS.add("jfif");
IMG_EXTENSIONS.add("jpg");
IMG_EXTENSIONS.add("jpeg");
IMG_EXTENSIONS.add("png");
IMG_EXTENSIONS.add("tif");
IMG_EXTENSIONS.add("tiff");
IMG_EXTENSIONS.add("wbmp");
}
private final static Collection<String> CSS_EXTENSIONS;
static {
CSS_EXTENSIONS = new ArrayList<String>();
CSS_EXTENSIONS.add("css");
CSS_EXTENSIONS.add("scss");
}
private ResourceHelper() {}
/**
* Returns the web resource type of the given resource and null otherwise.
*
* @param resource
* @return the web resource type of the given resource and null otherwise.
*/
| // Path: org.eclipse.a.wst.html.webresources.core/src/org/eclipse/wst/html/webresources/core/WebResourceType.java
// public enum WebResourceType {
//
// css, js, img;
//
// public static WebResourceType get(String value) {
// WebResourceType[] types = WebResourceType.values();
// WebResourceType type;
// for (int i = 0; i < types.length; i++) {
// type = types[i];
// if (type.name().equalsIgnoreCase(value)) {
// return type;
// }
// }
// return null;
// }
//
// }
// Path: org.eclipse.a.wst.html.webresources.core/src/org/eclipse/wst/html/webresources/core/utils/ResourceHelper.java
import java.io.File;
import java.util.ArrayList;
import java.util.Collection;
import org.eclipse.core.resources.IResource;
import org.eclipse.wst.html.webresources.core.WebResourceType;
/**
* Copyright (c) 2013-2014 Angelo ZERR.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Angelo Zerr <angelo.zerr@gmail.com> - initial API and implementation
*/
package org.eclipse.wst.html.webresources.core.utils;
/**
* Helper for {@link IResource}.
*/
public class ResourceHelper {
private final static Collection<String> IMG_EXTENSIONS;
static {
IMG_EXTENSIONS = new ArrayList<String>();
IMG_EXTENSIONS.add("bmp");
IMG_EXTENSIONS.add("gif");
IMG_EXTENSIONS.add("jif");
IMG_EXTENSIONS.add("jfif");
IMG_EXTENSIONS.add("jpg");
IMG_EXTENSIONS.add("jpeg");
IMG_EXTENSIONS.add("png");
IMG_EXTENSIONS.add("tif");
IMG_EXTENSIONS.add("tiff");
IMG_EXTENSIONS.add("wbmp");
}
private final static Collection<String> CSS_EXTENSIONS;
static {
CSS_EXTENSIONS = new ArrayList<String>();
CSS_EXTENSIONS.add("css");
CSS_EXTENSIONS.add("scss");
}
private ResourceHelper() {}
/**
* Returns the web resource type of the given resource and null otherwise.
*
* @param resource
* @return the web resource type of the given resource and null otherwise.
*/
| public static WebResourceType getWebResourceType(IResource resource) {
|
DataDog/jenkins-datadog-plugin | src/test/java/org/datadog/jenkins/plugins/datadog/clients/DatadogClientStub.java | // Path: src/main/java/org/datadog/jenkins/plugins/datadog/DatadogClient.java
// public interface DatadogClient {
//
// public static enum ClientType {
// HTTP,
// DSD;
//
// private ClientType() { }
// }
//
// public static enum Status {
// OK(0),
// WARNING(1),
// CRITICAL(2),
// UNKNOWN(3);
//
// private final int val;
//
// private Status(int val) {
// this.val = val;
// }
//
// public int toValue(){
// return this.val;
// }
//
// public ServiceCheck.Status toServiceCheckStatus(){
// return ServiceCheck.Status.valueOf(this.name());
// }
// }
//
// public void setUrl(String url);
//
// public void setApiKey(Secret apiKey);
//
// public void setHostname(String hostname);
//
// public void setPort(int port);
//
// /**
// * Sends an event to the Datadog API, including the event payload.
// *
// * @param event - a DatadogEvent object
// * @return a boolean to signify the success or failure of the HTTP POST request.
// */
// public boolean event(DatadogEvent event);
//
// /**
// * Increment a counter for the given metrics.
// * NOTE: To submit all counters you need to execute the flushCounters method.
// * This is to aggregate counters and submit them in batch to Datadog in order to minimize network traffic.
// * @param name - metric name
// * @param hostname - metric hostname
// * @param tags - metric tags
// */
// public void incrementCounter(String name, String hostname, Map<String, Set<String>> tags);
//
// /**
// * Submit all your counters as rate with 10 seconds intervals.
// */
// public void flushCounters();
//
// /**
// * Sends a metric to the Datadog API, including the gauge name, and value.
// *
// * @param name - A String with the name of the metric to record.
// * @param value - A long containing the value to submit.
// * @param hostname - A String with the hostname to submit.
// * @param tags - A Map containing the tags to submit.
// * @return a boolean to signify the success or failure of the HTTP POST request.
// */
// public boolean gauge(String name, long value, String hostname, Map<String, Set<String>> tags);
//
// /**
// * Sends a service check to the Datadog API, including the check name, and status.
// *
// * @param name - A String with the name of the service check to record.
// * @param status - An Status with the status code to record for this service check.
// * @param hostname - A String with the hostname to submit.
// * @param tags - A Map containing the tags to submit.
// * @return a boolean to signify the success or failure of the HTTP POST request.
// */
// public boolean serviceCheck(String name, Status status, String hostname, Map<String, Set<String>> tags);
//
// /**
// * Tests the apiKey is valid.
// *
// * @return a boolean to signify the success or failure of the HTTP GET request.
// * @throws IOException if there is an input/output exception.
// * @throws ServletException if there is a servlet exception.
// */
// public boolean validate() throws IOException, ServletException;
// }
//
// Path: src/main/java/org/datadog/jenkins/plugins/datadog/DatadogEvent.java
// public interface DatadogEvent {
//
// public static enum AlertType {
// ERROR,
// WARNING,
// INFO,
// SUCCESS;
//
// private AlertType() {
// }
//
// public Event.AlertType toEventAlertType(){
// return Event.AlertType.valueOf(this.name());
// }
// }
//
// public static enum Priority {
// LOW,
// NORMAL;
//
// private Priority() {
// }
//
// public Event.Priority toEventPriority(){
// return Event.Priority.valueOf(this.name());
// }
// }
//
// public String getTitle();
//
// public String getText();
//
// public String getHost();
//
// public Priority getPriority();
//
// public AlertType getAlertType();
//
// public String getAggregationKey();
//
// public Long getDate();
//
// public Map<String, Set<String>> getTags();
//
//
// }
| import javax.servlet.ServletException;
import java.io.IOException;
import java.util.*;
import hudson.util.Secret;
import org.datadog.jenkins.plugins.datadog.DatadogClient;
import org.datadog.jenkins.plugins.datadog.DatadogEvent;
import org.junit.Assert; | /*
The MIT License
Copyright (c) 2015-Present Datadog, Inc <opensource@datadoghq.com>
All rights reserved.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
package org.datadog.jenkins.plugins.datadog.clients;
public class DatadogClientStub implements DatadogClient {
List<DatadogMetric> metrics = new ArrayList<>();
List<DatadogMetric> serviceChecks = new ArrayList<>();
public DatadogClientStub() {
this.metrics = new ArrayList<>();
this.serviceChecks = new ArrayList<>();
}
@Override
public void setUrl(String url) {
// noop
}
@Override
public void setApiKey(Secret apiKey) {
// noop
}
@Override
public void setHostname(String hostname) {
// noop
}
@Override
public void setPort(int port) {
// noop
}
@Override | // Path: src/main/java/org/datadog/jenkins/plugins/datadog/DatadogClient.java
// public interface DatadogClient {
//
// public static enum ClientType {
// HTTP,
// DSD;
//
// private ClientType() { }
// }
//
// public static enum Status {
// OK(0),
// WARNING(1),
// CRITICAL(2),
// UNKNOWN(3);
//
// private final int val;
//
// private Status(int val) {
// this.val = val;
// }
//
// public int toValue(){
// return this.val;
// }
//
// public ServiceCheck.Status toServiceCheckStatus(){
// return ServiceCheck.Status.valueOf(this.name());
// }
// }
//
// public void setUrl(String url);
//
// public void setApiKey(Secret apiKey);
//
// public void setHostname(String hostname);
//
// public void setPort(int port);
//
// /**
// * Sends an event to the Datadog API, including the event payload.
// *
// * @param event - a DatadogEvent object
// * @return a boolean to signify the success or failure of the HTTP POST request.
// */
// public boolean event(DatadogEvent event);
//
// /**
// * Increment a counter for the given metrics.
// * NOTE: To submit all counters you need to execute the flushCounters method.
// * This is to aggregate counters and submit them in batch to Datadog in order to minimize network traffic.
// * @param name - metric name
// * @param hostname - metric hostname
// * @param tags - metric tags
// */
// public void incrementCounter(String name, String hostname, Map<String, Set<String>> tags);
//
// /**
// * Submit all your counters as rate with 10 seconds intervals.
// */
// public void flushCounters();
//
// /**
// * Sends a metric to the Datadog API, including the gauge name, and value.
// *
// * @param name - A String with the name of the metric to record.
// * @param value - A long containing the value to submit.
// * @param hostname - A String with the hostname to submit.
// * @param tags - A Map containing the tags to submit.
// * @return a boolean to signify the success or failure of the HTTP POST request.
// */
// public boolean gauge(String name, long value, String hostname, Map<String, Set<String>> tags);
//
// /**
// * Sends a service check to the Datadog API, including the check name, and status.
// *
// * @param name - A String with the name of the service check to record.
// * @param status - An Status with the status code to record for this service check.
// * @param hostname - A String with the hostname to submit.
// * @param tags - A Map containing the tags to submit.
// * @return a boolean to signify the success or failure of the HTTP POST request.
// */
// public boolean serviceCheck(String name, Status status, String hostname, Map<String, Set<String>> tags);
//
// /**
// * Tests the apiKey is valid.
// *
// * @return a boolean to signify the success or failure of the HTTP GET request.
// * @throws IOException if there is an input/output exception.
// * @throws ServletException if there is a servlet exception.
// */
// public boolean validate() throws IOException, ServletException;
// }
//
// Path: src/main/java/org/datadog/jenkins/plugins/datadog/DatadogEvent.java
// public interface DatadogEvent {
//
// public static enum AlertType {
// ERROR,
// WARNING,
// INFO,
// SUCCESS;
//
// private AlertType() {
// }
//
// public Event.AlertType toEventAlertType(){
// return Event.AlertType.valueOf(this.name());
// }
// }
//
// public static enum Priority {
// LOW,
// NORMAL;
//
// private Priority() {
// }
//
// public Event.Priority toEventPriority(){
// return Event.Priority.valueOf(this.name());
// }
// }
//
// public String getTitle();
//
// public String getText();
//
// public String getHost();
//
// public Priority getPriority();
//
// public AlertType getAlertType();
//
// public String getAggregationKey();
//
// public Long getDate();
//
// public Map<String, Set<String>> getTags();
//
//
// }
// Path: src/test/java/org/datadog/jenkins/plugins/datadog/clients/DatadogClientStub.java
import javax.servlet.ServletException;
import java.io.IOException;
import java.util.*;
import hudson.util.Secret;
import org.datadog.jenkins.plugins.datadog.DatadogClient;
import org.datadog.jenkins.plugins.datadog.DatadogEvent;
import org.junit.Assert;
/*
The MIT License
Copyright (c) 2015-Present Datadog, Inc <opensource@datadoghq.com>
All rights reserved.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
package org.datadog.jenkins.plugins.datadog.clients;
public class DatadogClientStub implements DatadogClient {
List<DatadogMetric> metrics = new ArrayList<>();
List<DatadogMetric> serviceChecks = new ArrayList<>();
public DatadogClientStub() {
this.metrics = new ArrayList<>();
this.serviceChecks = new ArrayList<>();
}
@Override
public void setUrl(String url) {
// noop
}
@Override
public void setApiKey(Secret apiKey) {
// noop
}
@Override
public void setHostname(String hostname) {
// noop
}
@Override
public void setPort(int port) {
// noop
}
@Override | public boolean event(DatadogEvent event) { |
DataDog/jenkins-datadog-plugin | src/main/java/org/datadog/jenkins/plugins/datadog/DatadogUtilities.java | // Path: src/main/java/org/datadog/jenkins/plugins/datadog/util/TagsUtil.java
// public class TagsUtil {
//
// public static Map<String, Set<String>> merge(Map<String, Set<String>> dest, Map<String, Set<String>> orig) {
// if (dest == null) {
// dest = new HashMap<>();
// }
// if (orig == null) {
// orig = new HashMap<>();
// }
// for (String oName: orig.keySet()){
// Set<String> dValues = dest.containsKey(oName) ? dest.get(oName) : new HashSet<String>();
// if (dValues == null) {
// dValues = new HashSet<>();
// }
// Set<String> oValues = orig.get(oName);
// if (oValues != null) {
// dValues.addAll(oValues);
// }
// dest.put(oName, dValues);
// }
// return dest;
// }
//
// public static JSONArray convertTagsToJSONArray(Map<String, Set<String>> tags){
// JSONArray result = new JSONArray();
// for (String name : tags.keySet()) {
// Set<String> values = tags.get(name);
// for (String value : values){
// if ("".equals(value)){
// result.add(name); // Tag with no value
// }else{
// result.add(String.format("%s:%s", name, value));
// }
// }
// }
// return result;
// }
//
// public static String[] convertTagsToArray(Map<String, Set<String>> tags){
// List<String> result = new ArrayList<>();
// for (String name : tags.keySet()) {
// Set<String> values = tags.get(name);
// for (String value : values){
// if("".equals(value)){
// result.add(name);
// }else{
// result.add(String.format("%s:%s", name, value));
// }
// }
// }
// Collections.sort(result);
// return result.toArray(new String[0]);
// }
// }
| import jenkins.model.Jenkins;
import org.datadog.jenkins.plugins.datadog.util.TagsUtil;
import javax.annotation.Nonnull;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.Inet4Address;
import java.net.UnknownHostException;
import java.util.*;
import java.util.logging.Logger;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import hudson.EnvVars;
import hudson.ExtensionList;
import hudson.XmlFile;
import hudson.model.*;
import hudson.model.labels.LabelAtom; | /*
The MIT License
Copyright (c) 2015-Present Datadog, Inc <opensource@datadoghq.com>
All rights reserved.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
package org.datadog.jenkins.plugins.datadog;
public class DatadogUtilities {
private static final Logger logger = Logger.getLogger(DatadogUtilities.class.getName());
private static final Integer MAX_HOSTNAME_LEN = 255;
/**
* @return - The descriptor for the Datadog plugin. In this case the global configuration.
*/
public static DatadogGlobalConfiguration getDatadogGlobalDescriptor() {
Jenkins jenkins = Jenkins.getInstance();
if (jenkins == null) {
return null;
}
return ExtensionList.lookup(DatadogGlobalConfiguration.class).get(DatadogGlobalConfiguration.class);
}
/**
* @param r - Current build.
* @return - The configured {@link DatadogJobProperty}. Null if not there
*/
public static DatadogJobProperty getDatadogJobProperties(@Nonnull Run r) {
return (DatadogJobProperty) r.getParent().getProperty(DatadogJobProperty.class);
}
/**
* Builds extraTags if any are configured in the Job.
*
* @param run - Current build
* @param listener - Current listener
* @return A {@link HashMap} containing the key,value pairs of tags if any.
*/
public static Map<String, Set<String>> getBuildTags(Run run, @Nonnull TaskListener listener) {
Map<String, Set<String>> result = new HashMap<>();
String jobName = run.getParent().getFullName();
final String globalJobTags = getDatadogGlobalDescriptor().getGlobalJobTags();
final DatadogJobProperty property = DatadogUtilities.getDatadogJobProperties(run);
String workspaceTagFile = property.readTagFile(run);
// If job doesn't have a workspace Tag File set we check if one has been defined globally
if(workspaceTagFile == null){
workspaceTagFile = getDatadogGlobalDescriptor().getGlobalTagFile();
}
try {
final EnvVars envVars = run.getEnvironment(listener);
if (workspaceTagFile != null) { | // Path: src/main/java/org/datadog/jenkins/plugins/datadog/util/TagsUtil.java
// public class TagsUtil {
//
// public static Map<String, Set<String>> merge(Map<String, Set<String>> dest, Map<String, Set<String>> orig) {
// if (dest == null) {
// dest = new HashMap<>();
// }
// if (orig == null) {
// orig = new HashMap<>();
// }
// for (String oName: orig.keySet()){
// Set<String> dValues = dest.containsKey(oName) ? dest.get(oName) : new HashSet<String>();
// if (dValues == null) {
// dValues = new HashSet<>();
// }
// Set<String> oValues = orig.get(oName);
// if (oValues != null) {
// dValues.addAll(oValues);
// }
// dest.put(oName, dValues);
// }
// return dest;
// }
//
// public static JSONArray convertTagsToJSONArray(Map<String, Set<String>> tags){
// JSONArray result = new JSONArray();
// for (String name : tags.keySet()) {
// Set<String> values = tags.get(name);
// for (String value : values){
// if ("".equals(value)){
// result.add(name); // Tag with no value
// }else{
// result.add(String.format("%s:%s", name, value));
// }
// }
// }
// return result;
// }
//
// public static String[] convertTagsToArray(Map<String, Set<String>> tags){
// List<String> result = new ArrayList<>();
// for (String name : tags.keySet()) {
// Set<String> values = tags.get(name);
// for (String value : values){
// if("".equals(value)){
// result.add(name);
// }else{
// result.add(String.format("%s:%s", name, value));
// }
// }
// }
// Collections.sort(result);
// return result.toArray(new String[0]);
// }
// }
// Path: src/main/java/org/datadog/jenkins/plugins/datadog/DatadogUtilities.java
import jenkins.model.Jenkins;
import org.datadog.jenkins.plugins.datadog.util.TagsUtil;
import javax.annotation.Nonnull;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.Inet4Address;
import java.net.UnknownHostException;
import java.util.*;
import java.util.logging.Logger;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import hudson.EnvVars;
import hudson.ExtensionList;
import hudson.XmlFile;
import hudson.model.*;
import hudson.model.labels.LabelAtom;
/*
The MIT License
Copyright (c) 2015-Present Datadog, Inc <opensource@datadoghq.com>
All rights reserved.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
package org.datadog.jenkins.plugins.datadog;
public class DatadogUtilities {
private static final Logger logger = Logger.getLogger(DatadogUtilities.class.getName());
private static final Integer MAX_HOSTNAME_LEN = 255;
/**
* @return - The descriptor for the Datadog plugin. In this case the global configuration.
*/
public static DatadogGlobalConfiguration getDatadogGlobalDescriptor() {
Jenkins jenkins = Jenkins.getInstance();
if (jenkins == null) {
return null;
}
return ExtensionList.lookup(DatadogGlobalConfiguration.class).get(DatadogGlobalConfiguration.class);
}
/**
* @param r - Current build.
* @return - The configured {@link DatadogJobProperty}. Null if not there
*/
public static DatadogJobProperty getDatadogJobProperties(@Nonnull Run r) {
return (DatadogJobProperty) r.getParent().getProperty(DatadogJobProperty.class);
}
/**
* Builds extraTags if any are configured in the Job.
*
* @param run - Current build
* @param listener - Current listener
* @return A {@link HashMap} containing the key,value pairs of tags if any.
*/
public static Map<String, Set<String>> getBuildTags(Run run, @Nonnull TaskListener listener) {
Map<String, Set<String>> result = new HashMap<>();
String jobName = run.getParent().getFullName();
final String globalJobTags = getDatadogGlobalDescriptor().getGlobalJobTags();
final DatadogJobProperty property = DatadogUtilities.getDatadogJobProperties(run);
String workspaceTagFile = property.readTagFile(run);
// If job doesn't have a workspace Tag File set we check if one has been defined globally
if(workspaceTagFile == null){
workspaceTagFile = getDatadogGlobalDescriptor().getGlobalTagFile();
}
try {
final EnvVars envVars = run.getEnvironment(listener);
if (workspaceTagFile != null) { | result = TagsUtil.merge(result, computeTagListFromVarList(envVars, workspaceTagFile)); |
DataDog/jenkins-datadog-plugin | src/test/java/org/datadog/jenkins/plugins/datadog/clients/DatadogClientTest.java | // Path: src/main/java/org/datadog/jenkins/plugins/datadog/DatadogClient.java
// public interface DatadogClient {
//
// public static enum ClientType {
// HTTP,
// DSD;
//
// private ClientType() { }
// }
//
// public static enum Status {
// OK(0),
// WARNING(1),
// CRITICAL(2),
// UNKNOWN(3);
//
// private final int val;
//
// private Status(int val) {
// this.val = val;
// }
//
// public int toValue(){
// return this.val;
// }
//
// public ServiceCheck.Status toServiceCheckStatus(){
// return ServiceCheck.Status.valueOf(this.name());
// }
// }
//
// public void setUrl(String url);
//
// public void setApiKey(Secret apiKey);
//
// public void setHostname(String hostname);
//
// public void setPort(int port);
//
// /**
// * Sends an event to the Datadog API, including the event payload.
// *
// * @param event - a DatadogEvent object
// * @return a boolean to signify the success or failure of the HTTP POST request.
// */
// public boolean event(DatadogEvent event);
//
// /**
// * Increment a counter for the given metrics.
// * NOTE: To submit all counters you need to execute the flushCounters method.
// * This is to aggregate counters and submit them in batch to Datadog in order to minimize network traffic.
// * @param name - metric name
// * @param hostname - metric hostname
// * @param tags - metric tags
// */
// public void incrementCounter(String name, String hostname, Map<String, Set<String>> tags);
//
// /**
// * Submit all your counters as rate with 10 seconds intervals.
// */
// public void flushCounters();
//
// /**
// * Sends a metric to the Datadog API, including the gauge name, and value.
// *
// * @param name - A String with the name of the metric to record.
// * @param value - A long containing the value to submit.
// * @param hostname - A String with the hostname to submit.
// * @param tags - A Map containing the tags to submit.
// * @return a boolean to signify the success or failure of the HTTP POST request.
// */
// public boolean gauge(String name, long value, String hostname, Map<String, Set<String>> tags);
//
// /**
// * Sends a service check to the Datadog API, including the check name, and status.
// *
// * @param name - A String with the name of the service check to record.
// * @param status - An Status with the status code to record for this service check.
// * @param hostname - A String with the hostname to submit.
// * @param tags - A Map containing the tags to submit.
// * @return a boolean to signify the success or failure of the HTTP POST request.
// */
// public boolean serviceCheck(String name, Status status, String hostname, Map<String, Set<String>> tags);
//
// /**
// * Tests the apiKey is valid.
// *
// * @return a boolean to signify the success or failure of the HTTP GET request.
// * @throws IOException if there is an input/output exception.
// * @throws ServletException if there is a servlet exception.
// */
// public boolean validate() throws IOException, ServletException;
// }
| import java.util.HashMap;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.*;
import org.datadog.jenkins.plugins.datadog.DatadogClient;
import org.junit.Assert;
import org.junit.Test;
import java.io.IOException; | /*
The MIT License
Copyright (c) 2015-Present Datadog, Inc <opensource@datadoghq.com>
All rights reserved.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
package org.datadog.jenkins.plugins.datadog.clients;
public class DatadogClientTest {
@Test
public void testIncrementCountAndFlush() throws IOException, InterruptedException {
DatadogHttpClient.enableValidations = false; | // Path: src/main/java/org/datadog/jenkins/plugins/datadog/DatadogClient.java
// public interface DatadogClient {
//
// public static enum ClientType {
// HTTP,
// DSD;
//
// private ClientType() { }
// }
//
// public static enum Status {
// OK(0),
// WARNING(1),
// CRITICAL(2),
// UNKNOWN(3);
//
// private final int val;
//
// private Status(int val) {
// this.val = val;
// }
//
// public int toValue(){
// return this.val;
// }
//
// public ServiceCheck.Status toServiceCheckStatus(){
// return ServiceCheck.Status.valueOf(this.name());
// }
// }
//
// public void setUrl(String url);
//
// public void setApiKey(Secret apiKey);
//
// public void setHostname(String hostname);
//
// public void setPort(int port);
//
// /**
// * Sends an event to the Datadog API, including the event payload.
// *
// * @param event - a DatadogEvent object
// * @return a boolean to signify the success or failure of the HTTP POST request.
// */
// public boolean event(DatadogEvent event);
//
// /**
// * Increment a counter for the given metrics.
// * NOTE: To submit all counters you need to execute the flushCounters method.
// * This is to aggregate counters and submit them in batch to Datadog in order to minimize network traffic.
// * @param name - metric name
// * @param hostname - metric hostname
// * @param tags - metric tags
// */
// public void incrementCounter(String name, String hostname, Map<String, Set<String>> tags);
//
// /**
// * Submit all your counters as rate with 10 seconds intervals.
// */
// public void flushCounters();
//
// /**
// * Sends a metric to the Datadog API, including the gauge name, and value.
// *
// * @param name - A String with the name of the metric to record.
// * @param value - A long containing the value to submit.
// * @param hostname - A String with the hostname to submit.
// * @param tags - A Map containing the tags to submit.
// * @return a boolean to signify the success or failure of the HTTP POST request.
// */
// public boolean gauge(String name, long value, String hostname, Map<String, Set<String>> tags);
//
// /**
// * Sends a service check to the Datadog API, including the check name, and status.
// *
// * @param name - A String with the name of the service check to record.
// * @param status - An Status with the status code to record for this service check.
// * @param hostname - A String with the hostname to submit.
// * @param tags - A Map containing the tags to submit.
// * @return a boolean to signify the success or failure of the HTTP POST request.
// */
// public boolean serviceCheck(String name, Status status, String hostname, Map<String, Set<String>> tags);
//
// /**
// * Tests the apiKey is valid.
// *
// * @return a boolean to signify the success or failure of the HTTP GET request.
// * @throws IOException if there is an input/output exception.
// * @throws ServletException if there is a servlet exception.
// */
// public boolean validate() throws IOException, ServletException;
// }
// Path: src/test/java/org/datadog/jenkins/plugins/datadog/clients/DatadogClientTest.java
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.*;
import org.datadog.jenkins.plugins.datadog.DatadogClient;
import org.junit.Assert;
import org.junit.Test;
import java.io.IOException;
/*
The MIT License
Copyright (c) 2015-Present Datadog, Inc <opensource@datadoghq.com>
All rights reserved.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
package org.datadog.jenkins.plugins.datadog.clients;
public class DatadogClientTest {
@Test
public void testIncrementCountAndFlush() throws IOException, InterruptedException {
DatadogHttpClient.enableValidations = false; | DatadogClient client = DatadogHttpClient.getInstance("test", null); |
DataDog/jenkins-datadog-plugin | src/main/java/org/datadog/jenkins/plugins/datadog/publishers/DatadogCountersPublisher.java | // Path: src/main/java/org/datadog/jenkins/plugins/datadog/DatadogClient.java
// public interface DatadogClient {
//
// public static enum ClientType {
// HTTP,
// DSD;
//
// private ClientType() { }
// }
//
// public static enum Status {
// OK(0),
// WARNING(1),
// CRITICAL(2),
// UNKNOWN(3);
//
// private final int val;
//
// private Status(int val) {
// this.val = val;
// }
//
// public int toValue(){
// return this.val;
// }
//
// public ServiceCheck.Status toServiceCheckStatus(){
// return ServiceCheck.Status.valueOf(this.name());
// }
// }
//
// public void setUrl(String url);
//
// public void setApiKey(Secret apiKey);
//
// public void setHostname(String hostname);
//
// public void setPort(int port);
//
// /**
// * Sends an event to the Datadog API, including the event payload.
// *
// * @param event - a DatadogEvent object
// * @return a boolean to signify the success or failure of the HTTP POST request.
// */
// public boolean event(DatadogEvent event);
//
// /**
// * Increment a counter for the given metrics.
// * NOTE: To submit all counters you need to execute the flushCounters method.
// * This is to aggregate counters and submit them in batch to Datadog in order to minimize network traffic.
// * @param name - metric name
// * @param hostname - metric hostname
// * @param tags - metric tags
// */
// public void incrementCounter(String name, String hostname, Map<String, Set<String>> tags);
//
// /**
// * Submit all your counters as rate with 10 seconds intervals.
// */
// public void flushCounters();
//
// /**
// * Sends a metric to the Datadog API, including the gauge name, and value.
// *
// * @param name - A String with the name of the metric to record.
// * @param value - A long containing the value to submit.
// * @param hostname - A String with the hostname to submit.
// * @param tags - A Map containing the tags to submit.
// * @return a boolean to signify the success or failure of the HTTP POST request.
// */
// public boolean gauge(String name, long value, String hostname, Map<String, Set<String>> tags);
//
// /**
// * Sends a service check to the Datadog API, including the check name, and status.
// *
// * @param name - A String with the name of the service check to record.
// * @param status - An Status with the status code to record for this service check.
// * @param hostname - A String with the hostname to submit.
// * @param tags - A Map containing the tags to submit.
// * @return a boolean to signify the success or failure of the HTTP POST request.
// */
// public boolean serviceCheck(String name, Status status, String hostname, Map<String, Set<String>> tags);
//
// /**
// * Tests the apiKey is valid.
// *
// * @return a boolean to signify the success or failure of the HTTP GET request.
// * @throws IOException if there is an input/output exception.
// * @throws ServletException if there is a servlet exception.
// */
// public boolean validate() throws IOException, ServletException;
// }
//
// Path: src/main/java/org/datadog/jenkins/plugins/datadog/clients/ClientFactory.java
// public class ClientFactory {
//
// public static DatadogClient getClient(DatadogClient.ClientType type, String apiUrl, Secret apiKey, String host, Integer port){
// switch(type){
// case HTTP:
// return DatadogHttpClient.getInstance(apiUrl, apiKey);
// case DSD:
// return DogStatsDClient.getInstance(host, port);
// default:
// return null;
// }
// }
//
// public static DatadogClient getClient() {
// DatadogGlobalConfiguration descriptor = DatadogUtilities.getDatadogGlobalDescriptor();
// return ClientFactory.getClient(DatadogClient.ClientType.valueOf(descriptor.getReportWith()),
// descriptor.getTargetApiURL(), descriptor.getTargetApiKey(),
// descriptor.getTargetHost(), descriptor.getTargetPort());
// }
// }
| import java.io.IOException;
import java.util.concurrent.TimeUnit;
import java.util.logging.Logger;
import hudson.Extension;
import hudson.model.*;
import org.datadog.jenkins.plugins.datadog.DatadogClient;
import org.datadog.jenkins.plugins.datadog.clients.ClientFactory; | /*
The MIT License
Copyright (c) 2015-Present Datadog, Inc <opensource@datadoghq.com>
All rights reserved.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
package org.datadog.jenkins.plugins.datadog.publishers;
@Extension
public class DatadogCountersPublisher extends AsyncPeriodicWork {
private static final Logger logger = Logger.getLogger(DatadogCountersPublisher.class.getName());
public DatadogCountersPublisher() {
super("Datadog Counters Publisher");
}
@Override
public long getRecurrencePeriod() {
return TimeUnit.SECONDS.toMillis(10);
}
@Override
protected void execute(TaskListener taskListener) throws IOException, InterruptedException {
try {
logger.fine("Execute called: Publishing counters");
// Get Datadog Client Instance | // Path: src/main/java/org/datadog/jenkins/plugins/datadog/DatadogClient.java
// public interface DatadogClient {
//
// public static enum ClientType {
// HTTP,
// DSD;
//
// private ClientType() { }
// }
//
// public static enum Status {
// OK(0),
// WARNING(1),
// CRITICAL(2),
// UNKNOWN(3);
//
// private final int val;
//
// private Status(int val) {
// this.val = val;
// }
//
// public int toValue(){
// return this.val;
// }
//
// public ServiceCheck.Status toServiceCheckStatus(){
// return ServiceCheck.Status.valueOf(this.name());
// }
// }
//
// public void setUrl(String url);
//
// public void setApiKey(Secret apiKey);
//
// public void setHostname(String hostname);
//
// public void setPort(int port);
//
// /**
// * Sends an event to the Datadog API, including the event payload.
// *
// * @param event - a DatadogEvent object
// * @return a boolean to signify the success or failure of the HTTP POST request.
// */
// public boolean event(DatadogEvent event);
//
// /**
// * Increment a counter for the given metrics.
// * NOTE: To submit all counters you need to execute the flushCounters method.
// * This is to aggregate counters and submit them in batch to Datadog in order to minimize network traffic.
// * @param name - metric name
// * @param hostname - metric hostname
// * @param tags - metric tags
// */
// public void incrementCounter(String name, String hostname, Map<String, Set<String>> tags);
//
// /**
// * Submit all your counters as rate with 10 seconds intervals.
// */
// public void flushCounters();
//
// /**
// * Sends a metric to the Datadog API, including the gauge name, and value.
// *
// * @param name - A String with the name of the metric to record.
// * @param value - A long containing the value to submit.
// * @param hostname - A String with the hostname to submit.
// * @param tags - A Map containing the tags to submit.
// * @return a boolean to signify the success or failure of the HTTP POST request.
// */
// public boolean gauge(String name, long value, String hostname, Map<String, Set<String>> tags);
//
// /**
// * Sends a service check to the Datadog API, including the check name, and status.
// *
// * @param name - A String with the name of the service check to record.
// * @param status - An Status with the status code to record for this service check.
// * @param hostname - A String with the hostname to submit.
// * @param tags - A Map containing the tags to submit.
// * @return a boolean to signify the success or failure of the HTTP POST request.
// */
// public boolean serviceCheck(String name, Status status, String hostname, Map<String, Set<String>> tags);
//
// /**
// * Tests the apiKey is valid.
// *
// * @return a boolean to signify the success or failure of the HTTP GET request.
// * @throws IOException if there is an input/output exception.
// * @throws ServletException if there is a servlet exception.
// */
// public boolean validate() throws IOException, ServletException;
// }
//
// Path: src/main/java/org/datadog/jenkins/plugins/datadog/clients/ClientFactory.java
// public class ClientFactory {
//
// public static DatadogClient getClient(DatadogClient.ClientType type, String apiUrl, Secret apiKey, String host, Integer port){
// switch(type){
// case HTTP:
// return DatadogHttpClient.getInstance(apiUrl, apiKey);
// case DSD:
// return DogStatsDClient.getInstance(host, port);
// default:
// return null;
// }
// }
//
// public static DatadogClient getClient() {
// DatadogGlobalConfiguration descriptor = DatadogUtilities.getDatadogGlobalDescriptor();
// return ClientFactory.getClient(DatadogClient.ClientType.valueOf(descriptor.getReportWith()),
// descriptor.getTargetApiURL(), descriptor.getTargetApiKey(),
// descriptor.getTargetHost(), descriptor.getTargetPort());
// }
// }
// Path: src/main/java/org/datadog/jenkins/plugins/datadog/publishers/DatadogCountersPublisher.java
import java.io.IOException;
import java.util.concurrent.TimeUnit;
import java.util.logging.Logger;
import hudson.Extension;
import hudson.model.*;
import org.datadog.jenkins.plugins.datadog.DatadogClient;
import org.datadog.jenkins.plugins.datadog.clients.ClientFactory;
/*
The MIT License
Copyright (c) 2015-Present Datadog, Inc <opensource@datadoghq.com>
All rights reserved.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
package org.datadog.jenkins.plugins.datadog.publishers;
@Extension
public class DatadogCountersPublisher extends AsyncPeriodicWork {
private static final Logger logger = Logger.getLogger(DatadogCountersPublisher.class.getName());
public DatadogCountersPublisher() {
super("Datadog Counters Publisher");
}
@Override
public long getRecurrencePeriod() {
return TimeUnit.SECONDS.toMillis(10);
}
@Override
protected void execute(TaskListener taskListener) throws IOException, InterruptedException {
try {
logger.fine("Execute called: Publishing counters");
// Get Datadog Client Instance | DatadogClient client = ClientFactory.getClient(); |
DataDog/jenkins-datadog-plugin | src/main/java/org/datadog/jenkins/plugins/datadog/publishers/DatadogCountersPublisher.java | // Path: src/main/java/org/datadog/jenkins/plugins/datadog/DatadogClient.java
// public interface DatadogClient {
//
// public static enum ClientType {
// HTTP,
// DSD;
//
// private ClientType() { }
// }
//
// public static enum Status {
// OK(0),
// WARNING(1),
// CRITICAL(2),
// UNKNOWN(3);
//
// private final int val;
//
// private Status(int val) {
// this.val = val;
// }
//
// public int toValue(){
// return this.val;
// }
//
// public ServiceCheck.Status toServiceCheckStatus(){
// return ServiceCheck.Status.valueOf(this.name());
// }
// }
//
// public void setUrl(String url);
//
// public void setApiKey(Secret apiKey);
//
// public void setHostname(String hostname);
//
// public void setPort(int port);
//
// /**
// * Sends an event to the Datadog API, including the event payload.
// *
// * @param event - a DatadogEvent object
// * @return a boolean to signify the success or failure of the HTTP POST request.
// */
// public boolean event(DatadogEvent event);
//
// /**
// * Increment a counter for the given metrics.
// * NOTE: To submit all counters you need to execute the flushCounters method.
// * This is to aggregate counters and submit them in batch to Datadog in order to minimize network traffic.
// * @param name - metric name
// * @param hostname - metric hostname
// * @param tags - metric tags
// */
// public void incrementCounter(String name, String hostname, Map<String, Set<String>> tags);
//
// /**
// * Submit all your counters as rate with 10 seconds intervals.
// */
// public void flushCounters();
//
// /**
// * Sends a metric to the Datadog API, including the gauge name, and value.
// *
// * @param name - A String with the name of the metric to record.
// * @param value - A long containing the value to submit.
// * @param hostname - A String with the hostname to submit.
// * @param tags - A Map containing the tags to submit.
// * @return a boolean to signify the success or failure of the HTTP POST request.
// */
// public boolean gauge(String name, long value, String hostname, Map<String, Set<String>> tags);
//
// /**
// * Sends a service check to the Datadog API, including the check name, and status.
// *
// * @param name - A String with the name of the service check to record.
// * @param status - An Status with the status code to record for this service check.
// * @param hostname - A String with the hostname to submit.
// * @param tags - A Map containing the tags to submit.
// * @return a boolean to signify the success or failure of the HTTP POST request.
// */
// public boolean serviceCheck(String name, Status status, String hostname, Map<String, Set<String>> tags);
//
// /**
// * Tests the apiKey is valid.
// *
// * @return a boolean to signify the success or failure of the HTTP GET request.
// * @throws IOException if there is an input/output exception.
// * @throws ServletException if there is a servlet exception.
// */
// public boolean validate() throws IOException, ServletException;
// }
//
// Path: src/main/java/org/datadog/jenkins/plugins/datadog/clients/ClientFactory.java
// public class ClientFactory {
//
// public static DatadogClient getClient(DatadogClient.ClientType type, String apiUrl, Secret apiKey, String host, Integer port){
// switch(type){
// case HTTP:
// return DatadogHttpClient.getInstance(apiUrl, apiKey);
// case DSD:
// return DogStatsDClient.getInstance(host, port);
// default:
// return null;
// }
// }
//
// public static DatadogClient getClient() {
// DatadogGlobalConfiguration descriptor = DatadogUtilities.getDatadogGlobalDescriptor();
// return ClientFactory.getClient(DatadogClient.ClientType.valueOf(descriptor.getReportWith()),
// descriptor.getTargetApiURL(), descriptor.getTargetApiKey(),
// descriptor.getTargetHost(), descriptor.getTargetPort());
// }
// }
| import java.io.IOException;
import java.util.concurrent.TimeUnit;
import java.util.logging.Logger;
import hudson.Extension;
import hudson.model.*;
import org.datadog.jenkins.plugins.datadog.DatadogClient;
import org.datadog.jenkins.plugins.datadog.clients.ClientFactory; | /*
The MIT License
Copyright (c) 2015-Present Datadog, Inc <opensource@datadoghq.com>
All rights reserved.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
package org.datadog.jenkins.plugins.datadog.publishers;
@Extension
public class DatadogCountersPublisher extends AsyncPeriodicWork {
private static final Logger logger = Logger.getLogger(DatadogCountersPublisher.class.getName());
public DatadogCountersPublisher() {
super("Datadog Counters Publisher");
}
@Override
public long getRecurrencePeriod() {
return TimeUnit.SECONDS.toMillis(10);
}
@Override
protected void execute(TaskListener taskListener) throws IOException, InterruptedException {
try {
logger.fine("Execute called: Publishing counters");
// Get Datadog Client Instance | // Path: src/main/java/org/datadog/jenkins/plugins/datadog/DatadogClient.java
// public interface DatadogClient {
//
// public static enum ClientType {
// HTTP,
// DSD;
//
// private ClientType() { }
// }
//
// public static enum Status {
// OK(0),
// WARNING(1),
// CRITICAL(2),
// UNKNOWN(3);
//
// private final int val;
//
// private Status(int val) {
// this.val = val;
// }
//
// public int toValue(){
// return this.val;
// }
//
// public ServiceCheck.Status toServiceCheckStatus(){
// return ServiceCheck.Status.valueOf(this.name());
// }
// }
//
// public void setUrl(String url);
//
// public void setApiKey(Secret apiKey);
//
// public void setHostname(String hostname);
//
// public void setPort(int port);
//
// /**
// * Sends an event to the Datadog API, including the event payload.
// *
// * @param event - a DatadogEvent object
// * @return a boolean to signify the success or failure of the HTTP POST request.
// */
// public boolean event(DatadogEvent event);
//
// /**
// * Increment a counter for the given metrics.
// * NOTE: To submit all counters you need to execute the flushCounters method.
// * This is to aggregate counters and submit them in batch to Datadog in order to minimize network traffic.
// * @param name - metric name
// * @param hostname - metric hostname
// * @param tags - metric tags
// */
// public void incrementCounter(String name, String hostname, Map<String, Set<String>> tags);
//
// /**
// * Submit all your counters as rate with 10 seconds intervals.
// */
// public void flushCounters();
//
// /**
// * Sends a metric to the Datadog API, including the gauge name, and value.
// *
// * @param name - A String with the name of the metric to record.
// * @param value - A long containing the value to submit.
// * @param hostname - A String with the hostname to submit.
// * @param tags - A Map containing the tags to submit.
// * @return a boolean to signify the success or failure of the HTTP POST request.
// */
// public boolean gauge(String name, long value, String hostname, Map<String, Set<String>> tags);
//
// /**
// * Sends a service check to the Datadog API, including the check name, and status.
// *
// * @param name - A String with the name of the service check to record.
// * @param status - An Status with the status code to record for this service check.
// * @param hostname - A String with the hostname to submit.
// * @param tags - A Map containing the tags to submit.
// * @return a boolean to signify the success or failure of the HTTP POST request.
// */
// public boolean serviceCheck(String name, Status status, String hostname, Map<String, Set<String>> tags);
//
// /**
// * Tests the apiKey is valid.
// *
// * @return a boolean to signify the success or failure of the HTTP GET request.
// * @throws IOException if there is an input/output exception.
// * @throws ServletException if there is a servlet exception.
// */
// public boolean validate() throws IOException, ServletException;
// }
//
// Path: src/main/java/org/datadog/jenkins/plugins/datadog/clients/ClientFactory.java
// public class ClientFactory {
//
// public static DatadogClient getClient(DatadogClient.ClientType type, String apiUrl, Secret apiKey, String host, Integer port){
// switch(type){
// case HTTP:
// return DatadogHttpClient.getInstance(apiUrl, apiKey);
// case DSD:
// return DogStatsDClient.getInstance(host, port);
// default:
// return null;
// }
// }
//
// public static DatadogClient getClient() {
// DatadogGlobalConfiguration descriptor = DatadogUtilities.getDatadogGlobalDescriptor();
// return ClientFactory.getClient(DatadogClient.ClientType.valueOf(descriptor.getReportWith()),
// descriptor.getTargetApiURL(), descriptor.getTargetApiKey(),
// descriptor.getTargetHost(), descriptor.getTargetPort());
// }
// }
// Path: src/main/java/org/datadog/jenkins/plugins/datadog/publishers/DatadogCountersPublisher.java
import java.io.IOException;
import java.util.concurrent.TimeUnit;
import java.util.logging.Logger;
import hudson.Extension;
import hudson.model.*;
import org.datadog.jenkins.plugins.datadog.DatadogClient;
import org.datadog.jenkins.plugins.datadog.clients.ClientFactory;
/*
The MIT License
Copyright (c) 2015-Present Datadog, Inc <opensource@datadoghq.com>
All rights reserved.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
package org.datadog.jenkins.plugins.datadog.publishers;
@Extension
public class DatadogCountersPublisher extends AsyncPeriodicWork {
private static final Logger logger = Logger.getLogger(DatadogCountersPublisher.class.getName());
public DatadogCountersPublisher() {
super("Datadog Counters Publisher");
}
@Override
public long getRecurrencePeriod() {
return TimeUnit.SECONDS.toMillis(10);
}
@Override
protected void execute(TaskListener taskListener) throws IOException, InterruptedException {
try {
logger.fine("Execute called: Publishing counters");
// Get Datadog Client Instance | DatadogClient client = ClientFactory.getClient(); |
mariotaku/SQLiteQB | library/src/main/java/org/mariotaku/sqliteqb/library/Expression.java | // Path: library/src/main/java/org/mariotaku/sqliteqb/library/Columns.java
// public static class Column extends AbsColumn {
//
// private final String sql, alias;
//
// public Column(final String sql) {
// this(sql, null);
// }
//
// public Column(final String sql, final String alias) {
// this.sql = sql;
// this.alias = alias;
// }
//
// public Column(final SQLLang sql, final String alias) {
// this.sql = sql.getSQL();
// this.alias = alias;
// }
//
// public Column(final Table table, final String columnName) {
// this(table, columnName, null);
// }
//
// public Column(final Table table, final String columnName, final String alias) {
// this(table.getSQL() + "." + columnName, alias);
// }
//
// @Override
// public String getSQL() {
// if (alias == null) return sql;
// return sql + " AS " + alias;
// }
// }
| import org.mariotaku.sqliteqb.library.Columns.Column; | /*
* Copyright (c) 2015 mariotaku
*
* 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 org.mariotaku.sqliteqb.library;
public class Expression implements SQLLang {
private final String expr;
public Expression(final String expr) {
this.expr = expr;
}
public Expression(SQLLang lang) {
this(lang.getSQL());
}
public static Expression and(final Expression... expressions) {
return new Expression(toExpr(expressions, "AND"));
}
| // Path: library/src/main/java/org/mariotaku/sqliteqb/library/Columns.java
// public static class Column extends AbsColumn {
//
// private final String sql, alias;
//
// public Column(final String sql) {
// this(sql, null);
// }
//
// public Column(final String sql, final String alias) {
// this.sql = sql;
// this.alias = alias;
// }
//
// public Column(final SQLLang sql, final String alias) {
// this.sql = sql.getSQL();
// this.alias = alias;
// }
//
// public Column(final Table table, final String columnName) {
// this(table, columnName, null);
// }
//
// public Column(final Table table, final String columnName, final String alias) {
// this(table.getSQL() + "." + columnName, alias);
// }
//
// @Override
// public String getSQL() {
// if (alias == null) return sql;
// return sql + " AS " + alias;
// }
// }
// Path: library/src/main/java/org/mariotaku/sqliteqb/library/Expression.java
import org.mariotaku.sqliteqb.library.Columns.Column;
/*
* Copyright (c) 2015 mariotaku
*
* 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 org.mariotaku.sqliteqb.library;
public class Expression implements SQLLang {
private final String expr;
public Expression(final String expr) {
this.expr = expr;
}
public Expression(SQLLang lang) {
this(lang.getSQL());
}
public static Expression and(final Expression... expressions) {
return new Expression(toExpr(expressions, "AND"));
}
| public static Expression equals(final Column l, final Column r) { |
mariotaku/SQLiteQB | library/src/main/java/org/mariotaku/sqliteqb/library/query/SQLAlterTableQuery.java | // Path: library/src/main/java/org/mariotaku/sqliteqb/library/NewColumn.java
// public class NewColumn implements SQLLang {
//
// private final String name;
// private final String type;
//
// public NewColumn(final String name, final String type) {
// this.name = name;
// this.type = type;
// }
//
// public static NewColumn[] createNewColumns(final String[] colNames, final String[] colTypes) {
// if (colNames == null || colTypes == null || colNames.length != colTypes.length)
// throw new IllegalArgumentException("length of columns and types not match.");
// final NewColumn[] newColumns = new NewColumn[colNames.length];
// for (int i = 0, j = colNames.length; i < j; i++) {
// newColumns[i] = new NewColumn(colNames[i], colTypes[i]);
// }
// return newColumns;
// }
//
// public String getName() {
// return name;
// }
//
// @Override
// public String getSQL() {
// if (name == null || type == null)
// throw new NullPointerException("name and type must not be null!");
// return name + " " + type;
// }
//
// public String getType() {
// return type;
// }
//
// }
//
// Path: library/src/main/java/org/mariotaku/sqliteqb/library/SQLQuery.java
// public interface SQLQuery extends SQLLang {
// }
| import org.mariotaku.sqliteqb.library.NewColumn;
import org.mariotaku.sqliteqb.library.SQLQuery; | /*
* Copyright (c) 2015 mariotaku
*
* 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 org.mariotaku.sqliteqb.library.query;
public class SQLAlterTableQuery implements SQLQuery {
private String table;
private String renameTo; | // Path: library/src/main/java/org/mariotaku/sqliteqb/library/NewColumn.java
// public class NewColumn implements SQLLang {
//
// private final String name;
// private final String type;
//
// public NewColumn(final String name, final String type) {
// this.name = name;
// this.type = type;
// }
//
// public static NewColumn[] createNewColumns(final String[] colNames, final String[] colTypes) {
// if (colNames == null || colTypes == null || colNames.length != colTypes.length)
// throw new IllegalArgumentException("length of columns and types not match.");
// final NewColumn[] newColumns = new NewColumn[colNames.length];
// for (int i = 0, j = colNames.length; i < j; i++) {
// newColumns[i] = new NewColumn(colNames[i], colTypes[i]);
// }
// return newColumns;
// }
//
// public String getName() {
// return name;
// }
//
// @Override
// public String getSQL() {
// if (name == null || type == null)
// throw new NullPointerException("name and type must not be null!");
// return name + " " + type;
// }
//
// public String getType() {
// return type;
// }
//
// }
//
// Path: library/src/main/java/org/mariotaku/sqliteqb/library/SQLQuery.java
// public interface SQLQuery extends SQLLang {
// }
// Path: library/src/main/java/org/mariotaku/sqliteqb/library/query/SQLAlterTableQuery.java
import org.mariotaku.sqliteqb.library.NewColumn;
import org.mariotaku.sqliteqb.library.SQLQuery;
/*
* Copyright (c) 2015 mariotaku
*
* 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 org.mariotaku.sqliteqb.library.query;
public class SQLAlterTableQuery implements SQLQuery {
private String table;
private String renameTo; | private NewColumn addColumn; |
mariotaku/SQLiteQB | library/src/main/java/org/mariotaku/sqliteqb/library/query/SQLWithSelectQuery.java | // Path: library/src/main/java/org/mariotaku/sqliteqb/library/SQLLang.java
// public interface SQLLang extends Cloneable {
//
// /**
// * Build SQL query string
// *
// * @return SQL query
// */
// String getSQL();
// }
//
// Path: library/src/main/java/org/mariotaku/sqliteqb/library/Selectable.java
// public interface Selectable extends SQLLang {
//
// }
| import org.mariotaku.sqliteqb.library.SQLLang;
import org.mariotaku.sqliteqb.library.Selectable;
import java.util.ArrayList;
import java.util.List; | }
sb.append(cte.getSQL());
first = false;
}
sb.append(" ");
sb.append(select.getSQL());
return sb.toString();
}
private SQLSelectQuery select;
void setSelectQuery(SQLSelectQuery select) {
this.select = select;
}
public static class Builder extends SQLSelectQuery.Builder {
private final SQLWithSelectQuery internalQuery = new SQLWithSelectQuery();
@Override
public SQLWithSelectQuery build() {
internalQuery.setSelectQuery(super.build());
return internalQuery;
}
@Override
public String buildSQL() {
return build().getSQL();
}
| // Path: library/src/main/java/org/mariotaku/sqliteqb/library/SQLLang.java
// public interface SQLLang extends Cloneable {
//
// /**
// * Build SQL query string
// *
// * @return SQL query
// */
// String getSQL();
// }
//
// Path: library/src/main/java/org/mariotaku/sqliteqb/library/Selectable.java
// public interface Selectable extends SQLLang {
//
// }
// Path: library/src/main/java/org/mariotaku/sqliteqb/library/query/SQLWithSelectQuery.java
import org.mariotaku.sqliteqb.library.SQLLang;
import org.mariotaku.sqliteqb.library.Selectable;
import java.util.ArrayList;
import java.util.List;
}
sb.append(cte.getSQL());
first = false;
}
sb.append(" ");
sb.append(select.getSQL());
return sb.toString();
}
private SQLSelectQuery select;
void setSelectQuery(SQLSelectQuery select) {
this.select = select;
}
public static class Builder extends SQLSelectQuery.Builder {
private final SQLWithSelectQuery internalQuery = new SQLWithSelectQuery();
@Override
public SQLWithSelectQuery build() {
internalQuery.setSelectQuery(super.build());
return internalQuery;
}
@Override
public String buildSQL() {
return build().getSQL();
}
| public Builder with(String name, Selectable as) { |
mariotaku/SQLiteQB | library/src/main/java/org/mariotaku/sqliteqb/library/query/SQLWithSelectQuery.java | // Path: library/src/main/java/org/mariotaku/sqliteqb/library/SQLLang.java
// public interface SQLLang extends Cloneable {
//
// /**
// * Build SQL query string
// *
// * @return SQL query
// */
// String getSQL();
// }
//
// Path: library/src/main/java/org/mariotaku/sqliteqb/library/Selectable.java
// public interface Selectable extends SQLLang {
//
// }
| import org.mariotaku.sqliteqb.library.SQLLang;
import org.mariotaku.sqliteqb.library.Selectable;
import java.util.ArrayList;
import java.util.List; |
void setSelectQuery(SQLSelectQuery select) {
this.select = select;
}
public static class Builder extends SQLSelectQuery.Builder {
private final SQLWithSelectQuery internalQuery = new SQLWithSelectQuery();
@Override
public SQLWithSelectQuery build() {
internalQuery.setSelectQuery(super.build());
return internalQuery;
}
@Override
public String buildSQL() {
return build().getSQL();
}
public Builder with(String name, Selectable as) {
internalQuery.with(name, as);
return this;
}
}
private void with(String name, Selectable as) {
ctes.add(new CTE(name, as));
}
| // Path: library/src/main/java/org/mariotaku/sqliteqb/library/SQLLang.java
// public interface SQLLang extends Cloneable {
//
// /**
// * Build SQL query string
// *
// * @return SQL query
// */
// String getSQL();
// }
//
// Path: library/src/main/java/org/mariotaku/sqliteqb/library/Selectable.java
// public interface Selectable extends SQLLang {
//
// }
// Path: library/src/main/java/org/mariotaku/sqliteqb/library/query/SQLWithSelectQuery.java
import org.mariotaku.sqliteqb.library.SQLLang;
import org.mariotaku.sqliteqb.library.Selectable;
import java.util.ArrayList;
import java.util.List;
void setSelectQuery(SQLSelectQuery select) {
this.select = select;
}
public static class Builder extends SQLSelectQuery.Builder {
private final SQLWithSelectQuery internalQuery = new SQLWithSelectQuery();
@Override
public SQLWithSelectQuery build() {
internalQuery.setSelectQuery(super.build());
return internalQuery;
}
@Override
public String buildSQL() {
return build().getSQL();
}
public Builder with(String name, Selectable as) {
internalQuery.with(name, as);
return this;
}
}
private void with(String name, Selectable as) {
ctes.add(new CTE(name, as));
}
| static class CTE implements SQLLang { |
mariotaku/SQLiteQB | library/src/test/java/org/mariotaku/sqliteqb/library/ExpressionTest.java | // Path: library/src/main/java/org/mariotaku/sqliteqb/library/Columns.java
// public static class Column extends AbsColumn {
//
// private final String sql, alias;
//
// public Column(final String sql) {
// this(sql, null);
// }
//
// public Column(final String sql, final String alias) {
// this.sql = sql;
// this.alias = alias;
// }
//
// public Column(final SQLLang sql, final String alias) {
// this.sql = sql.getSQL();
// this.alias = alias;
// }
//
// public Column(final Table table, final String columnName) {
// this(table, columnName, null);
// }
//
// public Column(final Table table, final String columnName, final String alias) {
// this(table.getSQL() + "." + columnName, alias);
// }
//
// @Override
// public String getSQL() {
// if (alias == null) return sql;
// return sql + " AS " + alias;
// }
// }
| import org.junit.Before;
import org.junit.Test;
import org.mariotaku.sqliteqb.library.Columns.Column;
import static org.junit.Assert.assertEquals; | package org.mariotaku.sqliteqb.library;
/**
* Created by mariotaku on 16/2/3.
*/
public class ExpressionTest {
@Before
public void setUp() throws Exception {
}
@Test
public void testAnd() throws Exception {
}
@Test
public void testEquals() throws Exception { | // Path: library/src/main/java/org/mariotaku/sqliteqb/library/Columns.java
// public static class Column extends AbsColumn {
//
// private final String sql, alias;
//
// public Column(final String sql) {
// this(sql, null);
// }
//
// public Column(final String sql, final String alias) {
// this.sql = sql;
// this.alias = alias;
// }
//
// public Column(final SQLLang sql, final String alias) {
// this.sql = sql.getSQL();
// this.alias = alias;
// }
//
// public Column(final Table table, final String columnName) {
// this(table, columnName, null);
// }
//
// public Column(final Table table, final String columnName, final String alias) {
// this(table.getSQL() + "." + columnName, alias);
// }
//
// @Override
// public String getSQL() {
// if (alias == null) return sql;
// return sql + " AS " + alias;
// }
// }
// Path: library/src/test/java/org/mariotaku/sqliteqb/library/ExpressionTest.java
import org.junit.Before;
import org.junit.Test;
import org.mariotaku.sqliteqb.library.Columns.Column;
import static org.junit.Assert.assertEquals;
package org.mariotaku.sqliteqb.library;
/**
* Created by mariotaku on 16/2/3.
*/
public class ExpressionTest {
@Before
public void setUp() throws Exception {
}
@Test
public void testAnd() throws Exception {
}
@Test
public void testEquals() throws Exception { | assertEquals(Expression.equals(new Column("a"), new Column("b")).getSQL(), "a = b"); |
mariotaku/SQLiteQB | library/src/main/java/org/mariotaku/sqliteqb/library/query/SQLCreateTableQuery.java | // Path: library/src/main/java/org/mariotaku/sqliteqb/library/Constraint.java
// public class Constraint implements SQLLang {
// private final String name;
// private final String type;
// private final SQLQuery constraint;
//
// public Constraint(String name, String type, SQLQuery constraint) {
// this.name = name;
// this.type = type;
// this.constraint = constraint;
// }
//
// @Override
// public String getSQL() {
// final StringBuilder sb = new StringBuilder();
// if (name != null) {
// sb.append("CONSTRAINT ");
// sb.append(name);
// sb.append(" ");
// }
// sb.append(type);
// sb.append(" ");
// sb.append(constraint.getSQL());
// return sb.toString();
// }
//
// public static Constraint unique(String name, Columns columns, OnConflict onConflict) {
// return new Constraint(name, "UNIQUE", new ColumnConflictConstaint(columns, onConflict));
// }
//
// public static Constraint unique(Columns columns, OnConflict onConflict) {
// return unique(null, columns, onConflict);
// }
//
// private static final class ColumnConflictConstaint implements SQLQuery {
//
// private final Columns columns;
// private final OnConflict onConflict;
//
// public ColumnConflictConstaint(Columns columns, OnConflict onConflict) {
// this.columns = columns;
// this.onConflict = onConflict;
// }
//
// @Override
// public String getSQL() {
// final StringBuilder sb = new StringBuilder();
// sb.append("(");
// sb.append(columns.getSQL());
// sb.append(") ");
// sb.append("ON CONFLICT ");
// sb.append(onConflict.getAction());
// return sb.toString();
// }
// }
//
// }
//
// Path: library/src/main/java/org/mariotaku/sqliteqb/library/NewColumn.java
// public class NewColumn implements SQLLang {
//
// private final String name;
// private final String type;
//
// public NewColumn(final String name, final String type) {
// this.name = name;
// this.type = type;
// }
//
// public static NewColumn[] createNewColumns(final String[] colNames, final String[] colTypes) {
// if (colNames == null || colTypes == null || colNames.length != colTypes.length)
// throw new IllegalArgumentException("length of columns and types not match.");
// final NewColumn[] newColumns = new NewColumn[colNames.length];
// for (int i = 0, j = colNames.length; i < j; i++) {
// newColumns[i] = new NewColumn(colNames[i], colTypes[i]);
// }
// return newColumns;
// }
//
// public String getName() {
// return name;
// }
//
// @Override
// public String getSQL() {
// if (name == null || type == null)
// throw new NullPointerException("name and type must not be null!");
// return name + " " + type;
// }
//
// public String getType() {
// return type;
// }
//
// }
//
// Path: library/src/main/java/org/mariotaku/sqliteqb/library/SQLQuery.java
// public interface SQLQuery extends SQLLang {
// }
//
// Path: library/src/main/java/org/mariotaku/sqliteqb/library/Utils.java
// public class Utils {
//
// public static String toString(final Object[] array, final char token, final boolean includeSpace) {
// final StringBuilder builder = new StringBuilder();
// final int length = array.length;
// for (int i = 0; i < length; i++) {
// final String string = objectToString(array[i]);
// if (string != null) {
// if (i > 0) {
// builder.append(includeSpace ? token + " " : token);
// }
// builder.append(string);
// }
// }
// return builder.toString();
// }
//
// public static String toStringForSQL(final int size) {
// final StringBuilder builder = new StringBuilder();
// for (int i = 0; i < size; i++) {
// if (i > 0) {
// builder.append(',');
// }
// builder.append('?');
// }
// return builder.toString();
// }
//
// private static String objectToString(Object o) {
// if (o instanceof SQLLang)
// return ((SQLLang) o).getSQL();
// return o != null ? o.toString() : null;
// }
//
// public static String[] toStringArray(Object[] array) {
// final String[] strings = new String[array.length];
// final int length = array.length;
// for (int i = 0; i < length; i++) {
// strings[i] = objectToString(array[i]);
// }
// return strings;
// }
// }
| import org.mariotaku.sqliteqb.library.Constraint;
import org.mariotaku.sqliteqb.library.NewColumn;
import org.mariotaku.sqliteqb.library.SQLQuery;
import org.mariotaku.sqliteqb.library.Utils; | /*
* Copyright (c) 2015 mariotaku
*
* 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 org.mariotaku.sqliteqb.library.query;
public class SQLCreateTableQuery implements SQLQuery {
private boolean temporary;
private boolean createIfNotExists;
private String table; | // Path: library/src/main/java/org/mariotaku/sqliteqb/library/Constraint.java
// public class Constraint implements SQLLang {
// private final String name;
// private final String type;
// private final SQLQuery constraint;
//
// public Constraint(String name, String type, SQLQuery constraint) {
// this.name = name;
// this.type = type;
// this.constraint = constraint;
// }
//
// @Override
// public String getSQL() {
// final StringBuilder sb = new StringBuilder();
// if (name != null) {
// sb.append("CONSTRAINT ");
// sb.append(name);
// sb.append(" ");
// }
// sb.append(type);
// sb.append(" ");
// sb.append(constraint.getSQL());
// return sb.toString();
// }
//
// public static Constraint unique(String name, Columns columns, OnConflict onConflict) {
// return new Constraint(name, "UNIQUE", new ColumnConflictConstaint(columns, onConflict));
// }
//
// public static Constraint unique(Columns columns, OnConflict onConflict) {
// return unique(null, columns, onConflict);
// }
//
// private static final class ColumnConflictConstaint implements SQLQuery {
//
// private final Columns columns;
// private final OnConflict onConflict;
//
// public ColumnConflictConstaint(Columns columns, OnConflict onConflict) {
// this.columns = columns;
// this.onConflict = onConflict;
// }
//
// @Override
// public String getSQL() {
// final StringBuilder sb = new StringBuilder();
// sb.append("(");
// sb.append(columns.getSQL());
// sb.append(") ");
// sb.append("ON CONFLICT ");
// sb.append(onConflict.getAction());
// return sb.toString();
// }
// }
//
// }
//
// Path: library/src/main/java/org/mariotaku/sqliteqb/library/NewColumn.java
// public class NewColumn implements SQLLang {
//
// private final String name;
// private final String type;
//
// public NewColumn(final String name, final String type) {
// this.name = name;
// this.type = type;
// }
//
// public static NewColumn[] createNewColumns(final String[] colNames, final String[] colTypes) {
// if (colNames == null || colTypes == null || colNames.length != colTypes.length)
// throw new IllegalArgumentException("length of columns and types not match.");
// final NewColumn[] newColumns = new NewColumn[colNames.length];
// for (int i = 0, j = colNames.length; i < j; i++) {
// newColumns[i] = new NewColumn(colNames[i], colTypes[i]);
// }
// return newColumns;
// }
//
// public String getName() {
// return name;
// }
//
// @Override
// public String getSQL() {
// if (name == null || type == null)
// throw new NullPointerException("name and type must not be null!");
// return name + " " + type;
// }
//
// public String getType() {
// return type;
// }
//
// }
//
// Path: library/src/main/java/org/mariotaku/sqliteqb/library/SQLQuery.java
// public interface SQLQuery extends SQLLang {
// }
//
// Path: library/src/main/java/org/mariotaku/sqliteqb/library/Utils.java
// public class Utils {
//
// public static String toString(final Object[] array, final char token, final boolean includeSpace) {
// final StringBuilder builder = new StringBuilder();
// final int length = array.length;
// for (int i = 0; i < length; i++) {
// final String string = objectToString(array[i]);
// if (string != null) {
// if (i > 0) {
// builder.append(includeSpace ? token + " " : token);
// }
// builder.append(string);
// }
// }
// return builder.toString();
// }
//
// public static String toStringForSQL(final int size) {
// final StringBuilder builder = new StringBuilder();
// for (int i = 0; i < size; i++) {
// if (i > 0) {
// builder.append(',');
// }
// builder.append('?');
// }
// return builder.toString();
// }
//
// private static String objectToString(Object o) {
// if (o instanceof SQLLang)
// return ((SQLLang) o).getSQL();
// return o != null ? o.toString() : null;
// }
//
// public static String[] toStringArray(Object[] array) {
// final String[] strings = new String[array.length];
// final int length = array.length;
// for (int i = 0; i < length; i++) {
// strings[i] = objectToString(array[i]);
// }
// return strings;
// }
// }
// Path: library/src/main/java/org/mariotaku/sqliteqb/library/query/SQLCreateTableQuery.java
import org.mariotaku.sqliteqb.library.Constraint;
import org.mariotaku.sqliteqb.library.NewColumn;
import org.mariotaku.sqliteqb.library.SQLQuery;
import org.mariotaku.sqliteqb.library.Utils;
/*
* Copyright (c) 2015 mariotaku
*
* 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 org.mariotaku.sqliteqb.library.query;
public class SQLCreateTableQuery implements SQLQuery {
private boolean temporary;
private boolean createIfNotExists;
private String table; | private NewColumn[] newColumns; |
mariotaku/SQLiteQB | library/src/main/java/org/mariotaku/sqliteqb/library/query/SQLCreateTableQuery.java | // Path: library/src/main/java/org/mariotaku/sqliteqb/library/Constraint.java
// public class Constraint implements SQLLang {
// private final String name;
// private final String type;
// private final SQLQuery constraint;
//
// public Constraint(String name, String type, SQLQuery constraint) {
// this.name = name;
// this.type = type;
// this.constraint = constraint;
// }
//
// @Override
// public String getSQL() {
// final StringBuilder sb = new StringBuilder();
// if (name != null) {
// sb.append("CONSTRAINT ");
// sb.append(name);
// sb.append(" ");
// }
// sb.append(type);
// sb.append(" ");
// sb.append(constraint.getSQL());
// return sb.toString();
// }
//
// public static Constraint unique(String name, Columns columns, OnConflict onConflict) {
// return new Constraint(name, "UNIQUE", new ColumnConflictConstaint(columns, onConflict));
// }
//
// public static Constraint unique(Columns columns, OnConflict onConflict) {
// return unique(null, columns, onConflict);
// }
//
// private static final class ColumnConflictConstaint implements SQLQuery {
//
// private final Columns columns;
// private final OnConflict onConflict;
//
// public ColumnConflictConstaint(Columns columns, OnConflict onConflict) {
// this.columns = columns;
// this.onConflict = onConflict;
// }
//
// @Override
// public String getSQL() {
// final StringBuilder sb = new StringBuilder();
// sb.append("(");
// sb.append(columns.getSQL());
// sb.append(") ");
// sb.append("ON CONFLICT ");
// sb.append(onConflict.getAction());
// return sb.toString();
// }
// }
//
// }
//
// Path: library/src/main/java/org/mariotaku/sqliteqb/library/NewColumn.java
// public class NewColumn implements SQLLang {
//
// private final String name;
// private final String type;
//
// public NewColumn(final String name, final String type) {
// this.name = name;
// this.type = type;
// }
//
// public static NewColumn[] createNewColumns(final String[] colNames, final String[] colTypes) {
// if (colNames == null || colTypes == null || colNames.length != colTypes.length)
// throw new IllegalArgumentException("length of columns and types not match.");
// final NewColumn[] newColumns = new NewColumn[colNames.length];
// for (int i = 0, j = colNames.length; i < j; i++) {
// newColumns[i] = new NewColumn(colNames[i], colTypes[i]);
// }
// return newColumns;
// }
//
// public String getName() {
// return name;
// }
//
// @Override
// public String getSQL() {
// if (name == null || type == null)
// throw new NullPointerException("name and type must not be null!");
// return name + " " + type;
// }
//
// public String getType() {
// return type;
// }
//
// }
//
// Path: library/src/main/java/org/mariotaku/sqliteqb/library/SQLQuery.java
// public interface SQLQuery extends SQLLang {
// }
//
// Path: library/src/main/java/org/mariotaku/sqliteqb/library/Utils.java
// public class Utils {
//
// public static String toString(final Object[] array, final char token, final boolean includeSpace) {
// final StringBuilder builder = new StringBuilder();
// final int length = array.length;
// for (int i = 0; i < length; i++) {
// final String string = objectToString(array[i]);
// if (string != null) {
// if (i > 0) {
// builder.append(includeSpace ? token + " " : token);
// }
// builder.append(string);
// }
// }
// return builder.toString();
// }
//
// public static String toStringForSQL(final int size) {
// final StringBuilder builder = new StringBuilder();
// for (int i = 0; i < size; i++) {
// if (i > 0) {
// builder.append(',');
// }
// builder.append('?');
// }
// return builder.toString();
// }
//
// private static String objectToString(Object o) {
// if (o instanceof SQLLang)
// return ((SQLLang) o).getSQL();
// return o != null ? o.toString() : null;
// }
//
// public static String[] toStringArray(Object[] array) {
// final String[] strings = new String[array.length];
// final int length = array.length;
// for (int i = 0; i < length; i++) {
// strings[i] = objectToString(array[i]);
// }
// return strings;
// }
// }
| import org.mariotaku.sqliteqb.library.Constraint;
import org.mariotaku.sqliteqb.library.NewColumn;
import org.mariotaku.sqliteqb.library.SQLQuery;
import org.mariotaku.sqliteqb.library.Utils; | /*
* Copyright (c) 2015 mariotaku
*
* 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 org.mariotaku.sqliteqb.library.query;
public class SQLCreateTableQuery implements SQLQuery {
private boolean temporary;
private boolean createIfNotExists;
private String table;
private NewColumn[] newColumns;
private SQLSelectQuery selectStmt; | // Path: library/src/main/java/org/mariotaku/sqliteqb/library/Constraint.java
// public class Constraint implements SQLLang {
// private final String name;
// private final String type;
// private final SQLQuery constraint;
//
// public Constraint(String name, String type, SQLQuery constraint) {
// this.name = name;
// this.type = type;
// this.constraint = constraint;
// }
//
// @Override
// public String getSQL() {
// final StringBuilder sb = new StringBuilder();
// if (name != null) {
// sb.append("CONSTRAINT ");
// sb.append(name);
// sb.append(" ");
// }
// sb.append(type);
// sb.append(" ");
// sb.append(constraint.getSQL());
// return sb.toString();
// }
//
// public static Constraint unique(String name, Columns columns, OnConflict onConflict) {
// return new Constraint(name, "UNIQUE", new ColumnConflictConstaint(columns, onConflict));
// }
//
// public static Constraint unique(Columns columns, OnConflict onConflict) {
// return unique(null, columns, onConflict);
// }
//
// private static final class ColumnConflictConstaint implements SQLQuery {
//
// private final Columns columns;
// private final OnConflict onConflict;
//
// public ColumnConflictConstaint(Columns columns, OnConflict onConflict) {
// this.columns = columns;
// this.onConflict = onConflict;
// }
//
// @Override
// public String getSQL() {
// final StringBuilder sb = new StringBuilder();
// sb.append("(");
// sb.append(columns.getSQL());
// sb.append(") ");
// sb.append("ON CONFLICT ");
// sb.append(onConflict.getAction());
// return sb.toString();
// }
// }
//
// }
//
// Path: library/src/main/java/org/mariotaku/sqliteqb/library/NewColumn.java
// public class NewColumn implements SQLLang {
//
// private final String name;
// private final String type;
//
// public NewColumn(final String name, final String type) {
// this.name = name;
// this.type = type;
// }
//
// public static NewColumn[] createNewColumns(final String[] colNames, final String[] colTypes) {
// if (colNames == null || colTypes == null || colNames.length != colTypes.length)
// throw new IllegalArgumentException("length of columns and types not match.");
// final NewColumn[] newColumns = new NewColumn[colNames.length];
// for (int i = 0, j = colNames.length; i < j; i++) {
// newColumns[i] = new NewColumn(colNames[i], colTypes[i]);
// }
// return newColumns;
// }
//
// public String getName() {
// return name;
// }
//
// @Override
// public String getSQL() {
// if (name == null || type == null)
// throw new NullPointerException("name and type must not be null!");
// return name + " " + type;
// }
//
// public String getType() {
// return type;
// }
//
// }
//
// Path: library/src/main/java/org/mariotaku/sqliteqb/library/SQLQuery.java
// public interface SQLQuery extends SQLLang {
// }
//
// Path: library/src/main/java/org/mariotaku/sqliteqb/library/Utils.java
// public class Utils {
//
// public static String toString(final Object[] array, final char token, final boolean includeSpace) {
// final StringBuilder builder = new StringBuilder();
// final int length = array.length;
// for (int i = 0; i < length; i++) {
// final String string = objectToString(array[i]);
// if (string != null) {
// if (i > 0) {
// builder.append(includeSpace ? token + " " : token);
// }
// builder.append(string);
// }
// }
// return builder.toString();
// }
//
// public static String toStringForSQL(final int size) {
// final StringBuilder builder = new StringBuilder();
// for (int i = 0; i < size; i++) {
// if (i > 0) {
// builder.append(',');
// }
// builder.append('?');
// }
// return builder.toString();
// }
//
// private static String objectToString(Object o) {
// if (o instanceof SQLLang)
// return ((SQLLang) o).getSQL();
// return o != null ? o.toString() : null;
// }
//
// public static String[] toStringArray(Object[] array) {
// final String[] strings = new String[array.length];
// final int length = array.length;
// for (int i = 0; i < length; i++) {
// strings[i] = objectToString(array[i]);
// }
// return strings;
// }
// }
// Path: library/src/main/java/org/mariotaku/sqliteqb/library/query/SQLCreateTableQuery.java
import org.mariotaku.sqliteqb.library.Constraint;
import org.mariotaku.sqliteqb.library.NewColumn;
import org.mariotaku.sqliteqb.library.SQLQuery;
import org.mariotaku.sqliteqb.library.Utils;
/*
* Copyright (c) 2015 mariotaku
*
* 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 org.mariotaku.sqliteqb.library.query;
public class SQLCreateTableQuery implements SQLQuery {
private boolean temporary;
private boolean createIfNotExists;
private String table;
private NewColumn[] newColumns;
private SQLSelectQuery selectStmt; | private Constraint[] constraints; |
mariotaku/SQLiteQB | library/src/main/java/org/mariotaku/sqliteqb/library/query/SQLInsertQuery.java | // Path: library/src/main/java/org/mariotaku/sqliteqb/library/OnConflict.java
// public enum OnConflict {
// ROLLBACK("ROLLBACK"), ABORT("ABORT"), REPLACE("REPLACE"), FAIL("FAIL"), IGNORE("IGNORE");
// private final String action;
//
// OnConflict(final String action) {
// this.action = action;
// }
//
// public String getAction() {
// return action;
// }
// }
//
// Path: library/src/main/java/org/mariotaku/sqliteqb/library/SQLQuery.java
// public interface SQLQuery extends SQLLang {
// }
//
// Path: library/src/main/java/org/mariotaku/sqliteqb/library/Utils.java
// public class Utils {
//
// public static String toString(final Object[] array, final char token, final boolean includeSpace) {
// final StringBuilder builder = new StringBuilder();
// final int length = array.length;
// for (int i = 0; i < length; i++) {
// final String string = objectToString(array[i]);
// if (string != null) {
// if (i > 0) {
// builder.append(includeSpace ? token + " " : token);
// }
// builder.append(string);
// }
// }
// return builder.toString();
// }
//
// public static String toStringForSQL(final int size) {
// final StringBuilder builder = new StringBuilder();
// for (int i = 0; i < size; i++) {
// if (i > 0) {
// builder.append(',');
// }
// builder.append('?');
// }
// return builder.toString();
// }
//
// private static String objectToString(Object o) {
// if (o instanceof SQLLang)
// return ((SQLLang) o).getSQL();
// return o != null ? o.toString() : null;
// }
//
// public static String[] toStringArray(Object[] array) {
// final String[] strings = new String[array.length];
// final int length = array.length;
// for (int i = 0; i < length; i++) {
// strings[i] = objectToString(array[i]);
// }
// return strings;
// }
// }
| import org.mariotaku.sqliteqb.library.OnConflict;
import org.mariotaku.sqliteqb.library.SQLQuery;
import org.mariotaku.sqliteqb.library.Utils; | /*
* Copyright (c) 2015 mariotaku
*
* 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 org.mariotaku.sqliteqb.library.query;
public class SQLInsertQuery implements SQLQuery {
private OnConflict onConflict;
private String table;
private String[] columns;
private String values;
SQLInsertQuery() {
}
@Override
public String getSQL() {
if (table == null) throw new NullPointerException("table must not be null!");
final StringBuilder sb = new StringBuilder();
sb.append("INSERT ");
if (onConflict != null) {
sb.append("OR ");
sb.append(onConflict.getAction());
sb.append(" ");
}
sb.append("INTO ");
sb.append(table);
sb.append(" ("); | // Path: library/src/main/java/org/mariotaku/sqliteqb/library/OnConflict.java
// public enum OnConflict {
// ROLLBACK("ROLLBACK"), ABORT("ABORT"), REPLACE("REPLACE"), FAIL("FAIL"), IGNORE("IGNORE");
// private final String action;
//
// OnConflict(final String action) {
// this.action = action;
// }
//
// public String getAction() {
// return action;
// }
// }
//
// Path: library/src/main/java/org/mariotaku/sqliteqb/library/SQLQuery.java
// public interface SQLQuery extends SQLLang {
// }
//
// Path: library/src/main/java/org/mariotaku/sqliteqb/library/Utils.java
// public class Utils {
//
// public static String toString(final Object[] array, final char token, final boolean includeSpace) {
// final StringBuilder builder = new StringBuilder();
// final int length = array.length;
// for (int i = 0; i < length; i++) {
// final String string = objectToString(array[i]);
// if (string != null) {
// if (i > 0) {
// builder.append(includeSpace ? token + " " : token);
// }
// builder.append(string);
// }
// }
// return builder.toString();
// }
//
// public static String toStringForSQL(final int size) {
// final StringBuilder builder = new StringBuilder();
// for (int i = 0; i < size; i++) {
// if (i > 0) {
// builder.append(',');
// }
// builder.append('?');
// }
// return builder.toString();
// }
//
// private static String objectToString(Object o) {
// if (o instanceof SQLLang)
// return ((SQLLang) o).getSQL();
// return o != null ? o.toString() : null;
// }
//
// public static String[] toStringArray(Object[] array) {
// final String[] strings = new String[array.length];
// final int length = array.length;
// for (int i = 0; i < length; i++) {
// strings[i] = objectToString(array[i]);
// }
// return strings;
// }
// }
// Path: library/src/main/java/org/mariotaku/sqliteqb/library/query/SQLInsertQuery.java
import org.mariotaku.sqliteqb.library.OnConflict;
import org.mariotaku.sqliteqb.library.SQLQuery;
import org.mariotaku.sqliteqb.library.Utils;
/*
* Copyright (c) 2015 mariotaku
*
* 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 org.mariotaku.sqliteqb.library.query;
public class SQLInsertQuery implements SQLQuery {
private OnConflict onConflict;
private String table;
private String[] columns;
private String values;
SQLInsertQuery() {
}
@Override
public String getSQL() {
if (table == null) throw new NullPointerException("table must not be null!");
final StringBuilder sb = new StringBuilder();
sb.append("INSERT ");
if (onConflict != null) {
sb.append("OR ");
sb.append(onConflict.getAction());
sb.append(" ");
}
sb.append("INTO ");
sb.append(table);
sb.append(" ("); | sb.append(Utils.toString(columns, ',', true)); |
algolia/algoliasearch-client-android | algoliasearch/src/main/java/com/algolia/search/saas/AbstractClient.java | // Path: algoliasearch/src/main/java/com/algolia/search/saas/helpers/HandlerExecutor.java
// public class HandlerExecutor implements Executor {
// /** Handler wrapped by this executor. */
// private Handler handler;
//
// /**
// * Construct a new executor wrapping the specified handler.
// *
// * @param handler Handler to wrap.
// */
// public HandlerExecutor(@NonNull Handler handler) {
// this.handler = handler;
// }
//
// /**
// * Execute a command, by posting it to the underlying handler.
// *
// * @param command Command to execute.
// */
// public void execute(Runnable command) {
// handler.post(command);
// }
// }
| import android.os.Build;
import android.os.Handler;
import android.os.Looper;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import com.algolia.search.saas.android.BuildConfig;
import com.algolia.search.saas.helpers.HandlerExecutor;
import org.json.JSONException;
import org.json.JSONObject;
import org.json.JSONTokener;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.UnsupportedEncodingException;
import java.lang.ref.WeakReference;
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.Executor;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.zip.GZIPInputStream; | private List<LibraryVersion> userAgents = new ArrayList<>();
/** Connect timeout (ms). */
private int connectTimeout = 2000;
/** Default read (receive) timeout (ms). */
private int readTimeout = 30000;
/** Read timeout for search requests (ms). */
private int searchTimeout = 5000;
/** Delay to wait when a host is down before retrying it (ms). */
private int hostDownDelay = 5000;
private final String applicationID;
private final String apiKey;
private List<String> readHosts;
private List<String> writeHosts;
private HashMap<String, HostStatus> hostStatuses = new HashMap<>();
/**
* HTTP headers that will be sent with every request.
*/
private HashMap<String, String> headers = new HashMap<String, String>();
/** Thread pool used to run asynchronous requests. */
protected ExecutorService searchExecutorService = Executors.newFixedThreadPool(4);
/** Executor used to run completion handlers. By default, runs on the main thread. */
protected @NonNull | // Path: algoliasearch/src/main/java/com/algolia/search/saas/helpers/HandlerExecutor.java
// public class HandlerExecutor implements Executor {
// /** Handler wrapped by this executor. */
// private Handler handler;
//
// /**
// * Construct a new executor wrapping the specified handler.
// *
// * @param handler Handler to wrap.
// */
// public HandlerExecutor(@NonNull Handler handler) {
// this.handler = handler;
// }
//
// /**
// * Execute a command, by posting it to the underlying handler.
// *
// * @param command Command to execute.
// */
// public void execute(Runnable command) {
// handler.post(command);
// }
// }
// Path: algoliasearch/src/main/java/com/algolia/search/saas/AbstractClient.java
import android.os.Build;
import android.os.Handler;
import android.os.Looper;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import com.algolia.search.saas.android.BuildConfig;
import com.algolia.search.saas.helpers.HandlerExecutor;
import org.json.JSONException;
import org.json.JSONObject;
import org.json.JSONTokener;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.UnsupportedEncodingException;
import java.lang.ref.WeakReference;
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.Executor;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.zip.GZIPInputStream;
private List<LibraryVersion> userAgents = new ArrayList<>();
/** Connect timeout (ms). */
private int connectTimeout = 2000;
/** Default read (receive) timeout (ms). */
private int readTimeout = 30000;
/** Read timeout for search requests (ms). */
private int searchTimeout = 5000;
/** Delay to wait when a host is down before retrying it (ms). */
private int hostDownDelay = 5000;
private final String applicationID;
private final String apiKey;
private List<String> readHosts;
private List<String> writeHosts;
private HashMap<String, HostStatus> hostStatuses = new HashMap<>();
/**
* HTTP headers that will be sent with every request.
*/
private HashMap<String, String> headers = new HashMap<String, String>();
/** Thread pool used to run asynchronous requests. */
protected ExecutorService searchExecutorService = Executors.newFixedThreadPool(4);
/** Executor used to run completion handlers. By default, runs on the main thread. */
protected @NonNull | Executor completionExecutor = new HandlerExecutor(new Handler(Looper.getMainLooper())); |
algolia/algoliasearch-client-android | algoliasearch/src/test/java/com/algolia/search/saas/BrowseIteratorTest.java | // Path: algoliasearch/src/main/java/com/algolia/search/saas/helpers/BrowseIterator.java
// public class BrowseIterator {
//
// /**
// * Listener for {@link com.algolia.search.saas.helpers.BrowseIterator}.
// */
// public interface BrowseIteratorHandler {
// /**
// * Called at each batch of results.
// *
// * @param iterator The iterator where the results originate from.
// * @param result The results (in case of success).
// * @param error The error (in case of error).
// */
// void handleBatch(@NonNull BrowseIterator iterator, JSONObject result, AlgoliaException error);
// }
//
// /** The index being browsed. */
// private Index index;
//
// /** The query used to filter the results. */
// private Query query;
//
// /** Listener. */
// private BrowseIteratorHandler handler;
//
// /** Eventual request-specific options */
// private @Nullable RequestOptions requestOptions;
//
// /** Cursor to use for the next call, if any. */
// private String cursor;
//
// /** Whether the iteration has already started. */
// private transient boolean started = false;
//
// /** Whether the iteration has been cancelled by the user. */
// private transient boolean cancelled = false;
//
// /** The currently ongoing request, if any. */
// private Request request;
//
// /**
// * Construct a new browse iterator.
// * NOTE: The iteration does not start automatically. You have to call `start()` explicitly.
// *
// * @param index The index to be browsed.
// * @param query The query used to filter the results.
// * @param handler Handler called for each batch of results.
// */
// public BrowseIterator(@NonNull Index index, @NonNull Query query, @NonNull BrowseIteratorHandler handler) {
// this(index, query, null, handler);
// }
//
// /**
// * Construct a new browse iterator.
// * NOTE: The iteration does not start automatically. You have to call `start()` explicitly.
// *
// * @param index The index to be browsed.
// * @param query The query used to filter the results.
// * @param requestOptions Request-specific options.
// * @param handler Handler called for each batch of results.
// */
// public BrowseIterator(@NonNull Index index, @NonNull Query query, @Nullable RequestOptions requestOptions, @NonNull BrowseIteratorHandler handler) {
// this.index = index;
// this.query = query;
// this.handler = handler;
// this.requestOptions = requestOptions;
// }
//
// /**
// * Start the iteration.
// */
// public void start() {
// if (started) {
// throw new IllegalStateException();
// }
// started = true;
// request = index.browseAsync(query, requestOptions, completionHandler);
// }
//
// /**
// * Cancel the iteration.
// * This cancels any currently ongoing request, and cancels the iteration.
// * The listener will not be called after the iteration has been cancelled.
// */
// public void cancel() {
// if (cancelled) {
// return;
// }
// request.cancel();
// request = null;
// cancelled = true;
// }
//
// /**
// * Determine if there is more content to be browsed.
// * WARNING: Can only be called from the handler, once the iteration has started.
// */
// public boolean hasNext() {
// if (!started) {
// throw new IllegalStateException();
// }
// return cursor != null;
// }
//
// private void next() {
// if (!hasNext()) {
// throw new IllegalStateException();
// }
// request = index.browseFromAsync(cursor, requestOptions, completionHandler);
// }
//
// private CompletionHandler completionHandler = new CompletionHandler() {
// @Override
// public void requestCompleted(JSONObject content, AlgoliaException error) {
// if (!cancelled) {
// handler.handleBatch(BrowseIterator.this, content, error);
// if (error == null) {
// cursor = content.optString("cursor", null);
// if (!cancelled && hasNext()) {
// next();
// }
// }
// }
// }
// };
// }
| import org.mockito.internal.util.reflection.Whitebox;
import org.robolectric.android.util.concurrent.RoboExecutorService;
import java.util.ArrayList;
import java.util.List;
import static junit.framework.Assert.fail;
import android.support.annotation.NonNull;
import com.algolia.search.saas.helpers.BrowseIterator;
import org.json.JSONArray;
import org.json.JSONObject;
import org.junit.Test; | // WARNING: Robolectric cannot work with custom executors in `AsyncTask`, so we substitute the client's
// executor with a Robolectric-compliant one.
Whitebox.setInternalState(client, "searchExecutorService", new RoboExecutorService());
indexName = Helpers.safeIndexName("àlgol?à-android");
index = client.initIndex(indexName);
objects = new ArrayList<JSONObject>();
for (int i = 0; i < 1500; ++i) {
objects.add(new JSONObject(String.format("{\"dummy\": %d}", i)));
}
JSONObject task = index.addObjects(new JSONArray(objects), /* requestOptions: */ null);
index.waitTask(task.getString("taskID"));
JSONArray objectIDs = task.getJSONArray("objectIDs");
ids = new ArrayList<String>();
for (int i = 0; i < objectIDs.length(); ++i) {
ids.add(objectIDs.getString(i));
}
}
@Override
public void tearDown() throws Exception {
client.deleteIndex(indexName, /* requestOptions: */ null);
}
@Test
public void nominal() throws Exception {
Query query = new Query();
AssertBrowseHandler handler = new AssertBrowseHandler() {
@Override | // Path: algoliasearch/src/main/java/com/algolia/search/saas/helpers/BrowseIterator.java
// public class BrowseIterator {
//
// /**
// * Listener for {@link com.algolia.search.saas.helpers.BrowseIterator}.
// */
// public interface BrowseIteratorHandler {
// /**
// * Called at each batch of results.
// *
// * @param iterator The iterator where the results originate from.
// * @param result The results (in case of success).
// * @param error The error (in case of error).
// */
// void handleBatch(@NonNull BrowseIterator iterator, JSONObject result, AlgoliaException error);
// }
//
// /** The index being browsed. */
// private Index index;
//
// /** The query used to filter the results. */
// private Query query;
//
// /** Listener. */
// private BrowseIteratorHandler handler;
//
// /** Eventual request-specific options */
// private @Nullable RequestOptions requestOptions;
//
// /** Cursor to use for the next call, if any. */
// private String cursor;
//
// /** Whether the iteration has already started. */
// private transient boolean started = false;
//
// /** Whether the iteration has been cancelled by the user. */
// private transient boolean cancelled = false;
//
// /** The currently ongoing request, if any. */
// private Request request;
//
// /**
// * Construct a new browse iterator.
// * NOTE: The iteration does not start automatically. You have to call `start()` explicitly.
// *
// * @param index The index to be browsed.
// * @param query The query used to filter the results.
// * @param handler Handler called for each batch of results.
// */
// public BrowseIterator(@NonNull Index index, @NonNull Query query, @NonNull BrowseIteratorHandler handler) {
// this(index, query, null, handler);
// }
//
// /**
// * Construct a new browse iterator.
// * NOTE: The iteration does not start automatically. You have to call `start()` explicitly.
// *
// * @param index The index to be browsed.
// * @param query The query used to filter the results.
// * @param requestOptions Request-specific options.
// * @param handler Handler called for each batch of results.
// */
// public BrowseIterator(@NonNull Index index, @NonNull Query query, @Nullable RequestOptions requestOptions, @NonNull BrowseIteratorHandler handler) {
// this.index = index;
// this.query = query;
// this.handler = handler;
// this.requestOptions = requestOptions;
// }
//
// /**
// * Start the iteration.
// */
// public void start() {
// if (started) {
// throw new IllegalStateException();
// }
// started = true;
// request = index.browseAsync(query, requestOptions, completionHandler);
// }
//
// /**
// * Cancel the iteration.
// * This cancels any currently ongoing request, and cancels the iteration.
// * The listener will not be called after the iteration has been cancelled.
// */
// public void cancel() {
// if (cancelled) {
// return;
// }
// request.cancel();
// request = null;
// cancelled = true;
// }
//
// /**
// * Determine if there is more content to be browsed.
// * WARNING: Can only be called from the handler, once the iteration has started.
// */
// public boolean hasNext() {
// if (!started) {
// throw new IllegalStateException();
// }
// return cursor != null;
// }
//
// private void next() {
// if (!hasNext()) {
// throw new IllegalStateException();
// }
// request = index.browseFromAsync(cursor, requestOptions, completionHandler);
// }
//
// private CompletionHandler completionHandler = new CompletionHandler() {
// @Override
// public void requestCompleted(JSONObject content, AlgoliaException error) {
// if (!cancelled) {
// handler.handleBatch(BrowseIterator.this, content, error);
// if (error == null) {
// cursor = content.optString("cursor", null);
// if (!cancelled && hasNext()) {
// next();
// }
// }
// }
// }
// };
// }
// Path: algoliasearch/src/test/java/com/algolia/search/saas/BrowseIteratorTest.java
import org.mockito.internal.util.reflection.Whitebox;
import org.robolectric.android.util.concurrent.RoboExecutorService;
import java.util.ArrayList;
import java.util.List;
import static junit.framework.Assert.fail;
import android.support.annotation.NonNull;
import com.algolia.search.saas.helpers.BrowseIterator;
import org.json.JSONArray;
import org.json.JSONObject;
import org.junit.Test;
// WARNING: Robolectric cannot work with custom executors in `AsyncTask`, so we substitute the client's
// executor with a Robolectric-compliant one.
Whitebox.setInternalState(client, "searchExecutorService", new RoboExecutorService());
indexName = Helpers.safeIndexName("àlgol?à-android");
index = client.initIndex(indexName);
objects = new ArrayList<JSONObject>();
for (int i = 0; i < 1500; ++i) {
objects.add(new JSONObject(String.format("{\"dummy\": %d}", i)));
}
JSONObject task = index.addObjects(new JSONArray(objects), /* requestOptions: */ null);
index.waitTask(task.getString("taskID"));
JSONArray objectIDs = task.getJSONArray("objectIDs");
ids = new ArrayList<String>();
for (int i = 0; i < objectIDs.length(); ++i) {
ids.add(objectIDs.getString(i));
}
}
@Override
public void tearDown() throws Exception {
client.deleteIndex(indexName, /* requestOptions: */ null);
}
@Test
public void nominal() throws Exception {
Query query = new Query();
AssertBrowseHandler handler = new AssertBrowseHandler() {
@Override | void doHandleBatch(BrowseIterator iterator, JSONObject result, AlgoliaException error) { |
eBay/RTran | rtran-api/src/test/java/com/ebay/rtran/DefaultMethodsTest.java | // Path: rtran-api/src/main/java/com/ebay/rtran/api/IRule.java
// public interface IRule<Model extends IModel> {
//
// Model transform(Model model);
//
// default boolean isEligibleFor(IProjectCtx projectType) {
// return true;
// }
//
// default Class<Model> rutimeModelClass() {
// Optional<Class<Model>> clazz = GenericsUtil.getClassForGenericType(getClass(), IRule.class, 0);
// return clazz.orElse(null);
// }
//
// default String id() {
// return getClass().getName();
// }
// }
| import com.ebay.rtran.api.IModelProvider;
import com.ebay.rtran.api.IRule;
import org.junit.Test;
import com.ebay.rtran.mock.MockModel;
import com.ebay.rtran.mock.MockProject; | /*
* Copyright (c) 2016 eBay Software Foundation.
*
* 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 com.ebay.rtran;
public class DefaultMethodsTest {
@Test
public void testRuntimeModelClassForRule()
throws IllegalAccessException, ClassNotFoundException, InstantiationException { | // Path: rtran-api/src/main/java/com/ebay/rtran/api/IRule.java
// public interface IRule<Model extends IModel> {
//
// Model transform(Model model);
//
// default boolean isEligibleFor(IProjectCtx projectType) {
// return true;
// }
//
// default Class<Model> rutimeModelClass() {
// Optional<Class<Model>> clazz = GenericsUtil.getClassForGenericType(getClass(), IRule.class, 0);
// return clazz.orElse(null);
// }
//
// default String id() {
// return getClass().getName();
// }
// }
// Path: rtran-api/src/test/java/com/ebay/rtran/DefaultMethodsTest.java
import com.ebay.rtran.api.IModelProvider;
import com.ebay.rtran.api.IRule;
import org.junit.Test;
import com.ebay.rtran.mock.MockModel;
import com.ebay.rtran.mock.MockProject;
/*
* Copyright (c) 2016 eBay Software Foundation.
*
* 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 com.ebay.rtran;
public class DefaultMethodsTest {
@Test
public void testRuntimeModelClassForRule()
throws IllegalAccessException, ClassNotFoundException, InstantiationException { | IRule<?> rule = Class.forName("com.ebay.rtran.mock.MockRule").asSubclass(IRule.class).newInstance(); |
jclehner/AppOpsXposed | src/at/jclehner/appopsxposed/util/Res.java | // Path: src/at/jclehner/appopsxposed/AppOpsXposed.java
// public class AppOpsXposed implements IXposedHookZygoteInit, IXposedHookLoadPackage, IXposedHookInitPackageResources
// {
// public static final String MODULE_PACKAGE = AppOpsXposed.class.getPackage().getName();
// public static final String SETTINGS_PACKAGE = "com.android.settings";
// public static final String SETTINGS_MAIN_ACTIVITY = SETTINGS_PACKAGE + ".Settings";
// public static final String APP_OPS_FRAGMENT = "com.android.settings.applications.AppOpsSummary";
// public static final String APP_OPS_DETAILS_FRAGMENT = "com.android.settings.applications.AppOpsDetails";
//
// private String mModPath;
//
// static
// {
// Util.logger = new Util.Logger() {
//
// @Override
// public void log(Throwable t)
// {
// XposedBridge.log(t);
// }
//
// @Override
// public void log(String s)
// {
// XposedBridge.log(s);
// }
// };
// }
//
// @Override
// public void initZygote(StartupParam startupParam) throws Throwable
// {
// mModPath = startupParam.modulePath;
// Res.modRes = XModuleResources.createInstance(mModPath, null);
// Res.modPrefs = new XSharedPreferences(AppOpsXposed.class.getPackage().getName());
// Res.modPrefs.makeWorldReadable();
// }
//
// @Override
// public void handleInitPackageResources(InitPackageResourcesParam resparam) throws Throwable
// {
// if(!ApkVariant.isSettingsPackage(resparam.packageName))
// return;
//
// for(int i = 0; i != Res.icons.length; ++i)
// Res.icons[i] = resparam.res.addResource(Res.modRes, Constants.ICONS[i]);
//
// XUtils.reloadPrefs();
//
// for(ApkVariant variant : ApkVariant.getAllMatching(resparam.packageName))
// {
// try
// {
// variant.handleInitPackageResources(resparam);
// }
// catch(Throwable t)
// {
// log(variant.getClass().getSimpleName() + ": [!!]");
// Util.debug(t);
// }
//
// break;
// }
//
// for(Hack hack : Hack.getAllEnabled(true))
// {
// try
// {
// hack.handleInitPackageResources(resparam);
// }
// catch(Throwable t)
// {
// log(hack.getClass().getSimpleName() + ": [!!]");
// Util.debug(t);
// }
// }
// }
//
// @Override
// public void handleLoadPackage(LoadPackageParam lpparam) throws Throwable
// {
// final boolean isSettings = ApkVariant.isSettingsPackage(lpparam);
//
// if(MODULE_PACKAGE.equals(lpparam.packageName))
// {
// XposedHelpers.findAndHookMethod(Util.class.getName(), lpparam.classLoader,
// "isXposedModuleEnabled", XC_MethodReplacement.returnConstant(true));
// }
//
// XUtils.reloadPrefs();
//
// for(Hack hack : Hack.getAllEnabled(true))
// {
// try
// {
// hack.handleLoadPackage(lpparam);
// }
// catch(Throwable t)
// {
// log(hack.getClass().getSimpleName() + ": [!!]");
// Util.debug(t);
// }
// }
//
// if(!isSettings)
// return;
//
// Res.settingsRes = XModuleResources.createInstance(lpparam.appInfo.sourceDir, null);
//
// for(ApkVariant variant : ApkVariant.getAllMatching(lpparam))
// {
// final String variantName = " " + variant.getClass().getSimpleName();
//
// try
// {
// variant.handleLoadPackage(lpparam);
// log(variantName + ": [OK]");
// break;
// }
// catch(Throwable t)
// {
// Util.debug(variantName + ": [!!]");
// Util.debug(t);
// }
// }
// }
// }
| import de.robv.android.xposed.XSharedPreferences;
import android.content.res.XModuleResources;
import at.jclehner.appopsxposed.AppOpsXposed;
import at.jclehner.appopsxposed.R; | package at.jclehner.appopsxposed.util;
public class Res
{
public static int[] icons = new int[Constants.ICONS.length];
public static XModuleResources settingsRes;
public static XModuleResources modRes;
public static XSharedPreferences modPrefs;
public static int getSettingsIdentifier(String name) { | // Path: src/at/jclehner/appopsxposed/AppOpsXposed.java
// public class AppOpsXposed implements IXposedHookZygoteInit, IXposedHookLoadPackage, IXposedHookInitPackageResources
// {
// public static final String MODULE_PACKAGE = AppOpsXposed.class.getPackage().getName();
// public static final String SETTINGS_PACKAGE = "com.android.settings";
// public static final String SETTINGS_MAIN_ACTIVITY = SETTINGS_PACKAGE + ".Settings";
// public static final String APP_OPS_FRAGMENT = "com.android.settings.applications.AppOpsSummary";
// public static final String APP_OPS_DETAILS_FRAGMENT = "com.android.settings.applications.AppOpsDetails";
//
// private String mModPath;
//
// static
// {
// Util.logger = new Util.Logger() {
//
// @Override
// public void log(Throwable t)
// {
// XposedBridge.log(t);
// }
//
// @Override
// public void log(String s)
// {
// XposedBridge.log(s);
// }
// };
// }
//
// @Override
// public void initZygote(StartupParam startupParam) throws Throwable
// {
// mModPath = startupParam.modulePath;
// Res.modRes = XModuleResources.createInstance(mModPath, null);
// Res.modPrefs = new XSharedPreferences(AppOpsXposed.class.getPackage().getName());
// Res.modPrefs.makeWorldReadable();
// }
//
// @Override
// public void handleInitPackageResources(InitPackageResourcesParam resparam) throws Throwable
// {
// if(!ApkVariant.isSettingsPackage(resparam.packageName))
// return;
//
// for(int i = 0; i != Res.icons.length; ++i)
// Res.icons[i] = resparam.res.addResource(Res.modRes, Constants.ICONS[i]);
//
// XUtils.reloadPrefs();
//
// for(ApkVariant variant : ApkVariant.getAllMatching(resparam.packageName))
// {
// try
// {
// variant.handleInitPackageResources(resparam);
// }
// catch(Throwable t)
// {
// log(variant.getClass().getSimpleName() + ": [!!]");
// Util.debug(t);
// }
//
// break;
// }
//
// for(Hack hack : Hack.getAllEnabled(true))
// {
// try
// {
// hack.handleInitPackageResources(resparam);
// }
// catch(Throwable t)
// {
// log(hack.getClass().getSimpleName() + ": [!!]");
// Util.debug(t);
// }
// }
// }
//
// @Override
// public void handleLoadPackage(LoadPackageParam lpparam) throws Throwable
// {
// final boolean isSettings = ApkVariant.isSettingsPackage(lpparam);
//
// if(MODULE_PACKAGE.equals(lpparam.packageName))
// {
// XposedHelpers.findAndHookMethod(Util.class.getName(), lpparam.classLoader,
// "isXposedModuleEnabled", XC_MethodReplacement.returnConstant(true));
// }
//
// XUtils.reloadPrefs();
//
// for(Hack hack : Hack.getAllEnabled(true))
// {
// try
// {
// hack.handleLoadPackage(lpparam);
// }
// catch(Throwable t)
// {
// log(hack.getClass().getSimpleName() + ": [!!]");
// Util.debug(t);
// }
// }
//
// if(!isSettings)
// return;
//
// Res.settingsRes = XModuleResources.createInstance(lpparam.appInfo.sourceDir, null);
//
// for(ApkVariant variant : ApkVariant.getAllMatching(lpparam))
// {
// final String variantName = " " + variant.getClass().getSimpleName();
//
// try
// {
// variant.handleLoadPackage(lpparam);
// log(variantName + ": [OK]");
// break;
// }
// catch(Throwable t)
// {
// Util.debug(variantName + ": [!!]");
// Util.debug(t);
// }
// }
// }
// }
// Path: src/at/jclehner/appopsxposed/util/Res.java
import de.robv.android.xposed.XSharedPreferences;
import android.content.res.XModuleResources;
import at.jclehner.appopsxposed.AppOpsXposed;
import at.jclehner.appopsxposed.R;
package at.jclehner.appopsxposed.util;
public class Res
{
public static int[] icons = new int[Constants.ICONS.length];
public static XModuleResources settingsRes;
public static XModuleResources modRes;
public static XSharedPreferences modPrefs;
public static int getSettingsIdentifier(String name) { | return settingsRes.getIdentifier(name, null, AppOpsXposed.SETTINGS_PACKAGE); |
alexdeleon/lupa | src/test/java/com/lumata/lib/lupa/extractor/internal/ContentExtractorMatcherTest.java | // Path: src/main/java/com/lumata/lib/lupa/extractor/internal/ContentExtractorMatcher.java
// class ContentExtractorMatcher<E extends WebContent> implements
// Comparable<ContentExtractorMatcher<? extends WebContent>> {
//
// private final ContentExtractor<E> contentExtractor;
// Map<String, String> constraints;
// int priority;
// static final String CONTENT_TYPE = "type";
// static final String URL = "url";
//
// ContentExtractorMatcher(ContentExtractor<E> contentExtractor, Map<String, String> constraints, int priority) {
// this.contentExtractor = contentExtractor;
// this.constraints = constraints;
// this.priority = priority;
// }
//
// /**
// * @return the contentExtractor
// */
// public ContentExtractor<E> getContentExtractor() {
// return contentExtractor;
// }
//
// public boolean isCaplableOfExtracting(Class<? extends WebContent> webContentType) {
// return contentExtractor.getExtractableWebContentType().isAssignableFrom(webContentType);
// }
//
// boolean matches(ReadableResource res) {
// if (MapUtils.isEmpty(constraints)) {
// return true;
// }
//
// return matchContentType(res) && matchUrl(res);
// }
//
// private boolean matchUrl(ReadableResource res) {
// // hasConstraint(url) -> matches(constraint(url), url)
// return !constraints.containsKey(URL) || res.getUrl().toString().matches(constraints.get(URL));
// }
//
// private boolean matchContentType(ReadableResource res) {
// // hasConstraint(type) -> hasContentType() ^ is(type, constraint(type))
// return !constraints.containsKey(CONTENT_TYPE)
// || (res.getContentType().isPresent() && res.getContentType().get()
// .is(MediaType.parse(constraints.get(CONTENT_TYPE))));
// }
//
// @Override
// public int compareTo(ContentExtractorMatcher<? extends WebContent> o) {
// int weightDifference = getWeigth(constraints) - getWeigth(o.constraints);
// if (weightDifference != 0) {
// return weightDifference;
// }
// int priorityDifference = o.priority - priority;
// if (priorityDifference != 0) {
// return priorityDifference;
// }
// return this.equals(o) ? 0 : 1;
// }
//
// private int getWeigth(Map<String, String> constraints) {
// int weight = 0;
// if (constraints.containsKey(CONTENT_TYPE)) {
// weight -= 1;
// }
// if (constraints.containsKey(URL)) {
// weight -= 2;
// }
// return weight;
// }
//
// @Override
// public int hashCode() {
// return Objects.hashCode(contentExtractor, constraints);
// }
//
// @Override
// public boolean equals(Object obj) {
// if (obj == null || !(obj instanceof ContentExtractorMatcher)) {
// return false;
// }
// ContentExtractorMatcher<?> that = (ContentExtractorMatcher<?>) obj;
// return Objects.equal(this.contentExtractor, that.contentExtractor)
// && Objects.equal(this.constraints, that.constraints) && Objects.equal(this.priority, that.priority);
// }
// }
| import static org.junit.Assert.assertTrue;
import java.util.HashMap;
import java.util.Map;
import org.junit.Test;
import com.lumata.lib.lupa.extractor.internal.ContentExtractorMatcher; | /**
* Copyright (c) 2013 Lumata
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package com.lumata.lib.lupa.extractor.internal;
/**
* @author Alexander De Leon - alexander.leon@lumatagroup.com
*
*/
public class ContentExtractorMatcherTest {
@Test
public void testUrlIsMoreSpecifictThanContentType() { | // Path: src/main/java/com/lumata/lib/lupa/extractor/internal/ContentExtractorMatcher.java
// class ContentExtractorMatcher<E extends WebContent> implements
// Comparable<ContentExtractorMatcher<? extends WebContent>> {
//
// private final ContentExtractor<E> contentExtractor;
// Map<String, String> constraints;
// int priority;
// static final String CONTENT_TYPE = "type";
// static final String URL = "url";
//
// ContentExtractorMatcher(ContentExtractor<E> contentExtractor, Map<String, String> constraints, int priority) {
// this.contentExtractor = contentExtractor;
// this.constraints = constraints;
// this.priority = priority;
// }
//
// /**
// * @return the contentExtractor
// */
// public ContentExtractor<E> getContentExtractor() {
// return contentExtractor;
// }
//
// public boolean isCaplableOfExtracting(Class<? extends WebContent> webContentType) {
// return contentExtractor.getExtractableWebContentType().isAssignableFrom(webContentType);
// }
//
// boolean matches(ReadableResource res) {
// if (MapUtils.isEmpty(constraints)) {
// return true;
// }
//
// return matchContentType(res) && matchUrl(res);
// }
//
// private boolean matchUrl(ReadableResource res) {
// // hasConstraint(url) -> matches(constraint(url), url)
// return !constraints.containsKey(URL) || res.getUrl().toString().matches(constraints.get(URL));
// }
//
// private boolean matchContentType(ReadableResource res) {
// // hasConstraint(type) -> hasContentType() ^ is(type, constraint(type))
// return !constraints.containsKey(CONTENT_TYPE)
// || (res.getContentType().isPresent() && res.getContentType().get()
// .is(MediaType.parse(constraints.get(CONTENT_TYPE))));
// }
//
// @Override
// public int compareTo(ContentExtractorMatcher<? extends WebContent> o) {
// int weightDifference = getWeigth(constraints) - getWeigth(o.constraints);
// if (weightDifference != 0) {
// return weightDifference;
// }
// int priorityDifference = o.priority - priority;
// if (priorityDifference != 0) {
// return priorityDifference;
// }
// return this.equals(o) ? 0 : 1;
// }
//
// private int getWeigth(Map<String, String> constraints) {
// int weight = 0;
// if (constraints.containsKey(CONTENT_TYPE)) {
// weight -= 1;
// }
// if (constraints.containsKey(URL)) {
// weight -= 2;
// }
// return weight;
// }
//
// @Override
// public int hashCode() {
// return Objects.hashCode(contentExtractor, constraints);
// }
//
// @Override
// public boolean equals(Object obj) {
// if (obj == null || !(obj instanceof ContentExtractorMatcher)) {
// return false;
// }
// ContentExtractorMatcher<?> that = (ContentExtractorMatcher<?>) obj;
// return Objects.equal(this.contentExtractor, that.contentExtractor)
// && Objects.equal(this.constraints, that.constraints) && Objects.equal(this.priority, that.priority);
// }
// }
// Path: src/test/java/com/lumata/lib/lupa/extractor/internal/ContentExtractorMatcherTest.java
import static org.junit.Assert.assertTrue;
import java.util.HashMap;
import java.util.Map;
import org.junit.Test;
import com.lumata.lib.lupa.extractor.internal.ContentExtractorMatcher;
/**
* Copyright (c) 2013 Lumata
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package com.lumata.lib.lupa.extractor.internal;
/**
* @author Alexander De Leon - alexander.leon@lumatagroup.com
*
*/
public class ContentExtractorMatcherTest {
@Test
public void testUrlIsMoreSpecifictThanContentType() { | ContentExtractorMatcher m1 = new ContentExtractorMatcher(null, map("type", "text/plain"), 0); |
alexdeleon/lupa | src/main/java/com/lumata/lib/lupa/extractor/internal/ImageExtractor.java | // Path: src/main/java/com/lumata/lib/lupa/ReadableResource.java
// public interface ReadableResource {
//
// URL getUrl();
//
// /**
// * Move the current URL to the redirection path and set the specified url as the actual resource url.
// *
// * @param url
// * the redirectionUrl
// */
// void makeRedirection(URL url);
//
// Optional<URL[]> getRedirectionPath();
//
// Optional<MediaType> getContentType();
//
// InputStream read() throws IOException;
//
// void discard();
// }
//
// Path: src/main/java/com/lumata/lib/lupa/ServiceLocator.java
// public interface ServiceLocator {
//
// Scraper getScraper();
//
// HttpService getHttpService();
//
// ImageService getImageService();
// }
//
// Path: src/main/java/com/lumata/lib/lupa/content/Image.java
// public class Image extends WebContent {
//
// private Integer width, height;
//
// public Image(String url, String... aliasUrls) {
// super(url, aliasUrls);
// }
//
// /**
// * @return the width in pixels
// */
// public Integer getWidth() {
// return width;
// }
//
// /**
// * @param width
// * the width in pixels to set
// */
// public void setWidth(Integer width) {
// this.width = width;
// }
//
// /**
// * @return the height in pixels
// */
// public Integer getHeight() {
// return height;
// }
//
// /**
// * @param height
// * the height in pixels to set
// */
// public void setHeight(Integer height) {
// this.height = height;
// }
//
// @Override
// public Type getType() {
// return Type.IMAGE;
// }
//
// @Override
// public String toString() {
// return toStringHelper(this).add("with", width).add("height", height).toString();
// }
// }
| import java.io.IOException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.lumata.lib.lupa.ReadableResource;
import com.lumata.lib.lupa.ServiceLocator;
import com.lumata.lib.lupa.content.Image;
| package com.lumata.lib.lupa.extractor.internal;
public class ImageExtractor extends AbstractExtractor<Image> {
private static final Logger LOG = LoggerFactory.getLogger(ImageExtractor.class);
@Override
| // Path: src/main/java/com/lumata/lib/lupa/ReadableResource.java
// public interface ReadableResource {
//
// URL getUrl();
//
// /**
// * Move the current URL to the redirection path and set the specified url as the actual resource url.
// *
// * @param url
// * the redirectionUrl
// */
// void makeRedirection(URL url);
//
// Optional<URL[]> getRedirectionPath();
//
// Optional<MediaType> getContentType();
//
// InputStream read() throws IOException;
//
// void discard();
// }
//
// Path: src/main/java/com/lumata/lib/lupa/ServiceLocator.java
// public interface ServiceLocator {
//
// Scraper getScraper();
//
// HttpService getHttpService();
//
// ImageService getImageService();
// }
//
// Path: src/main/java/com/lumata/lib/lupa/content/Image.java
// public class Image extends WebContent {
//
// private Integer width, height;
//
// public Image(String url, String... aliasUrls) {
// super(url, aliasUrls);
// }
//
// /**
// * @return the width in pixels
// */
// public Integer getWidth() {
// return width;
// }
//
// /**
// * @param width
// * the width in pixels to set
// */
// public void setWidth(Integer width) {
// this.width = width;
// }
//
// /**
// * @return the height in pixels
// */
// public Integer getHeight() {
// return height;
// }
//
// /**
// * @param height
// * the height in pixels to set
// */
// public void setHeight(Integer height) {
// this.height = height;
// }
//
// @Override
// public Type getType() {
// return Type.IMAGE;
// }
//
// @Override
// public String toString() {
// return toStringHelper(this).add("with", width).add("height", height).toString();
// }
// }
// Path: src/main/java/com/lumata/lib/lupa/extractor/internal/ImageExtractor.java
import java.io.IOException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.lumata.lib.lupa.ReadableResource;
import com.lumata.lib.lupa.ServiceLocator;
import com.lumata.lib.lupa.content.Image;
package com.lumata.lib.lupa.extractor.internal;
public class ImageExtractor extends AbstractExtractor<Image> {
private static final Logger LOG = LoggerFactory.getLogger(ImageExtractor.class);
@Override
| public Image extractContent(ReadableResource resource, ServiceLocator serviceLocator) throws IOException {
|
alexdeleon/lupa | src/main/java/com/lumata/lib/lupa/extractor/internal/ImageExtractor.java | // Path: src/main/java/com/lumata/lib/lupa/ReadableResource.java
// public interface ReadableResource {
//
// URL getUrl();
//
// /**
// * Move the current URL to the redirection path and set the specified url as the actual resource url.
// *
// * @param url
// * the redirectionUrl
// */
// void makeRedirection(URL url);
//
// Optional<URL[]> getRedirectionPath();
//
// Optional<MediaType> getContentType();
//
// InputStream read() throws IOException;
//
// void discard();
// }
//
// Path: src/main/java/com/lumata/lib/lupa/ServiceLocator.java
// public interface ServiceLocator {
//
// Scraper getScraper();
//
// HttpService getHttpService();
//
// ImageService getImageService();
// }
//
// Path: src/main/java/com/lumata/lib/lupa/content/Image.java
// public class Image extends WebContent {
//
// private Integer width, height;
//
// public Image(String url, String... aliasUrls) {
// super(url, aliasUrls);
// }
//
// /**
// * @return the width in pixels
// */
// public Integer getWidth() {
// return width;
// }
//
// /**
// * @param width
// * the width in pixels to set
// */
// public void setWidth(Integer width) {
// this.width = width;
// }
//
// /**
// * @return the height in pixels
// */
// public Integer getHeight() {
// return height;
// }
//
// /**
// * @param height
// * the height in pixels to set
// */
// public void setHeight(Integer height) {
// this.height = height;
// }
//
// @Override
// public Type getType() {
// return Type.IMAGE;
// }
//
// @Override
// public String toString() {
// return toStringHelper(this).add("with", width).add("height", height).toString();
// }
// }
| import java.io.IOException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.lumata.lib.lupa.ReadableResource;
import com.lumata.lib.lupa.ServiceLocator;
import com.lumata.lib.lupa.content.Image;
| package com.lumata.lib.lupa.extractor.internal;
public class ImageExtractor extends AbstractExtractor<Image> {
private static final Logger LOG = LoggerFactory.getLogger(ImageExtractor.class);
@Override
| // Path: src/main/java/com/lumata/lib/lupa/ReadableResource.java
// public interface ReadableResource {
//
// URL getUrl();
//
// /**
// * Move the current URL to the redirection path and set the specified url as the actual resource url.
// *
// * @param url
// * the redirectionUrl
// */
// void makeRedirection(URL url);
//
// Optional<URL[]> getRedirectionPath();
//
// Optional<MediaType> getContentType();
//
// InputStream read() throws IOException;
//
// void discard();
// }
//
// Path: src/main/java/com/lumata/lib/lupa/ServiceLocator.java
// public interface ServiceLocator {
//
// Scraper getScraper();
//
// HttpService getHttpService();
//
// ImageService getImageService();
// }
//
// Path: src/main/java/com/lumata/lib/lupa/content/Image.java
// public class Image extends WebContent {
//
// private Integer width, height;
//
// public Image(String url, String... aliasUrls) {
// super(url, aliasUrls);
// }
//
// /**
// * @return the width in pixels
// */
// public Integer getWidth() {
// return width;
// }
//
// /**
// * @param width
// * the width in pixels to set
// */
// public void setWidth(Integer width) {
// this.width = width;
// }
//
// /**
// * @return the height in pixels
// */
// public Integer getHeight() {
// return height;
// }
//
// /**
// * @param height
// * the height in pixels to set
// */
// public void setHeight(Integer height) {
// this.height = height;
// }
//
// @Override
// public Type getType() {
// return Type.IMAGE;
// }
//
// @Override
// public String toString() {
// return toStringHelper(this).add("with", width).add("height", height).toString();
// }
// }
// Path: src/main/java/com/lumata/lib/lupa/extractor/internal/ImageExtractor.java
import java.io.IOException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.lumata.lib.lupa.ReadableResource;
import com.lumata.lib.lupa.ServiceLocator;
import com.lumata.lib.lupa.content.Image;
package com.lumata.lib.lupa.extractor.internal;
public class ImageExtractor extends AbstractExtractor<Image> {
private static final Logger LOG = LoggerFactory.getLogger(ImageExtractor.class);
@Override
| public Image extractContent(ReadableResource resource, ServiceLocator serviceLocator) throws IOException {
|
alexdeleon/lupa | src/test/java/com/lumata/lib/lupa/util/URLUtilTest.java | // Path: src/main/java/com/lumata/lib/lupa/util/URLUtil.java
// public class URLUtil {
//
// public static String asString(URL url) {
// return url.toString();
// }
//
// public static String[] asString(URL[] urls) {
// if (urls == null) {
// return null;
// }
// return asString(Arrays.asList(urls)).toArray(new String[] {});
// }
//
// public static Collection<String> asString(Collection<URL> urls) {
// if (urls == null) {
// return null;
// }
// Collection<String> ret = Collections2.transform(urls, new Function<URL, String>() {
// @Override
// public String apply(URL input) {
// return asString(input);
// }
// });
// return ret;
// }
//
// public static URL getAbsoluteUrl(URL baseUrl, String relativeUrl) throws MalformedURLException {
// if (isAbsolute(relativeUrl)) {
// return new URL(relativeUrl);
// }
// return new URL(baseUrl, relativeUrl);
// }
//
// public static boolean isAbsolute(String url) {
// return url.matches("^.*://.*");
// }
//
// }
| import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import java.net.MalformedURLException;
import java.net.URL;
import org.junit.Test;
import com.lumata.lib.lupa.util.URLUtil; | /**
* Copyright (c) 2013 Lumata
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package com.lumata.lib.lupa.util;
/**
* @author Alexander De Leon - alexander.leon@lumatagroup.com
*
*/
public class URLUtilTest {
@Test
public void testBuildRelativeURL() throws MalformedURLException { | // Path: src/main/java/com/lumata/lib/lupa/util/URLUtil.java
// public class URLUtil {
//
// public static String asString(URL url) {
// return url.toString();
// }
//
// public static String[] asString(URL[] urls) {
// if (urls == null) {
// return null;
// }
// return asString(Arrays.asList(urls)).toArray(new String[] {});
// }
//
// public static Collection<String> asString(Collection<URL> urls) {
// if (urls == null) {
// return null;
// }
// Collection<String> ret = Collections2.transform(urls, new Function<URL, String>() {
// @Override
// public String apply(URL input) {
// return asString(input);
// }
// });
// return ret;
// }
//
// public static URL getAbsoluteUrl(URL baseUrl, String relativeUrl) throws MalformedURLException {
// if (isAbsolute(relativeUrl)) {
// return new URL(relativeUrl);
// }
// return new URL(baseUrl, relativeUrl);
// }
//
// public static boolean isAbsolute(String url) {
// return url.matches("^.*://.*");
// }
//
// }
// Path: src/test/java/com/lumata/lib/lupa/util/URLUtilTest.java
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import java.net.MalformedURLException;
import java.net.URL;
import org.junit.Test;
import com.lumata.lib.lupa.util.URLUtil;
/**
* Copyright (c) 2013 Lumata
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package com.lumata.lib.lupa.util;
/**
* @author Alexander De Leon - alexander.leon@lumatagroup.com
*
*/
public class URLUtilTest {
@Test
public void testBuildRelativeURL() throws MalformedURLException { | assertEquals(new URL("http://example.com/a"), URLUtil.getAbsoluteUrl(new URL("http://example.com"), "/a")); |
alexdeleon/lupa | src/main/java/com/lumata/lib/lupa/extractor/internal/HtmlImageExtractor.java | // Path: src/main/java/com/lumata/lib/lupa/content/Image.java
// public class Image extends WebContent {
//
// private Integer width, height;
//
// public Image(String url, String... aliasUrls) {
// super(url, aliasUrls);
// }
//
// /**
// * @return the width in pixels
// */
// public Integer getWidth() {
// return width;
// }
//
// /**
// * @param width
// * the width in pixels to set
// */
// public void setWidth(Integer width) {
// this.width = width;
// }
//
// /**
// * @return the height in pixels
// */
// public Integer getHeight() {
// return height;
// }
//
// /**
// * @param height
// * the height in pixels to set
// */
// public void setHeight(Integer height) {
// this.height = height;
// }
//
// @Override
// public Type getType() {
// return Type.IMAGE;
// }
//
// @Override
// public String toString() {
// return toStringHelper(this).add("with", width).add("height", height).toString();
// }
// }
| import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URL;
import org.jsoup.select.Elements;
import com.lumata.lib.lupa.content.Image; | /**
* Copyright (c) 2013 Lumata
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package com.lumata.lib.lupa.extractor.internal;
/**
* @author Alexander De Leon - alexander.leon@lumatagroup.com
*
*/
public interface HtmlImageExtractor {
static final int DEFAULT_MAX_IMAGES_TO_EXPLORE = 10;
static final int DEFAULT_MIN_IMAGE_SIZE = 65;
/**
* Looks at the the first number of images (maxImagesToLook) and returns the biggest one. The size of the image is
* taken from the HTML tag or if absent computed by reading the image meta.
*
* @param htmlSection
* a section of the HTML page where to extract the images from
* @return a Image or null if none is found.
* @throws MalformedURLException
* @throws IOException
*/ | // Path: src/main/java/com/lumata/lib/lupa/content/Image.java
// public class Image extends WebContent {
//
// private Integer width, height;
//
// public Image(String url, String... aliasUrls) {
// super(url, aliasUrls);
// }
//
// /**
// * @return the width in pixels
// */
// public Integer getWidth() {
// return width;
// }
//
// /**
// * @param width
// * the width in pixels to set
// */
// public void setWidth(Integer width) {
// this.width = width;
// }
//
// /**
// * @return the height in pixels
// */
// public Integer getHeight() {
// return height;
// }
//
// /**
// * @param height
// * the height in pixels to set
// */
// public void setHeight(Integer height) {
// this.height = height;
// }
//
// @Override
// public Type getType() {
// return Type.IMAGE;
// }
//
// @Override
// public String toString() {
// return toStringHelper(this).add("with", width).add("height", height).toString();
// }
// }
// Path: src/main/java/com/lumata/lib/lupa/extractor/internal/HtmlImageExtractor.java
import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URL;
import org.jsoup.select.Elements;
import com.lumata.lib.lupa.content.Image;
/**
* Copyright (c) 2013 Lumata
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package com.lumata.lib.lupa.extractor.internal;
/**
* @author Alexander De Leon - alexander.leon@lumatagroup.com
*
*/
public interface HtmlImageExtractor {
static final int DEFAULT_MAX_IMAGES_TO_EXPLORE = 10;
static final int DEFAULT_MIN_IMAGE_SIZE = 65;
/**
* Looks at the the first number of images (maxImagesToLook) and returns the biggest one. The size of the image is
* taken from the HTML tag or if absent computed by reading the image meta.
*
* @param htmlSection
* a section of the HTML page where to extract the images from
* @return a Image or null if none is found.
* @throws MalformedURLException
* @throws IOException
*/ | Image extractBestImage(URL sourceUrl, Elements htmlSection); |
alexdeleon/lupa | src/main/java/com/lumata/lib/lupa/extractor/internal/config/AbstractExtractorConfigurationModule.java | // Path: src/main/java/com/lumata/lib/lupa/extractor/ContentExtractor.java
// public interface ContentExtractor<E extends WebContent> {
//
// E extractContent(ReadableResource resource, ServiceLocator serviceLocator) throws IOException;
//
// void setConfiguration(Map<String, String> config);
//
// Class<E> getExtractableWebContentType();
//
// }
| import com.lumata.lib.lupa.extractor.ContentExtractor;
import java.util.ArrayList;
import java.util.List;
import java.util.Map; | /*
* 2011 copyright Buongiorno SpA
*/
package com.lumata.lib.lupa.extractor.internal.config;
/**
* @author Alexander De Leon - alexander.leon@buongiorno.com
*
*/
public abstract class AbstractExtractorConfigurationModule implements ExtractorConfigurationModule {
private final List<ExtractorConfiguration> configurations = new ArrayList<ExtractorConfiguration>();
@Override
public ExtractorConfiguration[] configurations() {
configure();
return configurations.toArray(new ExtractorConfiguration[configurations.size()]);
}
protected abstract void configure();
protected ConfigurationBuilder when(Map<String, String> constraints) {
ConfigurationBuilder builder = new ConfigurationBuilder();
builder.configuration.setConstraints(constraints);
return builder;
}
/* ----------------------- inner classes -- */
protected class ConfigurationBuilder {
private final ExtractorConfiguration configuration = new ExtractorConfiguration();
| // Path: src/main/java/com/lumata/lib/lupa/extractor/ContentExtractor.java
// public interface ContentExtractor<E extends WebContent> {
//
// E extractContent(ReadableResource resource, ServiceLocator serviceLocator) throws IOException;
//
// void setConfiguration(Map<String, String> config);
//
// Class<E> getExtractableWebContentType();
//
// }
// Path: src/main/java/com/lumata/lib/lupa/extractor/internal/config/AbstractExtractorConfigurationModule.java
import com.lumata.lib.lupa.extractor.ContentExtractor;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
/*
* 2011 copyright Buongiorno SpA
*/
package com.lumata.lib.lupa.extractor.internal.config;
/**
* @author Alexander De Leon - alexander.leon@buongiorno.com
*
*/
public abstract class AbstractExtractorConfigurationModule implements ExtractorConfigurationModule {
private final List<ExtractorConfiguration> configurations = new ArrayList<ExtractorConfiguration>();
@Override
public ExtractorConfiguration[] configurations() {
configure();
return configurations.toArray(new ExtractorConfiguration[configurations.size()]);
}
protected abstract void configure();
protected ConfigurationBuilder when(Map<String, String> constraints) {
ConfigurationBuilder builder = new ConfigurationBuilder();
builder.configuration.setConstraints(constraints);
return builder;
}
/* ----------------------- inner classes -- */
protected class ConfigurationBuilder {
private final ExtractorConfiguration configuration = new ExtractorConfiguration();
| public ConfigurationParametarizer use(Class<? extends ContentExtractor<?>> c) { |
alexdeleon/lupa | src/main/java/com/lumata/lib/lupa/internal/ImageServiceImpl.java | // Path: src/main/java/com/lumata/lib/lupa/HttpService.java
// @Service
// public interface HttpService {
//
// ReadableResource getRawResource(URL url);
//
// TextReadableResource getTextResource(URL url);
//
// TextReadableResource getTextResource(ReadableResource resource);
//
// }
//
// Path: src/main/java/com/lumata/lib/lupa/ImageService.java
// public interface ImageService {
//
// /**
// * Extracts image metadata from the specified URL. If it is unable to determine that the given URL contains an image
// * this methods returns <strong>null</strong>.
// *
// * @param imageUrl
// * @return an Image object or null if no image found at the given URL.
// * @throws IOException
// * if something goes wrong connecting to the image source.
// * @throws HttpException
// */
// Image getImageFromUrl(URL imageUrl) throws IOException;
//
// /**
// * Extracts image metadata from the specified resource. If it is unable to determine that the given URL contains an
// * image this methods returns <strong>null</strong>.
// *
// * @param resource
// * @return an Image object or null if no image found at the given URL.
// * @throws IOException
// * if something goes wrong connecting to the image source.
// * @throws HttpException
// */
// Image getImageFromResource(ReadableResource resource) throws IOException;
//
// }
//
// Path: src/main/java/com/lumata/lib/lupa/ReadableResource.java
// public interface ReadableResource {
//
// URL getUrl();
//
// /**
// * Move the current URL to the redirection path and set the specified url as the actual resource url.
// *
// * @param url
// * the redirectionUrl
// */
// void makeRedirection(URL url);
//
// Optional<URL[]> getRedirectionPath();
//
// Optional<MediaType> getContentType();
//
// InputStream read() throws IOException;
//
// void discard();
// }
//
// Path: src/main/java/com/lumata/lib/lupa/content/Image.java
// public class Image extends WebContent {
//
// private Integer width, height;
//
// public Image(String url, String... aliasUrls) {
// super(url, aliasUrls);
// }
//
// /**
// * @return the width in pixels
// */
// public Integer getWidth() {
// return width;
// }
//
// /**
// * @param width
// * the width in pixels to set
// */
// public void setWidth(Integer width) {
// this.width = width;
// }
//
// /**
// * @return the height in pixels
// */
// public Integer getHeight() {
// return height;
// }
//
// /**
// * @param height
// * the height in pixels to set
// */
// public void setHeight(Integer height) {
// this.height = height;
// }
//
// @Override
// public Type getType() {
// return Type.IMAGE;
// }
//
// @Override
// public String toString() {
// return toStringHelper(this).add("with", width).add("height", height).toString();
// }
// }
| import com.lumata.lib.lupa.HttpService;
import com.lumata.lib.lupa.ImageService;
import com.lumata.lib.lupa.ReadableResource;
import com.lumata.lib.lupa.content.Image;
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
import java.util.Iterator;
import javax.imageio.ImageIO;
import javax.imageio.ImageReader;
import javax.imageio.stream.ImageInputStream;
import com.google.common.net.MediaType; | /**
* Copyright (c) 2013 Lumata
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package com.lumata.lib.lupa.internal;
/**
* @author Alexander De Leon - alexander.leon@lumatagroup.com
*
*/
public class ImageServiceImpl implements ImageService {
private final HttpService httpService;
public ImageServiceImpl(HttpService httpService) {
super();
this.httpService = httpService;
}
@Override | // Path: src/main/java/com/lumata/lib/lupa/HttpService.java
// @Service
// public interface HttpService {
//
// ReadableResource getRawResource(URL url);
//
// TextReadableResource getTextResource(URL url);
//
// TextReadableResource getTextResource(ReadableResource resource);
//
// }
//
// Path: src/main/java/com/lumata/lib/lupa/ImageService.java
// public interface ImageService {
//
// /**
// * Extracts image metadata from the specified URL. If it is unable to determine that the given URL contains an image
// * this methods returns <strong>null</strong>.
// *
// * @param imageUrl
// * @return an Image object or null if no image found at the given URL.
// * @throws IOException
// * if something goes wrong connecting to the image source.
// * @throws HttpException
// */
// Image getImageFromUrl(URL imageUrl) throws IOException;
//
// /**
// * Extracts image metadata from the specified resource. If it is unable to determine that the given URL contains an
// * image this methods returns <strong>null</strong>.
// *
// * @param resource
// * @return an Image object or null if no image found at the given URL.
// * @throws IOException
// * if something goes wrong connecting to the image source.
// * @throws HttpException
// */
// Image getImageFromResource(ReadableResource resource) throws IOException;
//
// }
//
// Path: src/main/java/com/lumata/lib/lupa/ReadableResource.java
// public interface ReadableResource {
//
// URL getUrl();
//
// /**
// * Move the current URL to the redirection path and set the specified url as the actual resource url.
// *
// * @param url
// * the redirectionUrl
// */
// void makeRedirection(URL url);
//
// Optional<URL[]> getRedirectionPath();
//
// Optional<MediaType> getContentType();
//
// InputStream read() throws IOException;
//
// void discard();
// }
//
// Path: src/main/java/com/lumata/lib/lupa/content/Image.java
// public class Image extends WebContent {
//
// private Integer width, height;
//
// public Image(String url, String... aliasUrls) {
// super(url, aliasUrls);
// }
//
// /**
// * @return the width in pixels
// */
// public Integer getWidth() {
// return width;
// }
//
// /**
// * @param width
// * the width in pixels to set
// */
// public void setWidth(Integer width) {
// this.width = width;
// }
//
// /**
// * @return the height in pixels
// */
// public Integer getHeight() {
// return height;
// }
//
// /**
// * @param height
// * the height in pixels to set
// */
// public void setHeight(Integer height) {
// this.height = height;
// }
//
// @Override
// public Type getType() {
// return Type.IMAGE;
// }
//
// @Override
// public String toString() {
// return toStringHelper(this).add("with", width).add("height", height).toString();
// }
// }
// Path: src/main/java/com/lumata/lib/lupa/internal/ImageServiceImpl.java
import com.lumata.lib.lupa.HttpService;
import com.lumata.lib.lupa.ImageService;
import com.lumata.lib.lupa.ReadableResource;
import com.lumata.lib.lupa.content.Image;
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
import java.util.Iterator;
import javax.imageio.ImageIO;
import javax.imageio.ImageReader;
import javax.imageio.stream.ImageInputStream;
import com.google.common.net.MediaType;
/**
* Copyright (c) 2013 Lumata
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package com.lumata.lib.lupa.internal;
/**
* @author Alexander De Leon - alexander.leon@lumatagroup.com
*
*/
public class ImageServiceImpl implements ImageService {
private final HttpService httpService;
public ImageServiceImpl(HttpService httpService) {
super();
this.httpService = httpService;
}
@Override | public Image getImageFromUrl(URL imageUrl) throws IOException { |
alexdeleon/lupa | src/main/java/com/lumata/lib/lupa/internal/ImageServiceImpl.java | // Path: src/main/java/com/lumata/lib/lupa/HttpService.java
// @Service
// public interface HttpService {
//
// ReadableResource getRawResource(URL url);
//
// TextReadableResource getTextResource(URL url);
//
// TextReadableResource getTextResource(ReadableResource resource);
//
// }
//
// Path: src/main/java/com/lumata/lib/lupa/ImageService.java
// public interface ImageService {
//
// /**
// * Extracts image metadata from the specified URL. If it is unable to determine that the given URL contains an image
// * this methods returns <strong>null</strong>.
// *
// * @param imageUrl
// * @return an Image object or null if no image found at the given URL.
// * @throws IOException
// * if something goes wrong connecting to the image source.
// * @throws HttpException
// */
// Image getImageFromUrl(URL imageUrl) throws IOException;
//
// /**
// * Extracts image metadata from the specified resource. If it is unable to determine that the given URL contains an
// * image this methods returns <strong>null</strong>.
// *
// * @param resource
// * @return an Image object or null if no image found at the given URL.
// * @throws IOException
// * if something goes wrong connecting to the image source.
// * @throws HttpException
// */
// Image getImageFromResource(ReadableResource resource) throws IOException;
//
// }
//
// Path: src/main/java/com/lumata/lib/lupa/ReadableResource.java
// public interface ReadableResource {
//
// URL getUrl();
//
// /**
// * Move the current URL to the redirection path and set the specified url as the actual resource url.
// *
// * @param url
// * the redirectionUrl
// */
// void makeRedirection(URL url);
//
// Optional<URL[]> getRedirectionPath();
//
// Optional<MediaType> getContentType();
//
// InputStream read() throws IOException;
//
// void discard();
// }
//
// Path: src/main/java/com/lumata/lib/lupa/content/Image.java
// public class Image extends WebContent {
//
// private Integer width, height;
//
// public Image(String url, String... aliasUrls) {
// super(url, aliasUrls);
// }
//
// /**
// * @return the width in pixels
// */
// public Integer getWidth() {
// return width;
// }
//
// /**
// * @param width
// * the width in pixels to set
// */
// public void setWidth(Integer width) {
// this.width = width;
// }
//
// /**
// * @return the height in pixels
// */
// public Integer getHeight() {
// return height;
// }
//
// /**
// * @param height
// * the height in pixels to set
// */
// public void setHeight(Integer height) {
// this.height = height;
// }
//
// @Override
// public Type getType() {
// return Type.IMAGE;
// }
//
// @Override
// public String toString() {
// return toStringHelper(this).add("with", width).add("height", height).toString();
// }
// }
| import com.lumata.lib.lupa.HttpService;
import com.lumata.lib.lupa.ImageService;
import com.lumata.lib.lupa.ReadableResource;
import com.lumata.lib.lupa.content.Image;
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
import java.util.Iterator;
import javax.imageio.ImageIO;
import javax.imageio.ImageReader;
import javax.imageio.stream.ImageInputStream;
import com.google.common.net.MediaType; | /**
* Copyright (c) 2013 Lumata
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package com.lumata.lib.lupa.internal;
/**
* @author Alexander De Leon - alexander.leon@lumatagroup.com
*
*/
public class ImageServiceImpl implements ImageService {
private final HttpService httpService;
public ImageServiceImpl(HttpService httpService) {
super();
this.httpService = httpService;
}
@Override
public Image getImageFromUrl(URL imageUrl) throws IOException { | // Path: src/main/java/com/lumata/lib/lupa/HttpService.java
// @Service
// public interface HttpService {
//
// ReadableResource getRawResource(URL url);
//
// TextReadableResource getTextResource(URL url);
//
// TextReadableResource getTextResource(ReadableResource resource);
//
// }
//
// Path: src/main/java/com/lumata/lib/lupa/ImageService.java
// public interface ImageService {
//
// /**
// * Extracts image metadata from the specified URL. If it is unable to determine that the given URL contains an image
// * this methods returns <strong>null</strong>.
// *
// * @param imageUrl
// * @return an Image object or null if no image found at the given URL.
// * @throws IOException
// * if something goes wrong connecting to the image source.
// * @throws HttpException
// */
// Image getImageFromUrl(URL imageUrl) throws IOException;
//
// /**
// * Extracts image metadata from the specified resource. If it is unable to determine that the given URL contains an
// * image this methods returns <strong>null</strong>.
// *
// * @param resource
// * @return an Image object or null if no image found at the given URL.
// * @throws IOException
// * if something goes wrong connecting to the image source.
// * @throws HttpException
// */
// Image getImageFromResource(ReadableResource resource) throws IOException;
//
// }
//
// Path: src/main/java/com/lumata/lib/lupa/ReadableResource.java
// public interface ReadableResource {
//
// URL getUrl();
//
// /**
// * Move the current URL to the redirection path and set the specified url as the actual resource url.
// *
// * @param url
// * the redirectionUrl
// */
// void makeRedirection(URL url);
//
// Optional<URL[]> getRedirectionPath();
//
// Optional<MediaType> getContentType();
//
// InputStream read() throws IOException;
//
// void discard();
// }
//
// Path: src/main/java/com/lumata/lib/lupa/content/Image.java
// public class Image extends WebContent {
//
// private Integer width, height;
//
// public Image(String url, String... aliasUrls) {
// super(url, aliasUrls);
// }
//
// /**
// * @return the width in pixels
// */
// public Integer getWidth() {
// return width;
// }
//
// /**
// * @param width
// * the width in pixels to set
// */
// public void setWidth(Integer width) {
// this.width = width;
// }
//
// /**
// * @return the height in pixels
// */
// public Integer getHeight() {
// return height;
// }
//
// /**
// * @param height
// * the height in pixels to set
// */
// public void setHeight(Integer height) {
// this.height = height;
// }
//
// @Override
// public Type getType() {
// return Type.IMAGE;
// }
//
// @Override
// public String toString() {
// return toStringHelper(this).add("with", width).add("height", height).toString();
// }
// }
// Path: src/main/java/com/lumata/lib/lupa/internal/ImageServiceImpl.java
import com.lumata.lib.lupa.HttpService;
import com.lumata.lib.lupa.ImageService;
import com.lumata.lib.lupa.ReadableResource;
import com.lumata.lib.lupa.content.Image;
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
import java.util.Iterator;
import javax.imageio.ImageIO;
import javax.imageio.ImageReader;
import javax.imageio.stream.ImageInputStream;
import com.google.common.net.MediaType;
/**
* Copyright (c) 2013 Lumata
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package com.lumata.lib.lupa.internal;
/**
* @author Alexander De Leon - alexander.leon@lumatagroup.com
*
*/
public class ImageServiceImpl implements ImageService {
private final HttpService httpService;
public ImageServiceImpl(HttpService httpService) {
super();
this.httpService = httpService;
}
@Override
public Image getImageFromUrl(URL imageUrl) throws IOException { | ReadableResource resource = httpService.getRawResource(imageUrl); |
alexdeleon/lupa | src/main/java/com/lumata/lib/lupa/extractor/internal/HtmlBiggestImageExtractor.java | // Path: src/main/java/com/lumata/lib/lupa/ImageService.java
// public interface ImageService {
//
// /**
// * Extracts image metadata from the specified URL. If it is unable to determine that the given URL contains an image
// * this methods returns <strong>null</strong>.
// *
// * @param imageUrl
// * @return an Image object or null if no image found at the given URL.
// * @throws IOException
// * if something goes wrong connecting to the image source.
// * @throws HttpException
// */
// Image getImageFromUrl(URL imageUrl) throws IOException;
//
// /**
// * Extracts image metadata from the specified resource. If it is unable to determine that the given URL contains an
// * image this methods returns <strong>null</strong>.
// *
// * @param resource
// * @return an Image object or null if no image found at the given URL.
// * @throws IOException
// * if something goes wrong connecting to the image source.
// * @throws HttpException
// */
// Image getImageFromResource(ReadableResource resource) throws IOException;
//
// }
//
// Path: src/main/java/com/lumata/lib/lupa/content/Image.java
// public class Image extends WebContent {
//
// private Integer width, height;
//
// public Image(String url, String... aliasUrls) {
// super(url, aliasUrls);
// }
//
// /**
// * @return the width in pixels
// */
// public Integer getWidth() {
// return width;
// }
//
// /**
// * @param width
// * the width in pixels to set
// */
// public void setWidth(Integer width) {
// this.width = width;
// }
//
// /**
// * @return the height in pixels
// */
// public Integer getHeight() {
// return height;
// }
//
// /**
// * @param height
// * the height in pixels to set
// */
// public void setHeight(Integer height) {
// this.height = height;
// }
//
// @Override
// public Type getType() {
// return Type.IMAGE;
// }
//
// @Override
// public String toString() {
// return toStringHelper(this).add("with", width).add("height", height).toString();
// }
// }
| import java.net.URL;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Map;
import java.util.NoSuchElementException;
import java.util.Set;
import java.util.concurrent.Callable;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.ThreadFactory;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.concurrent.BasicThreadFactory;
import org.jsoup.nodes.Element;
import org.jsoup.select.Elements;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.lumata.lib.lupa.ImageService;
import com.lumata.lib.lupa.content.Image; | /**
* Copyright (c) 2013 Lumata
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package com.lumata.lib.lupa.extractor.internal;
/**
* @author Alexander De Leon - alexander.leon@lumatagroup.com
*
*/
public class HtmlBiggestImageExtractor implements HtmlImageExtractor {
private static final Logger LOG = LoggerFactory.getLogger(HtmlBiggestImageExtractor.class);
private static final String WIDTH_ATTRIBUTE = "width";
private static final String HEIGHT_ATTRIBUTE = "height";
| // Path: src/main/java/com/lumata/lib/lupa/ImageService.java
// public interface ImageService {
//
// /**
// * Extracts image metadata from the specified URL. If it is unable to determine that the given URL contains an image
// * this methods returns <strong>null</strong>.
// *
// * @param imageUrl
// * @return an Image object or null if no image found at the given URL.
// * @throws IOException
// * if something goes wrong connecting to the image source.
// * @throws HttpException
// */
// Image getImageFromUrl(URL imageUrl) throws IOException;
//
// /**
// * Extracts image metadata from the specified resource. If it is unable to determine that the given URL contains an
// * image this methods returns <strong>null</strong>.
// *
// * @param resource
// * @return an Image object or null if no image found at the given URL.
// * @throws IOException
// * if something goes wrong connecting to the image source.
// * @throws HttpException
// */
// Image getImageFromResource(ReadableResource resource) throws IOException;
//
// }
//
// Path: src/main/java/com/lumata/lib/lupa/content/Image.java
// public class Image extends WebContent {
//
// private Integer width, height;
//
// public Image(String url, String... aliasUrls) {
// super(url, aliasUrls);
// }
//
// /**
// * @return the width in pixels
// */
// public Integer getWidth() {
// return width;
// }
//
// /**
// * @param width
// * the width in pixels to set
// */
// public void setWidth(Integer width) {
// this.width = width;
// }
//
// /**
// * @return the height in pixels
// */
// public Integer getHeight() {
// return height;
// }
//
// /**
// * @param height
// * the height in pixels to set
// */
// public void setHeight(Integer height) {
// this.height = height;
// }
//
// @Override
// public Type getType() {
// return Type.IMAGE;
// }
//
// @Override
// public String toString() {
// return toStringHelper(this).add("with", width).add("height", height).toString();
// }
// }
// Path: src/main/java/com/lumata/lib/lupa/extractor/internal/HtmlBiggestImageExtractor.java
import java.net.URL;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Map;
import java.util.NoSuchElementException;
import java.util.Set;
import java.util.concurrent.Callable;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.ThreadFactory;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.concurrent.BasicThreadFactory;
import org.jsoup.nodes.Element;
import org.jsoup.select.Elements;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.lumata.lib.lupa.ImageService;
import com.lumata.lib.lupa.content.Image;
/**
* Copyright (c) 2013 Lumata
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package com.lumata.lib.lupa.extractor.internal;
/**
* @author Alexander De Leon - alexander.leon@lumatagroup.com
*
*/
public class HtmlBiggestImageExtractor implements HtmlImageExtractor {
private static final Logger LOG = LoggerFactory.getLogger(HtmlBiggestImageExtractor.class);
private static final String WIDTH_ATTRIBUTE = "width";
private static final String HEIGHT_ATTRIBUTE = "height";
| private final ImageService imageService; |
alexdeleon/lupa | src/main/java/com/lumata/lib/lupa/extractor/internal/HtmlBiggestImageExtractor.java | // Path: src/main/java/com/lumata/lib/lupa/ImageService.java
// public interface ImageService {
//
// /**
// * Extracts image metadata from the specified URL. If it is unable to determine that the given URL contains an image
// * this methods returns <strong>null</strong>.
// *
// * @param imageUrl
// * @return an Image object or null if no image found at the given URL.
// * @throws IOException
// * if something goes wrong connecting to the image source.
// * @throws HttpException
// */
// Image getImageFromUrl(URL imageUrl) throws IOException;
//
// /**
// * Extracts image metadata from the specified resource. If it is unable to determine that the given URL contains an
// * image this methods returns <strong>null</strong>.
// *
// * @param resource
// * @return an Image object or null if no image found at the given URL.
// * @throws IOException
// * if something goes wrong connecting to the image source.
// * @throws HttpException
// */
// Image getImageFromResource(ReadableResource resource) throws IOException;
//
// }
//
// Path: src/main/java/com/lumata/lib/lupa/content/Image.java
// public class Image extends WebContent {
//
// private Integer width, height;
//
// public Image(String url, String... aliasUrls) {
// super(url, aliasUrls);
// }
//
// /**
// * @return the width in pixels
// */
// public Integer getWidth() {
// return width;
// }
//
// /**
// * @param width
// * the width in pixels to set
// */
// public void setWidth(Integer width) {
// this.width = width;
// }
//
// /**
// * @return the height in pixels
// */
// public Integer getHeight() {
// return height;
// }
//
// /**
// * @param height
// * the height in pixels to set
// */
// public void setHeight(Integer height) {
// this.height = height;
// }
//
// @Override
// public Type getType() {
// return Type.IMAGE;
// }
//
// @Override
// public String toString() {
// return toStringHelper(this).add("with", width).add("height", height).toString();
// }
// }
| import java.net.URL;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Map;
import java.util.NoSuchElementException;
import java.util.Set;
import java.util.concurrent.Callable;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.ThreadFactory;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.concurrent.BasicThreadFactory;
import org.jsoup.nodes.Element;
import org.jsoup.select.Elements;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.lumata.lib.lupa.ImageService;
import com.lumata.lib.lupa.content.Image; | /**
* Copyright (c) 2013 Lumata
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package com.lumata.lib.lupa.extractor.internal;
/**
* @author Alexander De Leon - alexander.leon@lumatagroup.com
*
*/
public class HtmlBiggestImageExtractor implements HtmlImageExtractor {
private static final Logger LOG = LoggerFactory.getLogger(HtmlBiggestImageExtractor.class);
private static final String WIDTH_ATTRIBUTE = "width";
private static final String HEIGHT_ATTRIBUTE = "height";
private final ImageService imageService;
public HtmlBiggestImageExtractor(ImageService imageService) {
this.imageService = imageService;
}
@Override | // Path: src/main/java/com/lumata/lib/lupa/ImageService.java
// public interface ImageService {
//
// /**
// * Extracts image metadata from the specified URL. If it is unable to determine that the given URL contains an image
// * this methods returns <strong>null</strong>.
// *
// * @param imageUrl
// * @return an Image object or null if no image found at the given URL.
// * @throws IOException
// * if something goes wrong connecting to the image source.
// * @throws HttpException
// */
// Image getImageFromUrl(URL imageUrl) throws IOException;
//
// /**
// * Extracts image metadata from the specified resource. If it is unable to determine that the given URL contains an
// * image this methods returns <strong>null</strong>.
// *
// * @param resource
// * @return an Image object or null if no image found at the given URL.
// * @throws IOException
// * if something goes wrong connecting to the image source.
// * @throws HttpException
// */
// Image getImageFromResource(ReadableResource resource) throws IOException;
//
// }
//
// Path: src/main/java/com/lumata/lib/lupa/content/Image.java
// public class Image extends WebContent {
//
// private Integer width, height;
//
// public Image(String url, String... aliasUrls) {
// super(url, aliasUrls);
// }
//
// /**
// * @return the width in pixels
// */
// public Integer getWidth() {
// return width;
// }
//
// /**
// * @param width
// * the width in pixels to set
// */
// public void setWidth(Integer width) {
// this.width = width;
// }
//
// /**
// * @return the height in pixels
// */
// public Integer getHeight() {
// return height;
// }
//
// /**
// * @param height
// * the height in pixels to set
// */
// public void setHeight(Integer height) {
// this.height = height;
// }
//
// @Override
// public Type getType() {
// return Type.IMAGE;
// }
//
// @Override
// public String toString() {
// return toStringHelper(this).add("with", width).add("height", height).toString();
// }
// }
// Path: src/main/java/com/lumata/lib/lupa/extractor/internal/HtmlBiggestImageExtractor.java
import java.net.URL;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Map;
import java.util.NoSuchElementException;
import java.util.Set;
import java.util.concurrent.Callable;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.ThreadFactory;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.concurrent.BasicThreadFactory;
import org.jsoup.nodes.Element;
import org.jsoup.select.Elements;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.lumata.lib.lupa.ImageService;
import com.lumata.lib.lupa.content.Image;
/**
* Copyright (c) 2013 Lumata
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package com.lumata.lib.lupa.extractor.internal;
/**
* @author Alexander De Leon - alexander.leon@lumatagroup.com
*
*/
public class HtmlBiggestImageExtractor implements HtmlImageExtractor {
private static final Logger LOG = LoggerFactory.getLogger(HtmlBiggestImageExtractor.class);
private static final String WIDTH_ATTRIBUTE = "width";
private static final String HEIGHT_ATTRIBUTE = "height";
private final ImageService imageService;
public HtmlBiggestImageExtractor(ImageService imageService) {
this.imageService = imageService;
}
@Override | public Image extractBestImage(URL sourceUrl, Elements htmlSection) { |
alexdeleon/lupa | src/main/java/com/lumata/lib/lupa/internal/TextReadableResourceDecorator.java | // Path: src/main/java/com/lumata/lib/lupa/ReadableResource.java
// public interface ReadableResource {
//
// URL getUrl();
//
// /**
// * Move the current URL to the redirection path and set the specified url as the actual resource url.
// *
// * @param url
// * the redirectionUrl
// */
// void makeRedirection(URL url);
//
// Optional<URL[]> getRedirectionPath();
//
// Optional<MediaType> getContentType();
//
// InputStream read() throws IOException;
//
// void discard();
// }
//
// Path: src/main/java/com/lumata/lib/lupa/TextReadableResource.java
// public interface TextReadableResource extends ReadableResource {
//
// /**
// * Tries to discover the encoding of the resources and use it to consume this resource as text.
// *
// * @return a {@link Reader}
// */
// Reader readAsText() throws IOException;
//
// /**
// * Uses the specified {@link Charset} to consume this resource as text.
// *
// * @return a {@link Reader}
// */
// Reader readAsText(Charset charset) throws IOException;
//
// }
| import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.google.common.base.Optional;
import com.google.common.net.MediaType;
import com.lumata.lib.lupa.ReadableResource;
import com.lumata.lib.lupa.TextReadableResource;
import java.io.BufferedInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.Reader;
import java.io.UnsupportedEncodingException;
import java.net.URL;
import java.net.URLConnection;
import java.nio.charset.Charset; | /**
* Copyright (c) 2013 Lumata
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package com.lumata.lib.lupa.internal;
/**
* @author Alexander De Leon - alexander.leon@lumatagroup.com
*
*/
public class TextReadableResourceDecorator implements TextReadableResource {
private static final Logger LOG = LoggerFactory.getLogger(TextReadableResourceDecorator.class);
private static final int BUFFER_SIZE = 1024;
| // Path: src/main/java/com/lumata/lib/lupa/ReadableResource.java
// public interface ReadableResource {
//
// URL getUrl();
//
// /**
// * Move the current URL to the redirection path and set the specified url as the actual resource url.
// *
// * @param url
// * the redirectionUrl
// */
// void makeRedirection(URL url);
//
// Optional<URL[]> getRedirectionPath();
//
// Optional<MediaType> getContentType();
//
// InputStream read() throws IOException;
//
// void discard();
// }
//
// Path: src/main/java/com/lumata/lib/lupa/TextReadableResource.java
// public interface TextReadableResource extends ReadableResource {
//
// /**
// * Tries to discover the encoding of the resources and use it to consume this resource as text.
// *
// * @return a {@link Reader}
// */
// Reader readAsText() throws IOException;
//
// /**
// * Uses the specified {@link Charset} to consume this resource as text.
// *
// * @return a {@link Reader}
// */
// Reader readAsText(Charset charset) throws IOException;
//
// }
// Path: src/main/java/com/lumata/lib/lupa/internal/TextReadableResourceDecorator.java
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.google.common.base.Optional;
import com.google.common.net.MediaType;
import com.lumata.lib.lupa.ReadableResource;
import com.lumata.lib.lupa.TextReadableResource;
import java.io.BufferedInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.Reader;
import java.io.UnsupportedEncodingException;
import java.net.URL;
import java.net.URLConnection;
import java.nio.charset.Charset;
/**
* Copyright (c) 2013 Lumata
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package com.lumata.lib.lupa.internal;
/**
* @author Alexander De Leon - alexander.leon@lumatagroup.com
*
*/
public class TextReadableResourceDecorator implements TextReadableResource {
private static final Logger LOG = LoggerFactory.getLogger(TextReadableResourceDecorator.class);
private static final int BUFFER_SIZE = 1024;
| private final ReadableResource resource; |
alexdeleon/lupa | src/main/java/com/lumata/lib/lupa/cli/Lupa.java | // Path: src/main/java/com/lumata/lib/lupa/Scraper.java
// @Service
// public interface Scraper {
//
// /**
// * Extract the list of structured contents from the given URL.
// *
// * @param url
// * of the web resource
// * @return the {@link WebContent} object describing the contents of the URL and all alias URLs. Or null if no
// * content is found.
// * @throws IOException
// * is an IO error occurs while connecting to the URL.
// * @throws HttpException
// */
// WebContent scrapContent(String url) throws IOException;
//
// /**
// * Extract the list of structured contents from the given URL.
// *
// * @param url
// * of the web resource
// * @return the {@link WebContent} object describing the contents of the URL and all alias URLs. Or null if no
// * content is found.
// * @throws IOException
// * is an IO error occurs while connecting to the URL.
// * @throws HttpException
// */
// <E extends WebContent> E scrapContent(String url, Class<E> contentType) throws IOException;
//
// /**
// * Extract the list of structured contents from the given URL.
// *
// * @param url
// * of the web resource
// * @return the {@link WebContent} object describing the contents of the URL and all alias URLs. Or null if no
// * content is found.
// * @throws IOException
// * is an IO error occurs while connecting to the URL.
// * @throws HttpException
// */
// WebContent scrapContent(ReadableResource resource) throws IOException;
//
// /**
// * Extract the list of structured contents from the given URL.
// *
// * @param url
// * of the web resource
// * @return the {@link WebContent} object describing the contents of the URL and all alias URLs. Or null if no
// * content is found.
// * @throws IOException
// * is an IO error occurs while connecting to the URL.
// * @throws HttpException
// */
// <E extends WebContent> E scrapContent(ReadableResource resource, Class<E> contentType) throws IOException;
//
// }
| import java.io.PrintStream;
import org.apache.commons.cli.CommandLine;
import org.apache.commons.cli.CommandLineParser;
import org.apache.commons.cli.GnuParser;
import org.apache.commons.cli.HelpFormatter;
import org.apache.commons.cli.Options;
import org.apache.commons.cli.ParseException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import com.lumata.lib.lupa.Scraper; | Lupa lupa = new Lupa();
lupa.run(args);
}
private Lupa() {
options = createOptions();
}
private Options createOptions() {
Options options = new Options();
options.addOption("h", false, "Print help");
return options;
}
public final void run(String[] args) {
try {
CommandLine line = parseCommandLine(args);
int result = execute(line);
System.exit(result);
} catch (ParseException exp) {
printUsage();
} catch (Throwable exp) {
LOG.error("Unexpected error", exp);
}
}
private int execute(CommandLine line) {
if (line.hasOption("h") || line.getArgList().isEmpty()) {
printUsage();
} else { | // Path: src/main/java/com/lumata/lib/lupa/Scraper.java
// @Service
// public interface Scraper {
//
// /**
// * Extract the list of structured contents from the given URL.
// *
// * @param url
// * of the web resource
// * @return the {@link WebContent} object describing the contents of the URL and all alias URLs. Or null if no
// * content is found.
// * @throws IOException
// * is an IO error occurs while connecting to the URL.
// * @throws HttpException
// */
// WebContent scrapContent(String url) throws IOException;
//
// /**
// * Extract the list of structured contents from the given URL.
// *
// * @param url
// * of the web resource
// * @return the {@link WebContent} object describing the contents of the URL and all alias URLs. Or null if no
// * content is found.
// * @throws IOException
// * is an IO error occurs while connecting to the URL.
// * @throws HttpException
// */
// <E extends WebContent> E scrapContent(String url, Class<E> contentType) throws IOException;
//
// /**
// * Extract the list of structured contents from the given URL.
// *
// * @param url
// * of the web resource
// * @return the {@link WebContent} object describing the contents of the URL and all alias URLs. Or null if no
// * content is found.
// * @throws IOException
// * is an IO error occurs while connecting to the URL.
// * @throws HttpException
// */
// WebContent scrapContent(ReadableResource resource) throws IOException;
//
// /**
// * Extract the list of structured contents from the given URL.
// *
// * @param url
// * of the web resource
// * @return the {@link WebContent} object describing the contents of the URL and all alias URLs. Or null if no
// * content is found.
// * @throws IOException
// * is an IO error occurs while connecting to the URL.
// * @throws HttpException
// */
// <E extends WebContent> E scrapContent(ReadableResource resource, Class<E> contentType) throws IOException;
//
// }
// Path: src/main/java/com/lumata/lib/lupa/cli/Lupa.java
import java.io.PrintStream;
import org.apache.commons.cli.CommandLine;
import org.apache.commons.cli.CommandLineParser;
import org.apache.commons.cli.GnuParser;
import org.apache.commons.cli.HelpFormatter;
import org.apache.commons.cli.Options;
import org.apache.commons.cli.ParseException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import com.lumata.lib.lupa.Scraper;
Lupa lupa = new Lupa();
lupa.run(args);
}
private Lupa() {
options = createOptions();
}
private Options createOptions() {
Options options = new Options();
options.addOption("h", false, "Print help");
return options;
}
public final void run(String[] args) {
try {
CommandLine line = parseCommandLine(args);
int result = execute(line);
System.exit(result);
} catch (ParseException exp) {
printUsage();
} catch (Throwable exp) {
LOG.error("Unexpected error", exp);
}
}
private int execute(CommandLine line) {
if (line.hasOption("h") || line.getArgList().isEmpty()) {
printUsage();
} else { | Scraper scraper = loadStringContextAndGetScraper(); |
alexdeleon/lupa | src/main/java/com/lumata/lib/lupa/internal/HttpServiceImpl.java | // Path: src/main/java/com/lumata/lib/lupa/HttpService.java
// @Service
// public interface HttpService {
//
// ReadableResource getRawResource(URL url);
//
// TextReadableResource getTextResource(URL url);
//
// TextReadableResource getTextResource(ReadableResource resource);
//
// }
//
// Path: src/main/java/com/lumata/lib/lupa/ReadableResource.java
// public interface ReadableResource {
//
// URL getUrl();
//
// /**
// * Move the current URL to the redirection path and set the specified url as the actual resource url.
// *
// * @param url
// * the redirectionUrl
// */
// void makeRedirection(URL url);
//
// Optional<URL[]> getRedirectionPath();
//
// Optional<MediaType> getContentType();
//
// InputStream read() throws IOException;
//
// void discard();
// }
//
// Path: src/main/java/com/lumata/lib/lupa/TextReadableResource.java
// public interface TextReadableResource extends ReadableResource {
//
// /**
// * Tries to discover the encoding of the resources and use it to consume this resource as text.
// *
// * @return a {@link Reader}
// */
// Reader readAsText() throws IOException;
//
// /**
// * Uses the specified {@link Charset} to consume this resource as text.
// *
// * @return a {@link Reader}
// */
// Reader readAsText(Charset charset) throws IOException;
//
// }
| import java.net.URL;
import org.apache.http.client.HttpClient;
import com.lumata.lib.lupa.HttpService;
import com.lumata.lib.lupa.ReadableResource;
import com.lumata.lib.lupa.TextReadableResource; | /**
* Copyright (c) 2013 Lumata
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package com.lumata.lib.lupa.internal;
/**
* @author Alexander De Leon - alexander.leon@lumatagroup.com
*
*/
public class HttpServiceImpl implements HttpService {
private final HttpClient httpClient;
public HttpServiceImpl(HttpClient httpClient) {
this.httpClient = httpClient;
}
@Override | // Path: src/main/java/com/lumata/lib/lupa/HttpService.java
// @Service
// public interface HttpService {
//
// ReadableResource getRawResource(URL url);
//
// TextReadableResource getTextResource(URL url);
//
// TextReadableResource getTextResource(ReadableResource resource);
//
// }
//
// Path: src/main/java/com/lumata/lib/lupa/ReadableResource.java
// public interface ReadableResource {
//
// URL getUrl();
//
// /**
// * Move the current URL to the redirection path and set the specified url as the actual resource url.
// *
// * @param url
// * the redirectionUrl
// */
// void makeRedirection(URL url);
//
// Optional<URL[]> getRedirectionPath();
//
// Optional<MediaType> getContentType();
//
// InputStream read() throws IOException;
//
// void discard();
// }
//
// Path: src/main/java/com/lumata/lib/lupa/TextReadableResource.java
// public interface TextReadableResource extends ReadableResource {
//
// /**
// * Tries to discover the encoding of the resources and use it to consume this resource as text.
// *
// * @return a {@link Reader}
// */
// Reader readAsText() throws IOException;
//
// /**
// * Uses the specified {@link Charset} to consume this resource as text.
// *
// * @return a {@link Reader}
// */
// Reader readAsText(Charset charset) throws IOException;
//
// }
// Path: src/main/java/com/lumata/lib/lupa/internal/HttpServiceImpl.java
import java.net.URL;
import org.apache.http.client.HttpClient;
import com.lumata.lib.lupa.HttpService;
import com.lumata.lib.lupa.ReadableResource;
import com.lumata.lib.lupa.TextReadableResource;
/**
* Copyright (c) 2013 Lumata
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package com.lumata.lib.lupa.internal;
/**
* @author Alexander De Leon - alexander.leon@lumatagroup.com
*
*/
public class HttpServiceImpl implements HttpService {
private final HttpClient httpClient;
public HttpServiceImpl(HttpClient httpClient) {
this.httpClient = httpClient;
}
@Override | public ReadableResource getRawResource(URL url) { |
alexdeleon/lupa | src/main/java/com/lumata/lib/lupa/internal/HttpServiceImpl.java | // Path: src/main/java/com/lumata/lib/lupa/HttpService.java
// @Service
// public interface HttpService {
//
// ReadableResource getRawResource(URL url);
//
// TextReadableResource getTextResource(URL url);
//
// TextReadableResource getTextResource(ReadableResource resource);
//
// }
//
// Path: src/main/java/com/lumata/lib/lupa/ReadableResource.java
// public interface ReadableResource {
//
// URL getUrl();
//
// /**
// * Move the current URL to the redirection path and set the specified url as the actual resource url.
// *
// * @param url
// * the redirectionUrl
// */
// void makeRedirection(URL url);
//
// Optional<URL[]> getRedirectionPath();
//
// Optional<MediaType> getContentType();
//
// InputStream read() throws IOException;
//
// void discard();
// }
//
// Path: src/main/java/com/lumata/lib/lupa/TextReadableResource.java
// public interface TextReadableResource extends ReadableResource {
//
// /**
// * Tries to discover the encoding of the resources and use it to consume this resource as text.
// *
// * @return a {@link Reader}
// */
// Reader readAsText() throws IOException;
//
// /**
// * Uses the specified {@link Charset} to consume this resource as text.
// *
// * @return a {@link Reader}
// */
// Reader readAsText(Charset charset) throws IOException;
//
// }
| import java.net.URL;
import org.apache.http.client.HttpClient;
import com.lumata.lib.lupa.HttpService;
import com.lumata.lib.lupa.ReadableResource;
import com.lumata.lib.lupa.TextReadableResource; | /**
* Copyright (c) 2013 Lumata
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package com.lumata.lib.lupa.internal;
/**
* @author Alexander De Leon - alexander.leon@lumatagroup.com
*
*/
public class HttpServiceImpl implements HttpService {
private final HttpClient httpClient;
public HttpServiceImpl(HttpClient httpClient) {
this.httpClient = httpClient;
}
@Override
public ReadableResource getRawResource(URL url) {
return new ProxiedReadableResource(url, httpClient);
}
@Override | // Path: src/main/java/com/lumata/lib/lupa/HttpService.java
// @Service
// public interface HttpService {
//
// ReadableResource getRawResource(URL url);
//
// TextReadableResource getTextResource(URL url);
//
// TextReadableResource getTextResource(ReadableResource resource);
//
// }
//
// Path: src/main/java/com/lumata/lib/lupa/ReadableResource.java
// public interface ReadableResource {
//
// URL getUrl();
//
// /**
// * Move the current URL to the redirection path and set the specified url as the actual resource url.
// *
// * @param url
// * the redirectionUrl
// */
// void makeRedirection(URL url);
//
// Optional<URL[]> getRedirectionPath();
//
// Optional<MediaType> getContentType();
//
// InputStream read() throws IOException;
//
// void discard();
// }
//
// Path: src/main/java/com/lumata/lib/lupa/TextReadableResource.java
// public interface TextReadableResource extends ReadableResource {
//
// /**
// * Tries to discover the encoding of the resources and use it to consume this resource as text.
// *
// * @return a {@link Reader}
// */
// Reader readAsText() throws IOException;
//
// /**
// * Uses the specified {@link Charset} to consume this resource as text.
// *
// * @return a {@link Reader}
// */
// Reader readAsText(Charset charset) throws IOException;
//
// }
// Path: src/main/java/com/lumata/lib/lupa/internal/HttpServiceImpl.java
import java.net.URL;
import org.apache.http.client.HttpClient;
import com.lumata.lib.lupa.HttpService;
import com.lumata.lib.lupa.ReadableResource;
import com.lumata.lib.lupa.TextReadableResource;
/**
* Copyright (c) 2013 Lumata
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package com.lumata.lib.lupa.internal;
/**
* @author Alexander De Leon - alexander.leon@lumatagroup.com
*
*/
public class HttpServiceImpl implements HttpService {
private final HttpClient httpClient;
public HttpServiceImpl(HttpClient httpClient) {
this.httpClient = httpClient;
}
@Override
public ReadableResource getRawResource(URL url) {
return new ProxiedReadableResource(url, httpClient);
}
@Override | public TextReadableResource getTextResource(URL url) { |
alexdeleon/lupa | src/main/java/com/lumata/lib/lupa/Scraper.java | // Path: src/main/java/com/lumata/lib/lupa/content/WebContent.java
// public abstract class WebContent {
//
// public static enum Type {
// WEBPAGE,
// IMAGE,
// VIDEO,
// AUDIO,
// FEED
// }
//
// private final String url;
// private final String[] aliasUrls;
// private Set<String> keywords;
//
// WebContent(String url, String... aliasUrls) {
// this.url = url;
// this.aliasUrls = aliasUrls;
// }
//
// /**
// * Gets the preferred URL of this content
// *
// * @return the url
// */
// public String getUrl() {
// return url;
// }
//
// /**
// * Gets the known alias URLs where this content can be also located. The order is defined by the redirection path.
// *
// * @return the referingUrls
// */
// public String[] getAliasUrls() {
// return aliasUrls;
// }
//
// /**
// * @return the type of this web content.
// */
// public abstract Type getType();
//
// /**
// * @return the keywords of this web content.
// */
// public Set<String> getKeywords() {
// return keywords;
// }
//
// /**
// * @param keywords
// * the keywords to set
// */
// public void setKeywords(Set<String> keywords) {
// this.keywords = keywords;
// }
//
// @Override
// public int hashCode() {
// return Objects.hashCode(url, getType());
// }
//
// @Override
// public boolean equals(Object obj) {
// if (obj == null || !(obj instanceof WebContent)) {
// return false;
// }
// WebContent that = (WebContent) obj;
// return Objects.equal(this.url, that.url) && Objects.equal(this.getType(), that.getType())
// && Arrays.equals(this.aliasUrls, that.aliasUrls) && Objects.equal(this.keywords, that.keywords);
// }
//
// protected ToStringHelper toStringHelper(Object instance) {
// return Objects.toStringHelper(this).omitNullValues().add("url", url)
// .add("aliasUrls", Arrays.toString(aliasUrls)).add("keywords", keywords);
// }
//
// }
| import org.springframework.stereotype.Service;
import com.lumata.lib.lupa.content.WebContent;
import java.io.IOException; | /**
* Copyright (c) 2013 Lumata
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package com.lumata.lib.lupa;
/**
* Scraps the content of a URL and returns metadata information about it.
*
* @author Alexander De Leon - alexander.leon@lumatagroup.com
*
*/
@Service
public interface Scraper {
/**
* Extract the list of structured contents from the given URL.
*
* @param url
* of the web resource
* @return the {@link WebContent} object describing the contents of the URL and all alias URLs. Or null if no
* content is found.
* @throws IOException
* is an IO error occurs while connecting to the URL.
* @throws HttpException
*/ | // Path: src/main/java/com/lumata/lib/lupa/content/WebContent.java
// public abstract class WebContent {
//
// public static enum Type {
// WEBPAGE,
// IMAGE,
// VIDEO,
// AUDIO,
// FEED
// }
//
// private final String url;
// private final String[] aliasUrls;
// private Set<String> keywords;
//
// WebContent(String url, String... aliasUrls) {
// this.url = url;
// this.aliasUrls = aliasUrls;
// }
//
// /**
// * Gets the preferred URL of this content
// *
// * @return the url
// */
// public String getUrl() {
// return url;
// }
//
// /**
// * Gets the known alias URLs where this content can be also located. The order is defined by the redirection path.
// *
// * @return the referingUrls
// */
// public String[] getAliasUrls() {
// return aliasUrls;
// }
//
// /**
// * @return the type of this web content.
// */
// public abstract Type getType();
//
// /**
// * @return the keywords of this web content.
// */
// public Set<String> getKeywords() {
// return keywords;
// }
//
// /**
// * @param keywords
// * the keywords to set
// */
// public void setKeywords(Set<String> keywords) {
// this.keywords = keywords;
// }
//
// @Override
// public int hashCode() {
// return Objects.hashCode(url, getType());
// }
//
// @Override
// public boolean equals(Object obj) {
// if (obj == null || !(obj instanceof WebContent)) {
// return false;
// }
// WebContent that = (WebContent) obj;
// return Objects.equal(this.url, that.url) && Objects.equal(this.getType(), that.getType())
// && Arrays.equals(this.aliasUrls, that.aliasUrls) && Objects.equal(this.keywords, that.keywords);
// }
//
// protected ToStringHelper toStringHelper(Object instance) {
// return Objects.toStringHelper(this).omitNullValues().add("url", url)
// .add("aliasUrls", Arrays.toString(aliasUrls)).add("keywords", keywords);
// }
//
// }
// Path: src/main/java/com/lumata/lib/lupa/Scraper.java
import org.springframework.stereotype.Service;
import com.lumata.lib.lupa.content.WebContent;
import java.io.IOException;
/**
* Copyright (c) 2013 Lumata
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package com.lumata.lib.lupa;
/**
* Scraps the content of a URL and returns metadata information about it.
*
* @author Alexander De Leon - alexander.leon@lumatagroup.com
*
*/
@Service
public interface Scraper {
/**
* Extract the list of structured contents from the given URL.
*
* @param url
* of the web resource
* @return the {@link WebContent} object describing the contents of the URL and all alias URLs. Or null if no
* content is found.
* @throws IOException
* is an IO error occurs while connecting to the URL.
* @throws HttpException
*/ | WebContent scrapContent(String url) throws IOException; |
alexdeleon/lupa | src/main/java/com/lumata/lib/lupa/extractor/internal/ContentExtractorMatcher.java | // Path: src/main/java/com/lumata/lib/lupa/ReadableResource.java
// public interface ReadableResource {
//
// URL getUrl();
//
// /**
// * Move the current URL to the redirection path and set the specified url as the actual resource url.
// *
// * @param url
// * the redirectionUrl
// */
// void makeRedirection(URL url);
//
// Optional<URL[]> getRedirectionPath();
//
// Optional<MediaType> getContentType();
//
// InputStream read() throws IOException;
//
// void discard();
// }
//
// Path: src/main/java/com/lumata/lib/lupa/content/WebContent.java
// public abstract class WebContent {
//
// public static enum Type {
// WEBPAGE,
// IMAGE,
// VIDEO,
// AUDIO,
// FEED
// }
//
// private final String url;
// private final String[] aliasUrls;
// private Set<String> keywords;
//
// WebContent(String url, String... aliasUrls) {
// this.url = url;
// this.aliasUrls = aliasUrls;
// }
//
// /**
// * Gets the preferred URL of this content
// *
// * @return the url
// */
// public String getUrl() {
// return url;
// }
//
// /**
// * Gets the known alias URLs where this content can be also located. The order is defined by the redirection path.
// *
// * @return the referingUrls
// */
// public String[] getAliasUrls() {
// return aliasUrls;
// }
//
// /**
// * @return the type of this web content.
// */
// public abstract Type getType();
//
// /**
// * @return the keywords of this web content.
// */
// public Set<String> getKeywords() {
// return keywords;
// }
//
// /**
// * @param keywords
// * the keywords to set
// */
// public void setKeywords(Set<String> keywords) {
// this.keywords = keywords;
// }
//
// @Override
// public int hashCode() {
// return Objects.hashCode(url, getType());
// }
//
// @Override
// public boolean equals(Object obj) {
// if (obj == null || !(obj instanceof WebContent)) {
// return false;
// }
// WebContent that = (WebContent) obj;
// return Objects.equal(this.url, that.url) && Objects.equal(this.getType(), that.getType())
// && Arrays.equals(this.aliasUrls, that.aliasUrls) && Objects.equal(this.keywords, that.keywords);
// }
//
// protected ToStringHelper toStringHelper(Object instance) {
// return Objects.toStringHelper(this).omitNullValues().add("url", url)
// .add("aliasUrls", Arrays.toString(aliasUrls)).add("keywords", keywords);
// }
//
// }
//
// Path: src/main/java/com/lumata/lib/lupa/extractor/ContentExtractor.java
// public interface ContentExtractor<E extends WebContent> {
//
// E extractContent(ReadableResource resource, ServiceLocator serviceLocator) throws IOException;
//
// void setConfiguration(Map<String, String> config);
//
// Class<E> getExtractableWebContentType();
//
// }
| import java.util.Map;
import org.apache.commons.collections.MapUtils;
import com.google.common.base.Objects;
import com.google.common.net.MediaType;
import com.lumata.lib.lupa.ReadableResource;
import com.lumata.lib.lupa.content.WebContent;
import com.lumata.lib.lupa.extractor.ContentExtractor; | /**
* Copyright (c) 2013 Lumata
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package com.lumata.lib.lupa.extractor.internal;
class ContentExtractorMatcher<E extends WebContent> implements
Comparable<ContentExtractorMatcher<? extends WebContent>> {
| // Path: src/main/java/com/lumata/lib/lupa/ReadableResource.java
// public interface ReadableResource {
//
// URL getUrl();
//
// /**
// * Move the current URL to the redirection path and set the specified url as the actual resource url.
// *
// * @param url
// * the redirectionUrl
// */
// void makeRedirection(URL url);
//
// Optional<URL[]> getRedirectionPath();
//
// Optional<MediaType> getContentType();
//
// InputStream read() throws IOException;
//
// void discard();
// }
//
// Path: src/main/java/com/lumata/lib/lupa/content/WebContent.java
// public abstract class WebContent {
//
// public static enum Type {
// WEBPAGE,
// IMAGE,
// VIDEO,
// AUDIO,
// FEED
// }
//
// private final String url;
// private final String[] aliasUrls;
// private Set<String> keywords;
//
// WebContent(String url, String... aliasUrls) {
// this.url = url;
// this.aliasUrls = aliasUrls;
// }
//
// /**
// * Gets the preferred URL of this content
// *
// * @return the url
// */
// public String getUrl() {
// return url;
// }
//
// /**
// * Gets the known alias URLs where this content can be also located. The order is defined by the redirection path.
// *
// * @return the referingUrls
// */
// public String[] getAliasUrls() {
// return aliasUrls;
// }
//
// /**
// * @return the type of this web content.
// */
// public abstract Type getType();
//
// /**
// * @return the keywords of this web content.
// */
// public Set<String> getKeywords() {
// return keywords;
// }
//
// /**
// * @param keywords
// * the keywords to set
// */
// public void setKeywords(Set<String> keywords) {
// this.keywords = keywords;
// }
//
// @Override
// public int hashCode() {
// return Objects.hashCode(url, getType());
// }
//
// @Override
// public boolean equals(Object obj) {
// if (obj == null || !(obj instanceof WebContent)) {
// return false;
// }
// WebContent that = (WebContent) obj;
// return Objects.equal(this.url, that.url) && Objects.equal(this.getType(), that.getType())
// && Arrays.equals(this.aliasUrls, that.aliasUrls) && Objects.equal(this.keywords, that.keywords);
// }
//
// protected ToStringHelper toStringHelper(Object instance) {
// return Objects.toStringHelper(this).omitNullValues().add("url", url)
// .add("aliasUrls", Arrays.toString(aliasUrls)).add("keywords", keywords);
// }
//
// }
//
// Path: src/main/java/com/lumata/lib/lupa/extractor/ContentExtractor.java
// public interface ContentExtractor<E extends WebContent> {
//
// E extractContent(ReadableResource resource, ServiceLocator serviceLocator) throws IOException;
//
// void setConfiguration(Map<String, String> config);
//
// Class<E> getExtractableWebContentType();
//
// }
// Path: src/main/java/com/lumata/lib/lupa/extractor/internal/ContentExtractorMatcher.java
import java.util.Map;
import org.apache.commons.collections.MapUtils;
import com.google.common.base.Objects;
import com.google.common.net.MediaType;
import com.lumata.lib.lupa.ReadableResource;
import com.lumata.lib.lupa.content.WebContent;
import com.lumata.lib.lupa.extractor.ContentExtractor;
/**
* Copyright (c) 2013 Lumata
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package com.lumata.lib.lupa.extractor.internal;
class ContentExtractorMatcher<E extends WebContent> implements
Comparable<ContentExtractorMatcher<? extends WebContent>> {
| private final ContentExtractor<E> contentExtractor; |
alexdeleon/lupa | src/main/java/com/lumata/lib/lupa/extractor/internal/ContentExtractorMatcher.java | // Path: src/main/java/com/lumata/lib/lupa/ReadableResource.java
// public interface ReadableResource {
//
// URL getUrl();
//
// /**
// * Move the current URL to the redirection path and set the specified url as the actual resource url.
// *
// * @param url
// * the redirectionUrl
// */
// void makeRedirection(URL url);
//
// Optional<URL[]> getRedirectionPath();
//
// Optional<MediaType> getContentType();
//
// InputStream read() throws IOException;
//
// void discard();
// }
//
// Path: src/main/java/com/lumata/lib/lupa/content/WebContent.java
// public abstract class WebContent {
//
// public static enum Type {
// WEBPAGE,
// IMAGE,
// VIDEO,
// AUDIO,
// FEED
// }
//
// private final String url;
// private final String[] aliasUrls;
// private Set<String> keywords;
//
// WebContent(String url, String... aliasUrls) {
// this.url = url;
// this.aliasUrls = aliasUrls;
// }
//
// /**
// * Gets the preferred URL of this content
// *
// * @return the url
// */
// public String getUrl() {
// return url;
// }
//
// /**
// * Gets the known alias URLs where this content can be also located. The order is defined by the redirection path.
// *
// * @return the referingUrls
// */
// public String[] getAliasUrls() {
// return aliasUrls;
// }
//
// /**
// * @return the type of this web content.
// */
// public abstract Type getType();
//
// /**
// * @return the keywords of this web content.
// */
// public Set<String> getKeywords() {
// return keywords;
// }
//
// /**
// * @param keywords
// * the keywords to set
// */
// public void setKeywords(Set<String> keywords) {
// this.keywords = keywords;
// }
//
// @Override
// public int hashCode() {
// return Objects.hashCode(url, getType());
// }
//
// @Override
// public boolean equals(Object obj) {
// if (obj == null || !(obj instanceof WebContent)) {
// return false;
// }
// WebContent that = (WebContent) obj;
// return Objects.equal(this.url, that.url) && Objects.equal(this.getType(), that.getType())
// && Arrays.equals(this.aliasUrls, that.aliasUrls) && Objects.equal(this.keywords, that.keywords);
// }
//
// protected ToStringHelper toStringHelper(Object instance) {
// return Objects.toStringHelper(this).omitNullValues().add("url", url)
// .add("aliasUrls", Arrays.toString(aliasUrls)).add("keywords", keywords);
// }
//
// }
//
// Path: src/main/java/com/lumata/lib/lupa/extractor/ContentExtractor.java
// public interface ContentExtractor<E extends WebContent> {
//
// E extractContent(ReadableResource resource, ServiceLocator serviceLocator) throws IOException;
//
// void setConfiguration(Map<String, String> config);
//
// Class<E> getExtractableWebContentType();
//
// }
| import java.util.Map;
import org.apache.commons.collections.MapUtils;
import com.google.common.base.Objects;
import com.google.common.net.MediaType;
import com.lumata.lib.lupa.ReadableResource;
import com.lumata.lib.lupa.content.WebContent;
import com.lumata.lib.lupa.extractor.ContentExtractor; | /**
* Copyright (c) 2013 Lumata
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package com.lumata.lib.lupa.extractor.internal;
class ContentExtractorMatcher<E extends WebContent> implements
Comparable<ContentExtractorMatcher<? extends WebContent>> {
private final ContentExtractor<E> contentExtractor;
Map<String, String> constraints;
int priority;
static final String CONTENT_TYPE = "type";
static final String URL = "url";
ContentExtractorMatcher(ContentExtractor<E> contentExtractor, Map<String, String> constraints, int priority) {
this.contentExtractor = contentExtractor;
this.constraints = constraints;
this.priority = priority;
}
/**
* @return the contentExtractor
*/
public ContentExtractor<E> getContentExtractor() {
return contentExtractor;
}
public boolean isCaplableOfExtracting(Class<? extends WebContent> webContentType) {
return contentExtractor.getExtractableWebContentType().isAssignableFrom(webContentType);
}
| // Path: src/main/java/com/lumata/lib/lupa/ReadableResource.java
// public interface ReadableResource {
//
// URL getUrl();
//
// /**
// * Move the current URL to the redirection path and set the specified url as the actual resource url.
// *
// * @param url
// * the redirectionUrl
// */
// void makeRedirection(URL url);
//
// Optional<URL[]> getRedirectionPath();
//
// Optional<MediaType> getContentType();
//
// InputStream read() throws IOException;
//
// void discard();
// }
//
// Path: src/main/java/com/lumata/lib/lupa/content/WebContent.java
// public abstract class WebContent {
//
// public static enum Type {
// WEBPAGE,
// IMAGE,
// VIDEO,
// AUDIO,
// FEED
// }
//
// private final String url;
// private final String[] aliasUrls;
// private Set<String> keywords;
//
// WebContent(String url, String... aliasUrls) {
// this.url = url;
// this.aliasUrls = aliasUrls;
// }
//
// /**
// * Gets the preferred URL of this content
// *
// * @return the url
// */
// public String getUrl() {
// return url;
// }
//
// /**
// * Gets the known alias URLs where this content can be also located. The order is defined by the redirection path.
// *
// * @return the referingUrls
// */
// public String[] getAliasUrls() {
// return aliasUrls;
// }
//
// /**
// * @return the type of this web content.
// */
// public abstract Type getType();
//
// /**
// * @return the keywords of this web content.
// */
// public Set<String> getKeywords() {
// return keywords;
// }
//
// /**
// * @param keywords
// * the keywords to set
// */
// public void setKeywords(Set<String> keywords) {
// this.keywords = keywords;
// }
//
// @Override
// public int hashCode() {
// return Objects.hashCode(url, getType());
// }
//
// @Override
// public boolean equals(Object obj) {
// if (obj == null || !(obj instanceof WebContent)) {
// return false;
// }
// WebContent that = (WebContent) obj;
// return Objects.equal(this.url, that.url) && Objects.equal(this.getType(), that.getType())
// && Arrays.equals(this.aliasUrls, that.aliasUrls) && Objects.equal(this.keywords, that.keywords);
// }
//
// protected ToStringHelper toStringHelper(Object instance) {
// return Objects.toStringHelper(this).omitNullValues().add("url", url)
// .add("aliasUrls", Arrays.toString(aliasUrls)).add("keywords", keywords);
// }
//
// }
//
// Path: src/main/java/com/lumata/lib/lupa/extractor/ContentExtractor.java
// public interface ContentExtractor<E extends WebContent> {
//
// E extractContent(ReadableResource resource, ServiceLocator serviceLocator) throws IOException;
//
// void setConfiguration(Map<String, String> config);
//
// Class<E> getExtractableWebContentType();
//
// }
// Path: src/main/java/com/lumata/lib/lupa/extractor/internal/ContentExtractorMatcher.java
import java.util.Map;
import org.apache.commons.collections.MapUtils;
import com.google.common.base.Objects;
import com.google.common.net.MediaType;
import com.lumata.lib.lupa.ReadableResource;
import com.lumata.lib.lupa.content.WebContent;
import com.lumata.lib.lupa.extractor.ContentExtractor;
/**
* Copyright (c) 2013 Lumata
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package com.lumata.lib.lupa.extractor.internal;
class ContentExtractorMatcher<E extends WebContent> implements
Comparable<ContentExtractorMatcher<? extends WebContent>> {
private final ContentExtractor<E> contentExtractor;
Map<String, String> constraints;
int priority;
static final String CONTENT_TYPE = "type";
static final String URL = "url";
ContentExtractorMatcher(ContentExtractor<E> contentExtractor, Map<String, String> constraints, int priority) {
this.contentExtractor = contentExtractor;
this.constraints = constraints;
this.priority = priority;
}
/**
* @return the contentExtractor
*/
public ContentExtractor<E> getContentExtractor() {
return contentExtractor;
}
public boolean isCaplableOfExtracting(Class<? extends WebContent> webContentType) {
return contentExtractor.getExtractableWebContentType().isAssignableFrom(webContentType);
}
| boolean matches(ReadableResource res) { |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.