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
gp15237125756/PoiExcelExport2.0
font/DefaultCellFontImpl.java
// Path: util/XSSFontUtil.java // public class XSSFontUtil { // //default // /** // * @param wb // * @return {code XSSFFont} // */ // public static XSSFFont createXSSFFont(XSSFWorkbook wb){ // String message="XSSFWorkbook must not be null!"; // Objects.requireNonNull(wb, () -> message); // XSSFFont cellfont=wb.createFont(); // cellfont.setFontName("新宋体"); // cellfont.setFontHeightInPoints((short) 12); // cellfont.setBoldweight(XSSFFont.BOLDWEIGHT_BOLD); // cellfont.setColor(new XSSFColor(new Color(50,73,38))); // // return cellfont; // } // // /** // * @param wb // * @param fontFamily // * @param height // * @param color // * @param bold // * @return // */ // public static XSSFFont createColorXSSFFont(XSSFWorkbook wb,String fontFamily,short height,XSSFColor color,boolean bold){ // String message="XSSFWorkbook must not be null!"; // Objects.requireNonNull(wb, () -> message); // XSSFFont cellfont=wb.createFont(); // cellfont.setFontName(fontFamily); // cellfont.setFontHeightInPoints(height); // cellfont.setColor(color); // if(bold){ // cellfont.setBoldweight(XSSFFont.BOLDWEIGHT_BOLD); // } // return cellfont; // } // <<<<<<< HEAD // // ======= // >>>>>>> fe2012a7f8558d8df36b789847bdc41c788d6eaf // }
import org.apache.poi.xssf.usermodel.XSSFFont; import org.apache.poi.xssf.usermodel.XSSFWorkbook; import com.ld.datacenter.poi.util.XSSFontUtil;
package com.ld.datacenter.poi.font; public class DefaultCellFontImpl implements IFontFactory { private XSSFWorkbook wb; public DefaultCellFontImpl(XSSFWorkbook wb){ this.wb=wb; } @Override public XSSFFont create() { // TODO Auto-generated method stub
// Path: util/XSSFontUtil.java // public class XSSFontUtil { // //default // /** // * @param wb // * @return {code XSSFFont} // */ // public static XSSFFont createXSSFFont(XSSFWorkbook wb){ // String message="XSSFWorkbook must not be null!"; // Objects.requireNonNull(wb, () -> message); // XSSFFont cellfont=wb.createFont(); // cellfont.setFontName("新宋体"); // cellfont.setFontHeightInPoints((short) 12); // cellfont.setBoldweight(XSSFFont.BOLDWEIGHT_BOLD); // cellfont.setColor(new XSSFColor(new Color(50,73,38))); // // return cellfont; // } // // /** // * @param wb // * @param fontFamily // * @param height // * @param color // * @param bold // * @return // */ // public static XSSFFont createColorXSSFFont(XSSFWorkbook wb,String fontFamily,short height,XSSFColor color,boolean bold){ // String message="XSSFWorkbook must not be null!"; // Objects.requireNonNull(wb, () -> message); // XSSFFont cellfont=wb.createFont(); // cellfont.setFontName(fontFamily); // cellfont.setFontHeightInPoints(height); // cellfont.setColor(color); // if(bold){ // cellfont.setBoldweight(XSSFFont.BOLDWEIGHT_BOLD); // } // return cellfont; // } // <<<<<<< HEAD // // ======= // >>>>>>> fe2012a7f8558d8df36b789847bdc41c788d6eaf // } // Path: font/DefaultCellFontImpl.java import org.apache.poi.xssf.usermodel.XSSFFont; import org.apache.poi.xssf.usermodel.XSSFWorkbook; import com.ld.datacenter.poi.util.XSSFontUtil; package com.ld.datacenter.poi.font; public class DefaultCellFontImpl implements IFontFactory { private XSSFWorkbook wb; public DefaultCellFontImpl(XSSFWorkbook wb){ this.wb=wb; } @Override public XSSFFont create() { // TODO Auto-generated method stub
return XSSFontUtil.createXSSFFont(this.wb);
gp15237125756/PoiExcelExport2.0
font/ColorCellFontImpl.java
// Path: util/XSSFontUtil.java // public class XSSFontUtil { // //default // /** // * @param wb // * @return {code XSSFFont} // */ // public static XSSFFont createXSSFFont(XSSFWorkbook wb){ // String message="XSSFWorkbook must not be null!"; // Objects.requireNonNull(wb, () -> message); // XSSFFont cellfont=wb.createFont(); // cellfont.setFontName("新宋体"); // cellfont.setFontHeightInPoints((short) 12); // cellfont.setBoldweight(XSSFFont.BOLDWEIGHT_BOLD); // cellfont.setColor(new XSSFColor(new Color(50,73,38))); // // return cellfont; // } // // /** // * @param wb // * @param fontFamily // * @param height // * @param color // * @param bold // * @return // */ // public static XSSFFont createColorXSSFFont(XSSFWorkbook wb,String fontFamily,short height,XSSFColor color,boolean bold){ // String message="XSSFWorkbook must not be null!"; // Objects.requireNonNull(wb, () -> message); // XSSFFont cellfont=wb.createFont(); // cellfont.setFontName(fontFamily); // cellfont.setFontHeightInPoints(height); // cellfont.setColor(color); // if(bold){ // cellfont.setBoldweight(XSSFFont.BOLDWEIGHT_BOLD); // } // return cellfont; // } // <<<<<<< HEAD // // ======= // >>>>>>> fe2012a7f8558d8df36b789847bdc41c788d6eaf // }
import java.awt.Color; import org.apache.poi.xssf.usermodel.XSSFColor; import org.apache.poi.xssf.usermodel.XSSFFont; import org.apache.poi.xssf.usermodel.XSSFWorkbook; import com.ld.datacenter.poi.util.XSSFontUtil;
package com.ld.datacenter.poi.font; public class ColorCellFontImpl implements IFontFactory { private XSSFWorkbook wb; public ColorCellFontImpl(XSSFWorkbook wb){ this.wb=wb; } @Override public XSSFFont create() { // TODO Auto-generated method stub
// Path: util/XSSFontUtil.java // public class XSSFontUtil { // //default // /** // * @param wb // * @return {code XSSFFont} // */ // public static XSSFFont createXSSFFont(XSSFWorkbook wb){ // String message="XSSFWorkbook must not be null!"; // Objects.requireNonNull(wb, () -> message); // XSSFFont cellfont=wb.createFont(); // cellfont.setFontName("新宋体"); // cellfont.setFontHeightInPoints((short) 12); // cellfont.setBoldweight(XSSFFont.BOLDWEIGHT_BOLD); // cellfont.setColor(new XSSFColor(new Color(50,73,38))); // // return cellfont; // } // // /** // * @param wb // * @param fontFamily // * @param height // * @param color // * @param bold // * @return // */ // public static XSSFFont createColorXSSFFont(XSSFWorkbook wb,String fontFamily,short height,XSSFColor color,boolean bold){ // String message="XSSFWorkbook must not be null!"; // Objects.requireNonNull(wb, () -> message); // XSSFFont cellfont=wb.createFont(); // cellfont.setFontName(fontFamily); // cellfont.setFontHeightInPoints(height); // cellfont.setColor(color); // if(bold){ // cellfont.setBoldweight(XSSFFont.BOLDWEIGHT_BOLD); // } // return cellfont; // } // <<<<<<< HEAD // // ======= // >>>>>>> fe2012a7f8558d8df36b789847bdc41c788d6eaf // } // Path: font/ColorCellFontImpl.java import java.awt.Color; import org.apache.poi.xssf.usermodel.XSSFColor; import org.apache.poi.xssf.usermodel.XSSFFont; import org.apache.poi.xssf.usermodel.XSSFWorkbook; import com.ld.datacenter.poi.util.XSSFontUtil; package com.ld.datacenter.poi.font; public class ColorCellFontImpl implements IFontFactory { private XSSFWorkbook wb; public ColorCellFontImpl(XSSFWorkbook wb){ this.wb=wb; } @Override public XSSFFont create() { // TODO Auto-generated method stub
return XSSFontUtil.createColorXSSFFont(this.wb, "新宋体", (short) 16, new XSSFColor(Color.WHITE), true);
gp15237125756/PoiExcelExport2.0
font/TitleCellFontImpl.java
// Path: util/XSSFontUtil.java // public class XSSFontUtil { // //default // /** // * @param wb // * @return {code XSSFFont} // */ // public static XSSFFont createXSSFFont(XSSFWorkbook wb){ // String message="XSSFWorkbook must not be null!"; // Objects.requireNonNull(wb, () -> message); // XSSFFont cellfont=wb.createFont(); // cellfont.setFontName("新宋体"); // cellfont.setFontHeightInPoints((short) 12); // cellfont.setBoldweight(XSSFFont.BOLDWEIGHT_BOLD); // cellfont.setColor(new XSSFColor(new Color(50,73,38))); // // return cellfont; // } // // /** // * @param wb // * @param fontFamily // * @param height // * @param color // * @param bold // * @return // */ // public static XSSFFont createColorXSSFFont(XSSFWorkbook wb,String fontFamily,short height,XSSFColor color,boolean bold){ // String message="XSSFWorkbook must not be null!"; // Objects.requireNonNull(wb, () -> message); // XSSFFont cellfont=wb.createFont(); // cellfont.setFontName(fontFamily); // cellfont.setFontHeightInPoints(height); // cellfont.setColor(color); // if(bold){ // cellfont.setBoldweight(XSSFFont.BOLDWEIGHT_BOLD); // } // return cellfont; // } // <<<<<<< HEAD // // ======= // >>>>>>> fe2012a7f8558d8df36b789847bdc41c788d6eaf // }
import java.awt.Color; import org.apache.poi.xssf.usermodel.XSSFColor; import org.apache.poi.xssf.usermodel.XSSFFont; import org.apache.poi.xssf.usermodel.XSSFWorkbook; import com.ld.datacenter.poi.util.XSSFontUtil;
package com.ld.datacenter.poi.font; public class TitleCellFontImpl implements IFontFactory { private XSSFWorkbook wb; public TitleCellFontImpl(XSSFWorkbook wb){ this.wb=wb; } @Override public XSSFFont create() { // TODO Auto-generated method stub
// Path: util/XSSFontUtil.java // public class XSSFontUtil { // //default // /** // * @param wb // * @return {code XSSFFont} // */ // public static XSSFFont createXSSFFont(XSSFWorkbook wb){ // String message="XSSFWorkbook must not be null!"; // Objects.requireNonNull(wb, () -> message); // XSSFFont cellfont=wb.createFont(); // cellfont.setFontName("新宋体"); // cellfont.setFontHeightInPoints((short) 12); // cellfont.setBoldweight(XSSFFont.BOLDWEIGHT_BOLD); // cellfont.setColor(new XSSFColor(new Color(50,73,38))); // // return cellfont; // } // // /** // * @param wb // * @param fontFamily // * @param height // * @param color // * @param bold // * @return // */ // public static XSSFFont createColorXSSFFont(XSSFWorkbook wb,String fontFamily,short height,XSSFColor color,boolean bold){ // String message="XSSFWorkbook must not be null!"; // Objects.requireNonNull(wb, () -> message); // XSSFFont cellfont=wb.createFont(); // cellfont.setFontName(fontFamily); // cellfont.setFontHeightInPoints(height); // cellfont.setColor(color); // if(bold){ // cellfont.setBoldweight(XSSFFont.BOLDWEIGHT_BOLD); // } // return cellfont; // } // <<<<<<< HEAD // // ======= // >>>>>>> fe2012a7f8558d8df36b789847bdc41c788d6eaf // } // Path: font/TitleCellFontImpl.java import java.awt.Color; import org.apache.poi.xssf.usermodel.XSSFColor; import org.apache.poi.xssf.usermodel.XSSFFont; import org.apache.poi.xssf.usermodel.XSSFWorkbook; import com.ld.datacenter.poi.util.XSSFontUtil; package com.ld.datacenter.poi.font; public class TitleCellFontImpl implements IFontFactory { private XSSFWorkbook wb; public TitleCellFontImpl(XSSFWorkbook wb){ this.wb=wb; } @Override public XSSFFont create() { // TODO Auto-generated method stub
return XSSFontUtil.createColorXSSFFont(this.wb, "新宋体", (short) 16, new XSSFColor(Color.BLACK), false);
gp15237125756/PoiExcelExport2.0
annotation/EntityAttribute.java
// Path: helper/FontStyle.java // public enum FontStyle { // <<<<<<< HEAD // NONE,DEFAULT,TITLE,COLOR // ======= // NONE,DEFAULT,COLOR // >>>>>>> fe2012a7f8558d8df36b789847bdc41c788d6eaf // } // // Path: helper/CellStyle.java // public enum CellStyle { // <<<<<<< HEAD // NONE,DEFAULT,TITLE,STANDARD // ======= // NONE,DEFAULT,STANDARD // >>>>>>> fe2012a7f8558d8df36b789847bdc41c788d6eaf // }
import java.lang.annotation.Documented; import java.lang.annotation.ElementType; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; import com.ld.datacenter.poi.helper.FontStyle; import com.ld.datacenter.poi.helper.CellStyle;
package com.ld.datacenter.poi.annotation; /** * indicate field export available * @author Cruz * @version 01-00 */ @Target({ElementType.FIELD}) @Retention(RetentionPolicy.RUNTIME) @Documented public @interface EntityAttribute { /** excel column name*/ String columnName() default ""; /** whether required*/ boolean required() default false; <<<<<<< HEAD int[] col() default 0; ======= int col() default 0; >>>>>>> fe2012a7f8558d8df36b789847bdc41c788d6eaf int[] row() default 0; boolean merge() default false;
// Path: helper/FontStyle.java // public enum FontStyle { // <<<<<<< HEAD // NONE,DEFAULT,TITLE,COLOR // ======= // NONE,DEFAULT,COLOR // >>>>>>> fe2012a7f8558d8df36b789847bdc41c788d6eaf // } // // Path: helper/CellStyle.java // public enum CellStyle { // <<<<<<< HEAD // NONE,DEFAULT,TITLE,STANDARD // ======= // NONE,DEFAULT,STANDARD // >>>>>>> fe2012a7f8558d8df36b789847bdc41c788d6eaf // } // Path: annotation/EntityAttribute.java import java.lang.annotation.Documented; import java.lang.annotation.ElementType; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; import com.ld.datacenter.poi.helper.FontStyle; import com.ld.datacenter.poi.helper.CellStyle; package com.ld.datacenter.poi.annotation; /** * indicate field export available * @author Cruz * @version 01-00 */ @Target({ElementType.FIELD}) @Retention(RetentionPolicy.RUNTIME) @Documented public @interface EntityAttribute { /** excel column name*/ String columnName() default ""; /** whether required*/ boolean required() default false; <<<<<<< HEAD int[] col() default 0; ======= int col() default 0; >>>>>>> fe2012a7f8558d8df36b789847bdc41c788d6eaf int[] row() default 0; boolean merge() default false;
CellStyle cellStyle() default CellStyle.NONE;
gp15237125756/PoiExcelExport2.0
annotation/EntityAttribute.java
// Path: helper/FontStyle.java // public enum FontStyle { // <<<<<<< HEAD // NONE,DEFAULT,TITLE,COLOR // ======= // NONE,DEFAULT,COLOR // >>>>>>> fe2012a7f8558d8df36b789847bdc41c788d6eaf // } // // Path: helper/CellStyle.java // public enum CellStyle { // <<<<<<< HEAD // NONE,DEFAULT,TITLE,STANDARD // ======= // NONE,DEFAULT,STANDARD // >>>>>>> fe2012a7f8558d8df36b789847bdc41c788d6eaf // }
import java.lang.annotation.Documented; import java.lang.annotation.ElementType; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; import com.ld.datacenter.poi.helper.FontStyle; import com.ld.datacenter.poi.helper.CellStyle;
package com.ld.datacenter.poi.annotation; /** * indicate field export available * @author Cruz * @version 01-00 */ @Target({ElementType.FIELD}) @Retention(RetentionPolicy.RUNTIME) @Documented public @interface EntityAttribute { /** excel column name*/ String columnName() default ""; /** whether required*/ boolean required() default false; <<<<<<< HEAD int[] col() default 0; ======= int col() default 0; >>>>>>> fe2012a7f8558d8df36b789847bdc41c788d6eaf int[] row() default 0; boolean merge() default false; CellStyle cellStyle() default CellStyle.NONE;
// Path: helper/FontStyle.java // public enum FontStyle { // <<<<<<< HEAD // NONE,DEFAULT,TITLE,COLOR // ======= // NONE,DEFAULT,COLOR // >>>>>>> fe2012a7f8558d8df36b789847bdc41c788d6eaf // } // // Path: helper/CellStyle.java // public enum CellStyle { // <<<<<<< HEAD // NONE,DEFAULT,TITLE,STANDARD // ======= // NONE,DEFAULT,STANDARD // >>>>>>> fe2012a7f8558d8df36b789847bdc41c788d6eaf // } // Path: annotation/EntityAttribute.java import java.lang.annotation.Documented; import java.lang.annotation.ElementType; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; import com.ld.datacenter.poi.helper.FontStyle; import com.ld.datacenter.poi.helper.CellStyle; package com.ld.datacenter.poi.annotation; /** * indicate field export available * @author Cruz * @version 01-00 */ @Target({ElementType.FIELD}) @Retention(RetentionPolicy.RUNTIME) @Documented public @interface EntityAttribute { /** excel column name*/ String columnName() default ""; /** whether required*/ boolean required() default false; <<<<<<< HEAD int[] col() default 0; ======= int col() default 0; >>>>>>> fe2012a7f8558d8df36b789847bdc41c788d6eaf int[] row() default 0; boolean merge() default false; CellStyle cellStyle() default CellStyle.NONE;
FontStyle fontStyle() default FontStyle.NONE;
gp15237125756/PoiExcelExport2.0
extention/XSSFFontStyleLib.java
// Path: convert/FontStyleConvert.java // public class FontStyleConvert implements IFontStyleConvert { // // @Override // public void convert(FontStyle style, IFontFactory fac,XSSFFontStyleLib lib) { // XSSFFontStyleRule rule=new XSSFFontStyleRuleImpl(); // rule.registerStyleRule(style, fac.create(),lib); // } // // } // // Path: convert/IFontStyleConvert.java // public interface IFontStyleConvert { // void convert(FontStyle style,IFontFactory fac,XSSFFontStyleLib lib); // } // // Path: exception/FontStyleNotFoundException.java // public class FontStyleNotFoundException extends RuntimeException{ // // private static final long serialVersionUID = 1845298831506720372L; // // public FontStyleNotFoundException(){ // super(); // } // // // public FontStyleNotFoundException(String message){ // super(message); // } // // public FontStyleNotFoundException(Throwable Throwable){ // super(Throwable); // } // // public FontStyleNotFoundException(String message,Throwable cause){ // super(message,cause); // } // // public FontStyleNotFoundException(Class<?> cls,String message){ // super("entity ["+cls.getName()+"] "+message); // } // } // // Path: font/ColorCellFontImpl.java // public class ColorCellFontImpl implements IFontFactory { // private XSSFWorkbook wb; // // public ColorCellFontImpl(XSSFWorkbook wb){ // this.wb=wb; // } // @Override // public XSSFFont create() { // // TODO Auto-generated method stub // return XSSFontUtil.createColorXSSFFont(this.wb, "新宋体", (short) 16, new XSSFColor(Color.WHITE), true); // } // // } // // Path: font/DefaultCellFontImpl.java // public class DefaultCellFontImpl implements IFontFactory { // private XSSFWorkbook wb; // // public DefaultCellFontImpl(XSSFWorkbook wb){ // this.wb=wb; // } // @Override // public XSSFFont create() { // // TODO Auto-generated method stub // return XSSFontUtil.createXSSFFont(this.wb); // } // // }
import java.util.LinkedHashMap; import java.util.Map; import org.apache.poi.xssf.usermodel.XSSFFont; import org.apache.poi.xssf.usermodel.XSSFWorkbook; import com.ld.datacenter.poi.convert.FontStyleConvert; import com.ld.datacenter.poi.convert.IFontStyleConvert; import com.ld.datacenter.poi.exception.FontStyleNotFoundException; import com.ld.datacenter.poi.font.ColorCellFontImpl; import com.ld.datacenter.poi.font.DefaultCellFontImpl;
package com.ld.datacenter.poi.extention; <<<<<<< HEAD import com.ld.datacenter.poi.font.TitleCellFontImpl; ======= >>>>>>> fe2012a7f8558d8df36b789847bdc41c788d6eaf import com.ld.datacenter.poi.helper.FontStyle; public class XSSFFontStyleLib { /** 樣式緩存*/ private final Map<FontStyle,XSSFFont> FONT_STYLE_MAP=new LinkedHashMap<FontStyle, XSSFFont>(); <<<<<<< HEAD @SuppressWarnings("unused") ======= >>>>>>> fe2012a7f8558d8df36b789847bdc41c788d6eaf private final XSSFWorkbook wb; public XSSFFontStyleLib(XSSFWorkbook wb){ this.wb=wb;
// Path: convert/FontStyleConvert.java // public class FontStyleConvert implements IFontStyleConvert { // // @Override // public void convert(FontStyle style, IFontFactory fac,XSSFFontStyleLib lib) { // XSSFFontStyleRule rule=new XSSFFontStyleRuleImpl(); // rule.registerStyleRule(style, fac.create(),lib); // } // // } // // Path: convert/IFontStyleConvert.java // public interface IFontStyleConvert { // void convert(FontStyle style,IFontFactory fac,XSSFFontStyleLib lib); // } // // Path: exception/FontStyleNotFoundException.java // public class FontStyleNotFoundException extends RuntimeException{ // // private static final long serialVersionUID = 1845298831506720372L; // // public FontStyleNotFoundException(){ // super(); // } // // // public FontStyleNotFoundException(String message){ // super(message); // } // // public FontStyleNotFoundException(Throwable Throwable){ // super(Throwable); // } // // public FontStyleNotFoundException(String message,Throwable cause){ // super(message,cause); // } // // public FontStyleNotFoundException(Class<?> cls,String message){ // super("entity ["+cls.getName()+"] "+message); // } // } // // Path: font/ColorCellFontImpl.java // public class ColorCellFontImpl implements IFontFactory { // private XSSFWorkbook wb; // // public ColorCellFontImpl(XSSFWorkbook wb){ // this.wb=wb; // } // @Override // public XSSFFont create() { // // TODO Auto-generated method stub // return XSSFontUtil.createColorXSSFFont(this.wb, "新宋体", (short) 16, new XSSFColor(Color.WHITE), true); // } // // } // // Path: font/DefaultCellFontImpl.java // public class DefaultCellFontImpl implements IFontFactory { // private XSSFWorkbook wb; // // public DefaultCellFontImpl(XSSFWorkbook wb){ // this.wb=wb; // } // @Override // public XSSFFont create() { // // TODO Auto-generated method stub // return XSSFontUtil.createXSSFFont(this.wb); // } // // } // Path: extention/XSSFFontStyleLib.java import java.util.LinkedHashMap; import java.util.Map; import org.apache.poi.xssf.usermodel.XSSFFont; import org.apache.poi.xssf.usermodel.XSSFWorkbook; import com.ld.datacenter.poi.convert.FontStyleConvert; import com.ld.datacenter.poi.convert.IFontStyleConvert; import com.ld.datacenter.poi.exception.FontStyleNotFoundException; import com.ld.datacenter.poi.font.ColorCellFontImpl; import com.ld.datacenter.poi.font.DefaultCellFontImpl; package com.ld.datacenter.poi.extention; <<<<<<< HEAD import com.ld.datacenter.poi.font.TitleCellFontImpl; ======= >>>>>>> fe2012a7f8558d8df36b789847bdc41c788d6eaf import com.ld.datacenter.poi.helper.FontStyle; public class XSSFFontStyleLib { /** 樣式緩存*/ private final Map<FontStyle,XSSFFont> FONT_STYLE_MAP=new LinkedHashMap<FontStyle, XSSFFont>(); <<<<<<< HEAD @SuppressWarnings("unused") ======= >>>>>>> fe2012a7f8558d8df36b789847bdc41c788d6eaf private final XSSFWorkbook wb; public XSSFFontStyleLib(XSSFWorkbook wb){ this.wb=wb;
IFontStyleConvert convert=new FontStyleConvert();
gp15237125756/PoiExcelExport2.0
extention/XSSFFontStyleLib.java
// Path: convert/FontStyleConvert.java // public class FontStyleConvert implements IFontStyleConvert { // // @Override // public void convert(FontStyle style, IFontFactory fac,XSSFFontStyleLib lib) { // XSSFFontStyleRule rule=new XSSFFontStyleRuleImpl(); // rule.registerStyleRule(style, fac.create(),lib); // } // // } // // Path: convert/IFontStyleConvert.java // public interface IFontStyleConvert { // void convert(FontStyle style,IFontFactory fac,XSSFFontStyleLib lib); // } // // Path: exception/FontStyleNotFoundException.java // public class FontStyleNotFoundException extends RuntimeException{ // // private static final long serialVersionUID = 1845298831506720372L; // // public FontStyleNotFoundException(){ // super(); // } // // // public FontStyleNotFoundException(String message){ // super(message); // } // // public FontStyleNotFoundException(Throwable Throwable){ // super(Throwable); // } // // public FontStyleNotFoundException(String message,Throwable cause){ // super(message,cause); // } // // public FontStyleNotFoundException(Class<?> cls,String message){ // super("entity ["+cls.getName()+"] "+message); // } // } // // Path: font/ColorCellFontImpl.java // public class ColorCellFontImpl implements IFontFactory { // private XSSFWorkbook wb; // // public ColorCellFontImpl(XSSFWorkbook wb){ // this.wb=wb; // } // @Override // public XSSFFont create() { // // TODO Auto-generated method stub // return XSSFontUtil.createColorXSSFFont(this.wb, "新宋体", (short) 16, new XSSFColor(Color.WHITE), true); // } // // } // // Path: font/DefaultCellFontImpl.java // public class DefaultCellFontImpl implements IFontFactory { // private XSSFWorkbook wb; // // public DefaultCellFontImpl(XSSFWorkbook wb){ // this.wb=wb; // } // @Override // public XSSFFont create() { // // TODO Auto-generated method stub // return XSSFontUtil.createXSSFFont(this.wb); // } // // }
import java.util.LinkedHashMap; import java.util.Map; import org.apache.poi.xssf.usermodel.XSSFFont; import org.apache.poi.xssf.usermodel.XSSFWorkbook; import com.ld.datacenter.poi.convert.FontStyleConvert; import com.ld.datacenter.poi.convert.IFontStyleConvert; import com.ld.datacenter.poi.exception.FontStyleNotFoundException; import com.ld.datacenter.poi.font.ColorCellFontImpl; import com.ld.datacenter.poi.font.DefaultCellFontImpl;
package com.ld.datacenter.poi.extention; <<<<<<< HEAD import com.ld.datacenter.poi.font.TitleCellFontImpl; ======= >>>>>>> fe2012a7f8558d8df36b789847bdc41c788d6eaf import com.ld.datacenter.poi.helper.FontStyle; public class XSSFFontStyleLib { /** 樣式緩存*/ private final Map<FontStyle,XSSFFont> FONT_STYLE_MAP=new LinkedHashMap<FontStyle, XSSFFont>(); <<<<<<< HEAD @SuppressWarnings("unused") ======= >>>>>>> fe2012a7f8558d8df36b789847bdc41c788d6eaf private final XSSFWorkbook wb; public XSSFFontStyleLib(XSSFWorkbook wb){ this.wb=wb;
// Path: convert/FontStyleConvert.java // public class FontStyleConvert implements IFontStyleConvert { // // @Override // public void convert(FontStyle style, IFontFactory fac,XSSFFontStyleLib lib) { // XSSFFontStyleRule rule=new XSSFFontStyleRuleImpl(); // rule.registerStyleRule(style, fac.create(),lib); // } // // } // // Path: convert/IFontStyleConvert.java // public interface IFontStyleConvert { // void convert(FontStyle style,IFontFactory fac,XSSFFontStyleLib lib); // } // // Path: exception/FontStyleNotFoundException.java // public class FontStyleNotFoundException extends RuntimeException{ // // private static final long serialVersionUID = 1845298831506720372L; // // public FontStyleNotFoundException(){ // super(); // } // // // public FontStyleNotFoundException(String message){ // super(message); // } // // public FontStyleNotFoundException(Throwable Throwable){ // super(Throwable); // } // // public FontStyleNotFoundException(String message,Throwable cause){ // super(message,cause); // } // // public FontStyleNotFoundException(Class<?> cls,String message){ // super("entity ["+cls.getName()+"] "+message); // } // } // // Path: font/ColorCellFontImpl.java // public class ColorCellFontImpl implements IFontFactory { // private XSSFWorkbook wb; // // public ColorCellFontImpl(XSSFWorkbook wb){ // this.wb=wb; // } // @Override // public XSSFFont create() { // // TODO Auto-generated method stub // return XSSFontUtil.createColorXSSFFont(this.wb, "新宋体", (short) 16, new XSSFColor(Color.WHITE), true); // } // // } // // Path: font/DefaultCellFontImpl.java // public class DefaultCellFontImpl implements IFontFactory { // private XSSFWorkbook wb; // // public DefaultCellFontImpl(XSSFWorkbook wb){ // this.wb=wb; // } // @Override // public XSSFFont create() { // // TODO Auto-generated method stub // return XSSFontUtil.createXSSFFont(this.wb); // } // // } // Path: extention/XSSFFontStyleLib.java import java.util.LinkedHashMap; import java.util.Map; import org.apache.poi.xssf.usermodel.XSSFFont; import org.apache.poi.xssf.usermodel.XSSFWorkbook; import com.ld.datacenter.poi.convert.FontStyleConvert; import com.ld.datacenter.poi.convert.IFontStyleConvert; import com.ld.datacenter.poi.exception.FontStyleNotFoundException; import com.ld.datacenter.poi.font.ColorCellFontImpl; import com.ld.datacenter.poi.font.DefaultCellFontImpl; package com.ld.datacenter.poi.extention; <<<<<<< HEAD import com.ld.datacenter.poi.font.TitleCellFontImpl; ======= >>>>>>> fe2012a7f8558d8df36b789847bdc41c788d6eaf import com.ld.datacenter.poi.helper.FontStyle; public class XSSFFontStyleLib { /** 樣式緩存*/ private final Map<FontStyle,XSSFFont> FONT_STYLE_MAP=new LinkedHashMap<FontStyle, XSSFFont>(); <<<<<<< HEAD @SuppressWarnings("unused") ======= >>>>>>> fe2012a7f8558d8df36b789847bdc41c788d6eaf private final XSSFWorkbook wb; public XSSFFontStyleLib(XSSFWorkbook wb){ this.wb=wb;
IFontStyleConvert convert=new FontStyleConvert();
gp15237125756/PoiExcelExport2.0
extention/XSSFFontStyleLib.java
// Path: convert/FontStyleConvert.java // public class FontStyleConvert implements IFontStyleConvert { // // @Override // public void convert(FontStyle style, IFontFactory fac,XSSFFontStyleLib lib) { // XSSFFontStyleRule rule=new XSSFFontStyleRuleImpl(); // rule.registerStyleRule(style, fac.create(),lib); // } // // } // // Path: convert/IFontStyleConvert.java // public interface IFontStyleConvert { // void convert(FontStyle style,IFontFactory fac,XSSFFontStyleLib lib); // } // // Path: exception/FontStyleNotFoundException.java // public class FontStyleNotFoundException extends RuntimeException{ // // private static final long serialVersionUID = 1845298831506720372L; // // public FontStyleNotFoundException(){ // super(); // } // // // public FontStyleNotFoundException(String message){ // super(message); // } // // public FontStyleNotFoundException(Throwable Throwable){ // super(Throwable); // } // // public FontStyleNotFoundException(String message,Throwable cause){ // super(message,cause); // } // // public FontStyleNotFoundException(Class<?> cls,String message){ // super("entity ["+cls.getName()+"] "+message); // } // } // // Path: font/ColorCellFontImpl.java // public class ColorCellFontImpl implements IFontFactory { // private XSSFWorkbook wb; // // public ColorCellFontImpl(XSSFWorkbook wb){ // this.wb=wb; // } // @Override // public XSSFFont create() { // // TODO Auto-generated method stub // return XSSFontUtil.createColorXSSFFont(this.wb, "新宋体", (short) 16, new XSSFColor(Color.WHITE), true); // } // // } // // Path: font/DefaultCellFontImpl.java // public class DefaultCellFontImpl implements IFontFactory { // private XSSFWorkbook wb; // // public DefaultCellFontImpl(XSSFWorkbook wb){ // this.wb=wb; // } // @Override // public XSSFFont create() { // // TODO Auto-generated method stub // return XSSFontUtil.createXSSFFont(this.wb); // } // // }
import java.util.LinkedHashMap; import java.util.Map; import org.apache.poi.xssf.usermodel.XSSFFont; import org.apache.poi.xssf.usermodel.XSSFWorkbook; import com.ld.datacenter.poi.convert.FontStyleConvert; import com.ld.datacenter.poi.convert.IFontStyleConvert; import com.ld.datacenter.poi.exception.FontStyleNotFoundException; import com.ld.datacenter.poi.font.ColorCellFontImpl; import com.ld.datacenter.poi.font.DefaultCellFontImpl;
package com.ld.datacenter.poi.extention; <<<<<<< HEAD import com.ld.datacenter.poi.font.TitleCellFontImpl; ======= >>>>>>> fe2012a7f8558d8df36b789847bdc41c788d6eaf import com.ld.datacenter.poi.helper.FontStyle; public class XSSFFontStyleLib { /** 樣式緩存*/ private final Map<FontStyle,XSSFFont> FONT_STYLE_MAP=new LinkedHashMap<FontStyle, XSSFFont>(); <<<<<<< HEAD @SuppressWarnings("unused") ======= >>>>>>> fe2012a7f8558d8df36b789847bdc41c788d6eaf private final XSSFWorkbook wb; public XSSFFontStyleLib(XSSFWorkbook wb){ this.wb=wb; IFontStyleConvert convert=new FontStyleConvert(); //添加cell樣式
// Path: convert/FontStyleConvert.java // public class FontStyleConvert implements IFontStyleConvert { // // @Override // public void convert(FontStyle style, IFontFactory fac,XSSFFontStyleLib lib) { // XSSFFontStyleRule rule=new XSSFFontStyleRuleImpl(); // rule.registerStyleRule(style, fac.create(),lib); // } // // } // // Path: convert/IFontStyleConvert.java // public interface IFontStyleConvert { // void convert(FontStyle style,IFontFactory fac,XSSFFontStyleLib lib); // } // // Path: exception/FontStyleNotFoundException.java // public class FontStyleNotFoundException extends RuntimeException{ // // private static final long serialVersionUID = 1845298831506720372L; // // public FontStyleNotFoundException(){ // super(); // } // // // public FontStyleNotFoundException(String message){ // super(message); // } // // public FontStyleNotFoundException(Throwable Throwable){ // super(Throwable); // } // // public FontStyleNotFoundException(String message,Throwable cause){ // super(message,cause); // } // // public FontStyleNotFoundException(Class<?> cls,String message){ // super("entity ["+cls.getName()+"] "+message); // } // } // // Path: font/ColorCellFontImpl.java // public class ColorCellFontImpl implements IFontFactory { // private XSSFWorkbook wb; // // public ColorCellFontImpl(XSSFWorkbook wb){ // this.wb=wb; // } // @Override // public XSSFFont create() { // // TODO Auto-generated method stub // return XSSFontUtil.createColorXSSFFont(this.wb, "新宋体", (short) 16, new XSSFColor(Color.WHITE), true); // } // // } // // Path: font/DefaultCellFontImpl.java // public class DefaultCellFontImpl implements IFontFactory { // private XSSFWorkbook wb; // // public DefaultCellFontImpl(XSSFWorkbook wb){ // this.wb=wb; // } // @Override // public XSSFFont create() { // // TODO Auto-generated method stub // return XSSFontUtil.createXSSFFont(this.wb); // } // // } // Path: extention/XSSFFontStyleLib.java import java.util.LinkedHashMap; import java.util.Map; import org.apache.poi.xssf.usermodel.XSSFFont; import org.apache.poi.xssf.usermodel.XSSFWorkbook; import com.ld.datacenter.poi.convert.FontStyleConvert; import com.ld.datacenter.poi.convert.IFontStyleConvert; import com.ld.datacenter.poi.exception.FontStyleNotFoundException; import com.ld.datacenter.poi.font.ColorCellFontImpl; import com.ld.datacenter.poi.font.DefaultCellFontImpl; package com.ld.datacenter.poi.extention; <<<<<<< HEAD import com.ld.datacenter.poi.font.TitleCellFontImpl; ======= >>>>>>> fe2012a7f8558d8df36b789847bdc41c788d6eaf import com.ld.datacenter.poi.helper.FontStyle; public class XSSFFontStyleLib { /** 樣式緩存*/ private final Map<FontStyle,XSSFFont> FONT_STYLE_MAP=new LinkedHashMap<FontStyle, XSSFFont>(); <<<<<<< HEAD @SuppressWarnings("unused") ======= >>>>>>> fe2012a7f8558d8df36b789847bdc41c788d6eaf private final XSSFWorkbook wb; public XSSFFontStyleLib(XSSFWorkbook wb){ this.wb=wb; IFontStyleConvert convert=new FontStyleConvert(); //添加cell樣式
convert.convert(FontStyle.NONE, new DefaultCellFontImpl(wb),this);
gp15237125756/PoiExcelExport2.0
extention/XSSFFontStyleLib.java
// Path: convert/FontStyleConvert.java // public class FontStyleConvert implements IFontStyleConvert { // // @Override // public void convert(FontStyle style, IFontFactory fac,XSSFFontStyleLib lib) { // XSSFFontStyleRule rule=new XSSFFontStyleRuleImpl(); // rule.registerStyleRule(style, fac.create(),lib); // } // // } // // Path: convert/IFontStyleConvert.java // public interface IFontStyleConvert { // void convert(FontStyle style,IFontFactory fac,XSSFFontStyleLib lib); // } // // Path: exception/FontStyleNotFoundException.java // public class FontStyleNotFoundException extends RuntimeException{ // // private static final long serialVersionUID = 1845298831506720372L; // // public FontStyleNotFoundException(){ // super(); // } // // // public FontStyleNotFoundException(String message){ // super(message); // } // // public FontStyleNotFoundException(Throwable Throwable){ // super(Throwable); // } // // public FontStyleNotFoundException(String message,Throwable cause){ // super(message,cause); // } // // public FontStyleNotFoundException(Class<?> cls,String message){ // super("entity ["+cls.getName()+"] "+message); // } // } // // Path: font/ColorCellFontImpl.java // public class ColorCellFontImpl implements IFontFactory { // private XSSFWorkbook wb; // // public ColorCellFontImpl(XSSFWorkbook wb){ // this.wb=wb; // } // @Override // public XSSFFont create() { // // TODO Auto-generated method stub // return XSSFontUtil.createColorXSSFFont(this.wb, "新宋体", (short) 16, new XSSFColor(Color.WHITE), true); // } // // } // // Path: font/DefaultCellFontImpl.java // public class DefaultCellFontImpl implements IFontFactory { // private XSSFWorkbook wb; // // public DefaultCellFontImpl(XSSFWorkbook wb){ // this.wb=wb; // } // @Override // public XSSFFont create() { // // TODO Auto-generated method stub // return XSSFontUtil.createXSSFFont(this.wb); // } // // }
import java.util.LinkedHashMap; import java.util.Map; import org.apache.poi.xssf.usermodel.XSSFFont; import org.apache.poi.xssf.usermodel.XSSFWorkbook; import com.ld.datacenter.poi.convert.FontStyleConvert; import com.ld.datacenter.poi.convert.IFontStyleConvert; import com.ld.datacenter.poi.exception.FontStyleNotFoundException; import com.ld.datacenter.poi.font.ColorCellFontImpl; import com.ld.datacenter.poi.font.DefaultCellFontImpl;
package com.ld.datacenter.poi.extention; <<<<<<< HEAD import com.ld.datacenter.poi.font.TitleCellFontImpl; ======= >>>>>>> fe2012a7f8558d8df36b789847bdc41c788d6eaf import com.ld.datacenter.poi.helper.FontStyle; public class XSSFFontStyleLib { /** 樣式緩存*/ private final Map<FontStyle,XSSFFont> FONT_STYLE_MAP=new LinkedHashMap<FontStyle, XSSFFont>(); <<<<<<< HEAD @SuppressWarnings("unused") ======= >>>>>>> fe2012a7f8558d8df36b789847bdc41c788d6eaf private final XSSFWorkbook wb; public XSSFFontStyleLib(XSSFWorkbook wb){ this.wb=wb; IFontStyleConvert convert=new FontStyleConvert(); //添加cell樣式 convert.convert(FontStyle.NONE, new DefaultCellFontImpl(wb),this); convert.convert(FontStyle.DEFAULT, new DefaultCellFontImpl(wb),this); <<<<<<< HEAD convert.convert(FontStyle.TITLE, new TitleCellFontImpl(wb),this); ======= >>>>>>> fe2012a7f8558d8df36b789847bdc41c788d6eaf
// Path: convert/FontStyleConvert.java // public class FontStyleConvert implements IFontStyleConvert { // // @Override // public void convert(FontStyle style, IFontFactory fac,XSSFFontStyleLib lib) { // XSSFFontStyleRule rule=new XSSFFontStyleRuleImpl(); // rule.registerStyleRule(style, fac.create(),lib); // } // // } // // Path: convert/IFontStyleConvert.java // public interface IFontStyleConvert { // void convert(FontStyle style,IFontFactory fac,XSSFFontStyleLib lib); // } // // Path: exception/FontStyleNotFoundException.java // public class FontStyleNotFoundException extends RuntimeException{ // // private static final long serialVersionUID = 1845298831506720372L; // // public FontStyleNotFoundException(){ // super(); // } // // // public FontStyleNotFoundException(String message){ // super(message); // } // // public FontStyleNotFoundException(Throwable Throwable){ // super(Throwable); // } // // public FontStyleNotFoundException(String message,Throwable cause){ // super(message,cause); // } // // public FontStyleNotFoundException(Class<?> cls,String message){ // super("entity ["+cls.getName()+"] "+message); // } // } // // Path: font/ColorCellFontImpl.java // public class ColorCellFontImpl implements IFontFactory { // private XSSFWorkbook wb; // // public ColorCellFontImpl(XSSFWorkbook wb){ // this.wb=wb; // } // @Override // public XSSFFont create() { // // TODO Auto-generated method stub // return XSSFontUtil.createColorXSSFFont(this.wb, "新宋体", (short) 16, new XSSFColor(Color.WHITE), true); // } // // } // // Path: font/DefaultCellFontImpl.java // public class DefaultCellFontImpl implements IFontFactory { // private XSSFWorkbook wb; // // public DefaultCellFontImpl(XSSFWorkbook wb){ // this.wb=wb; // } // @Override // public XSSFFont create() { // // TODO Auto-generated method stub // return XSSFontUtil.createXSSFFont(this.wb); // } // // } // Path: extention/XSSFFontStyleLib.java import java.util.LinkedHashMap; import java.util.Map; import org.apache.poi.xssf.usermodel.XSSFFont; import org.apache.poi.xssf.usermodel.XSSFWorkbook; import com.ld.datacenter.poi.convert.FontStyleConvert; import com.ld.datacenter.poi.convert.IFontStyleConvert; import com.ld.datacenter.poi.exception.FontStyleNotFoundException; import com.ld.datacenter.poi.font.ColorCellFontImpl; import com.ld.datacenter.poi.font.DefaultCellFontImpl; package com.ld.datacenter.poi.extention; <<<<<<< HEAD import com.ld.datacenter.poi.font.TitleCellFontImpl; ======= >>>>>>> fe2012a7f8558d8df36b789847bdc41c788d6eaf import com.ld.datacenter.poi.helper.FontStyle; public class XSSFFontStyleLib { /** 樣式緩存*/ private final Map<FontStyle,XSSFFont> FONT_STYLE_MAP=new LinkedHashMap<FontStyle, XSSFFont>(); <<<<<<< HEAD @SuppressWarnings("unused") ======= >>>>>>> fe2012a7f8558d8df36b789847bdc41c788d6eaf private final XSSFWorkbook wb; public XSSFFontStyleLib(XSSFWorkbook wb){ this.wb=wb; IFontStyleConvert convert=new FontStyleConvert(); //添加cell樣式 convert.convert(FontStyle.NONE, new DefaultCellFontImpl(wb),this); convert.convert(FontStyle.DEFAULT, new DefaultCellFontImpl(wb),this); <<<<<<< HEAD convert.convert(FontStyle.TITLE, new TitleCellFontImpl(wb),this); ======= >>>>>>> fe2012a7f8558d8df36b789847bdc41c788d6eaf
convert.convert(FontStyle.COLOR, new ColorCellFontImpl(wb),this);
gp15237125756/PoiExcelExport2.0
extention/XSSFFontStyleLib.java
// Path: convert/FontStyleConvert.java // public class FontStyleConvert implements IFontStyleConvert { // // @Override // public void convert(FontStyle style, IFontFactory fac,XSSFFontStyleLib lib) { // XSSFFontStyleRule rule=new XSSFFontStyleRuleImpl(); // rule.registerStyleRule(style, fac.create(),lib); // } // // } // // Path: convert/IFontStyleConvert.java // public interface IFontStyleConvert { // void convert(FontStyle style,IFontFactory fac,XSSFFontStyleLib lib); // } // // Path: exception/FontStyleNotFoundException.java // public class FontStyleNotFoundException extends RuntimeException{ // // private static final long serialVersionUID = 1845298831506720372L; // // public FontStyleNotFoundException(){ // super(); // } // // // public FontStyleNotFoundException(String message){ // super(message); // } // // public FontStyleNotFoundException(Throwable Throwable){ // super(Throwable); // } // // public FontStyleNotFoundException(String message,Throwable cause){ // super(message,cause); // } // // public FontStyleNotFoundException(Class<?> cls,String message){ // super("entity ["+cls.getName()+"] "+message); // } // } // // Path: font/ColorCellFontImpl.java // public class ColorCellFontImpl implements IFontFactory { // private XSSFWorkbook wb; // // public ColorCellFontImpl(XSSFWorkbook wb){ // this.wb=wb; // } // @Override // public XSSFFont create() { // // TODO Auto-generated method stub // return XSSFontUtil.createColorXSSFFont(this.wb, "新宋体", (short) 16, new XSSFColor(Color.WHITE), true); // } // // } // // Path: font/DefaultCellFontImpl.java // public class DefaultCellFontImpl implements IFontFactory { // private XSSFWorkbook wb; // // public DefaultCellFontImpl(XSSFWorkbook wb){ // this.wb=wb; // } // @Override // public XSSFFont create() { // // TODO Auto-generated method stub // return XSSFontUtil.createXSSFFont(this.wb); // } // // }
import java.util.LinkedHashMap; import java.util.Map; import org.apache.poi.xssf.usermodel.XSSFFont; import org.apache.poi.xssf.usermodel.XSSFWorkbook; import com.ld.datacenter.poi.convert.FontStyleConvert; import com.ld.datacenter.poi.convert.IFontStyleConvert; import com.ld.datacenter.poi.exception.FontStyleNotFoundException; import com.ld.datacenter.poi.font.ColorCellFontImpl; import com.ld.datacenter.poi.font.DefaultCellFontImpl;
package com.ld.datacenter.poi.extention; <<<<<<< HEAD import com.ld.datacenter.poi.font.TitleCellFontImpl; ======= >>>>>>> fe2012a7f8558d8df36b789847bdc41c788d6eaf import com.ld.datacenter.poi.helper.FontStyle; public class XSSFFontStyleLib { /** 樣式緩存*/ private final Map<FontStyle,XSSFFont> FONT_STYLE_MAP=new LinkedHashMap<FontStyle, XSSFFont>(); <<<<<<< HEAD @SuppressWarnings("unused") ======= >>>>>>> fe2012a7f8558d8df36b789847bdc41c788d6eaf private final XSSFWorkbook wb; public XSSFFontStyleLib(XSSFWorkbook wb){ this.wb=wb; IFontStyleConvert convert=new FontStyleConvert(); //添加cell樣式 convert.convert(FontStyle.NONE, new DefaultCellFontImpl(wb),this); convert.convert(FontStyle.DEFAULT, new DefaultCellFontImpl(wb),this); <<<<<<< HEAD convert.convert(FontStyle.TITLE, new TitleCellFontImpl(wb),this); ======= >>>>>>> fe2012a7f8558d8df36b789847bdc41c788d6eaf convert.convert(FontStyle.COLOR, new ColorCellFontImpl(wb),this); } public void addStyle(FontStyle k,XSSFFont v){ FONT_STYLE_MAP.put(k, v); } public void removeStyle(FontStyle k){ FONT_STYLE_MAP.remove(k); } public XSSFFont get(FontStyle k){ XSSFFont v=FONT_STYLE_MAP.get(k); if(null==v){
// Path: convert/FontStyleConvert.java // public class FontStyleConvert implements IFontStyleConvert { // // @Override // public void convert(FontStyle style, IFontFactory fac,XSSFFontStyleLib lib) { // XSSFFontStyleRule rule=new XSSFFontStyleRuleImpl(); // rule.registerStyleRule(style, fac.create(),lib); // } // // } // // Path: convert/IFontStyleConvert.java // public interface IFontStyleConvert { // void convert(FontStyle style,IFontFactory fac,XSSFFontStyleLib lib); // } // // Path: exception/FontStyleNotFoundException.java // public class FontStyleNotFoundException extends RuntimeException{ // // private static final long serialVersionUID = 1845298831506720372L; // // public FontStyleNotFoundException(){ // super(); // } // // // public FontStyleNotFoundException(String message){ // super(message); // } // // public FontStyleNotFoundException(Throwable Throwable){ // super(Throwable); // } // // public FontStyleNotFoundException(String message,Throwable cause){ // super(message,cause); // } // // public FontStyleNotFoundException(Class<?> cls,String message){ // super("entity ["+cls.getName()+"] "+message); // } // } // // Path: font/ColorCellFontImpl.java // public class ColorCellFontImpl implements IFontFactory { // private XSSFWorkbook wb; // // public ColorCellFontImpl(XSSFWorkbook wb){ // this.wb=wb; // } // @Override // public XSSFFont create() { // // TODO Auto-generated method stub // return XSSFontUtil.createColorXSSFFont(this.wb, "新宋体", (short) 16, new XSSFColor(Color.WHITE), true); // } // // } // // Path: font/DefaultCellFontImpl.java // public class DefaultCellFontImpl implements IFontFactory { // private XSSFWorkbook wb; // // public DefaultCellFontImpl(XSSFWorkbook wb){ // this.wb=wb; // } // @Override // public XSSFFont create() { // // TODO Auto-generated method stub // return XSSFontUtil.createXSSFFont(this.wb); // } // // } // Path: extention/XSSFFontStyleLib.java import java.util.LinkedHashMap; import java.util.Map; import org.apache.poi.xssf.usermodel.XSSFFont; import org.apache.poi.xssf.usermodel.XSSFWorkbook; import com.ld.datacenter.poi.convert.FontStyleConvert; import com.ld.datacenter.poi.convert.IFontStyleConvert; import com.ld.datacenter.poi.exception.FontStyleNotFoundException; import com.ld.datacenter.poi.font.ColorCellFontImpl; import com.ld.datacenter.poi.font.DefaultCellFontImpl; package com.ld.datacenter.poi.extention; <<<<<<< HEAD import com.ld.datacenter.poi.font.TitleCellFontImpl; ======= >>>>>>> fe2012a7f8558d8df36b789847bdc41c788d6eaf import com.ld.datacenter.poi.helper.FontStyle; public class XSSFFontStyleLib { /** 樣式緩存*/ private final Map<FontStyle,XSSFFont> FONT_STYLE_MAP=new LinkedHashMap<FontStyle, XSSFFont>(); <<<<<<< HEAD @SuppressWarnings("unused") ======= >>>>>>> fe2012a7f8558d8df36b789847bdc41c788d6eaf private final XSSFWorkbook wb; public XSSFFontStyleLib(XSSFWorkbook wb){ this.wb=wb; IFontStyleConvert convert=new FontStyleConvert(); //添加cell樣式 convert.convert(FontStyle.NONE, new DefaultCellFontImpl(wb),this); convert.convert(FontStyle.DEFAULT, new DefaultCellFontImpl(wb),this); <<<<<<< HEAD convert.convert(FontStyle.TITLE, new TitleCellFontImpl(wb),this); ======= >>>>>>> fe2012a7f8558d8df36b789847bdc41c788d6eaf convert.convert(FontStyle.COLOR, new ColorCellFontImpl(wb),this); } public void addStyle(FontStyle k,XSSFFont v){ FONT_STYLE_MAP.put(k, v); } public void removeStyle(FontStyle k){ FONT_STYLE_MAP.remove(k); } public XSSFFont get(FontStyle k){ XSSFFont v=FONT_STYLE_MAP.get(k); if(null==v){
throw new FontStyleNotFoundException("the font style have not been defined!");
gp15237125756/PoiExcelExport2.0
convert/CellStyleConvert.java
// Path: extention/XSSFCellStyleLib.java // public class XSSFCellStyleLib { // /** 樣式緩存*/ // private final Map<CellStyle,XSSFCellStyle> CELL_STYLE_MAP=new LinkedHashMap<CellStyle, XSSFCellStyle>(); // // <<<<<<< HEAD // @SuppressWarnings("unused") // ======= // >>>>>>> fe2012a7f8558d8df36b789847bdc41c788d6eaf // private final XSSFWorkbook wb; // // public XSSFCellStyleLib(XSSFWorkbook wb){ // this.wb=wb; // ICellStyleConvert convert=new CellStyleConvert(); // //添加cell樣式 // convert.convert(CellStyle.NONE, new DefaultCellStyleImpl(wb),this); // convert.convert(CellStyle.DEFAULT, new DefaultCellStyleImpl(wb),this); // convert.convert(CellStyle.STANDARD, new TextCellStyleImpl(wb),this); // <<<<<<< HEAD // convert.convert(CellStyle.TITLE, new TitleCellStyleImpl(wb),this); // ======= // >>>>>>> fe2012a7f8558d8df36b789847bdc41c788d6eaf // } // // // public void addStyle(CellStyle k,XSSFCellStyle v){ // CELL_STYLE_MAP.put(k, v); // } // // public void removeStyle(CellStyle k){ // CELL_STYLE_MAP.remove(k); // } // // public XSSFCellStyle get(CellStyle k){ // XSSFCellStyle v=CELL_STYLE_MAP.get(k); // if(null==v){ // throw new CellStyleNotFoundException("the cell style have not been defined!"); // } // return v; // } // // public void clear(){ // CELL_STYLE_MAP.clear(); // } // } // // Path: extention/XSSFCellStyleRule.java // public interface XSSFCellStyleRule { // /** // * 註冊樣式 // */ // void registerStyleRule(CellStyle k,XSSFCellStyle v,XSSFCellStyleLib lib); // /** // * 移除樣式 // */ // void removeStyleRule(CellStyle k,XSSFCellStyleLib lib); // // } // // Path: extention/impl/XSSFCellStyleRuleImpl.java // public class XSSFCellStyleRuleImpl implements XSSFCellStyleRule{ // // @Override // public void registerStyleRule(CellStyle k, XSSFCellStyle v, // XSSFCellStyleLib lib) { // // lib.addStyle(k, v); // } // // @Override // public void removeStyleRule(CellStyle k, XSSFCellStyleLib lib) { // lib.removeStyle(k); // // } // // // // } // // Path: helper/CellStyle.java // public enum CellStyle { // <<<<<<< HEAD // NONE,DEFAULT,TITLE,STANDARD // ======= // NONE,DEFAULT,STANDARD // >>>>>>> fe2012a7f8558d8df36b789847bdc41c788d6eaf // } // // Path: style/ICellStyleFactory.java // public interface ICellStyleFactory { // // /** // * @param wb // * @return {@code XSSFCellStyle} // */ // XSSFCellStyle create(); // }
import com.ld.datacenter.poi.extention.XSSFCellStyleLib; import com.ld.datacenter.poi.extention.XSSFCellStyleRule; import com.ld.datacenter.poi.extention.impl.XSSFCellStyleRuleImpl; import com.ld.datacenter.poi.helper.CellStyle; import com.ld.datacenter.poi.style.ICellStyleFactory;
package com.ld.datacenter.poi.convert; public class CellStyleConvert implements ICellStyleConvert { @Override
// Path: extention/XSSFCellStyleLib.java // public class XSSFCellStyleLib { // /** 樣式緩存*/ // private final Map<CellStyle,XSSFCellStyle> CELL_STYLE_MAP=new LinkedHashMap<CellStyle, XSSFCellStyle>(); // // <<<<<<< HEAD // @SuppressWarnings("unused") // ======= // >>>>>>> fe2012a7f8558d8df36b789847bdc41c788d6eaf // private final XSSFWorkbook wb; // // public XSSFCellStyleLib(XSSFWorkbook wb){ // this.wb=wb; // ICellStyleConvert convert=new CellStyleConvert(); // //添加cell樣式 // convert.convert(CellStyle.NONE, new DefaultCellStyleImpl(wb),this); // convert.convert(CellStyle.DEFAULT, new DefaultCellStyleImpl(wb),this); // convert.convert(CellStyle.STANDARD, new TextCellStyleImpl(wb),this); // <<<<<<< HEAD // convert.convert(CellStyle.TITLE, new TitleCellStyleImpl(wb),this); // ======= // >>>>>>> fe2012a7f8558d8df36b789847bdc41c788d6eaf // } // // // public void addStyle(CellStyle k,XSSFCellStyle v){ // CELL_STYLE_MAP.put(k, v); // } // // public void removeStyle(CellStyle k){ // CELL_STYLE_MAP.remove(k); // } // // public XSSFCellStyle get(CellStyle k){ // XSSFCellStyle v=CELL_STYLE_MAP.get(k); // if(null==v){ // throw new CellStyleNotFoundException("the cell style have not been defined!"); // } // return v; // } // // public void clear(){ // CELL_STYLE_MAP.clear(); // } // } // // Path: extention/XSSFCellStyleRule.java // public interface XSSFCellStyleRule { // /** // * 註冊樣式 // */ // void registerStyleRule(CellStyle k,XSSFCellStyle v,XSSFCellStyleLib lib); // /** // * 移除樣式 // */ // void removeStyleRule(CellStyle k,XSSFCellStyleLib lib); // // } // // Path: extention/impl/XSSFCellStyleRuleImpl.java // public class XSSFCellStyleRuleImpl implements XSSFCellStyleRule{ // // @Override // public void registerStyleRule(CellStyle k, XSSFCellStyle v, // XSSFCellStyleLib lib) { // // lib.addStyle(k, v); // } // // @Override // public void removeStyleRule(CellStyle k, XSSFCellStyleLib lib) { // lib.removeStyle(k); // // } // // // // } // // Path: helper/CellStyle.java // public enum CellStyle { // <<<<<<< HEAD // NONE,DEFAULT,TITLE,STANDARD // ======= // NONE,DEFAULT,STANDARD // >>>>>>> fe2012a7f8558d8df36b789847bdc41c788d6eaf // } // // Path: style/ICellStyleFactory.java // public interface ICellStyleFactory { // // /** // * @param wb // * @return {@code XSSFCellStyle} // */ // XSSFCellStyle create(); // } // Path: convert/CellStyleConvert.java import com.ld.datacenter.poi.extention.XSSFCellStyleLib; import com.ld.datacenter.poi.extention.XSSFCellStyleRule; import com.ld.datacenter.poi.extention.impl.XSSFCellStyleRuleImpl; import com.ld.datacenter.poi.helper.CellStyle; import com.ld.datacenter.poi.style.ICellStyleFactory; package com.ld.datacenter.poi.convert; public class CellStyleConvert implements ICellStyleConvert { @Override
public void convert(CellStyle k, ICellStyleFactory v,XSSFCellStyleLib lib) {
gp15237125756/PoiExcelExport2.0
convert/CellStyleConvert.java
// Path: extention/XSSFCellStyleLib.java // public class XSSFCellStyleLib { // /** 樣式緩存*/ // private final Map<CellStyle,XSSFCellStyle> CELL_STYLE_MAP=new LinkedHashMap<CellStyle, XSSFCellStyle>(); // // <<<<<<< HEAD // @SuppressWarnings("unused") // ======= // >>>>>>> fe2012a7f8558d8df36b789847bdc41c788d6eaf // private final XSSFWorkbook wb; // // public XSSFCellStyleLib(XSSFWorkbook wb){ // this.wb=wb; // ICellStyleConvert convert=new CellStyleConvert(); // //添加cell樣式 // convert.convert(CellStyle.NONE, new DefaultCellStyleImpl(wb),this); // convert.convert(CellStyle.DEFAULT, new DefaultCellStyleImpl(wb),this); // convert.convert(CellStyle.STANDARD, new TextCellStyleImpl(wb),this); // <<<<<<< HEAD // convert.convert(CellStyle.TITLE, new TitleCellStyleImpl(wb),this); // ======= // >>>>>>> fe2012a7f8558d8df36b789847bdc41c788d6eaf // } // // // public void addStyle(CellStyle k,XSSFCellStyle v){ // CELL_STYLE_MAP.put(k, v); // } // // public void removeStyle(CellStyle k){ // CELL_STYLE_MAP.remove(k); // } // // public XSSFCellStyle get(CellStyle k){ // XSSFCellStyle v=CELL_STYLE_MAP.get(k); // if(null==v){ // throw new CellStyleNotFoundException("the cell style have not been defined!"); // } // return v; // } // // public void clear(){ // CELL_STYLE_MAP.clear(); // } // } // // Path: extention/XSSFCellStyleRule.java // public interface XSSFCellStyleRule { // /** // * 註冊樣式 // */ // void registerStyleRule(CellStyle k,XSSFCellStyle v,XSSFCellStyleLib lib); // /** // * 移除樣式 // */ // void removeStyleRule(CellStyle k,XSSFCellStyleLib lib); // // } // // Path: extention/impl/XSSFCellStyleRuleImpl.java // public class XSSFCellStyleRuleImpl implements XSSFCellStyleRule{ // // @Override // public void registerStyleRule(CellStyle k, XSSFCellStyle v, // XSSFCellStyleLib lib) { // // lib.addStyle(k, v); // } // // @Override // public void removeStyleRule(CellStyle k, XSSFCellStyleLib lib) { // lib.removeStyle(k); // // } // // // // } // // Path: helper/CellStyle.java // public enum CellStyle { // <<<<<<< HEAD // NONE,DEFAULT,TITLE,STANDARD // ======= // NONE,DEFAULT,STANDARD // >>>>>>> fe2012a7f8558d8df36b789847bdc41c788d6eaf // } // // Path: style/ICellStyleFactory.java // public interface ICellStyleFactory { // // /** // * @param wb // * @return {@code XSSFCellStyle} // */ // XSSFCellStyle create(); // }
import com.ld.datacenter.poi.extention.XSSFCellStyleLib; import com.ld.datacenter.poi.extention.XSSFCellStyleRule; import com.ld.datacenter.poi.extention.impl.XSSFCellStyleRuleImpl; import com.ld.datacenter.poi.helper.CellStyle; import com.ld.datacenter.poi.style.ICellStyleFactory;
package com.ld.datacenter.poi.convert; public class CellStyleConvert implements ICellStyleConvert { @Override
// Path: extention/XSSFCellStyleLib.java // public class XSSFCellStyleLib { // /** 樣式緩存*/ // private final Map<CellStyle,XSSFCellStyle> CELL_STYLE_MAP=new LinkedHashMap<CellStyle, XSSFCellStyle>(); // // <<<<<<< HEAD // @SuppressWarnings("unused") // ======= // >>>>>>> fe2012a7f8558d8df36b789847bdc41c788d6eaf // private final XSSFWorkbook wb; // // public XSSFCellStyleLib(XSSFWorkbook wb){ // this.wb=wb; // ICellStyleConvert convert=new CellStyleConvert(); // //添加cell樣式 // convert.convert(CellStyle.NONE, new DefaultCellStyleImpl(wb),this); // convert.convert(CellStyle.DEFAULT, new DefaultCellStyleImpl(wb),this); // convert.convert(CellStyle.STANDARD, new TextCellStyleImpl(wb),this); // <<<<<<< HEAD // convert.convert(CellStyle.TITLE, new TitleCellStyleImpl(wb),this); // ======= // >>>>>>> fe2012a7f8558d8df36b789847bdc41c788d6eaf // } // // // public void addStyle(CellStyle k,XSSFCellStyle v){ // CELL_STYLE_MAP.put(k, v); // } // // public void removeStyle(CellStyle k){ // CELL_STYLE_MAP.remove(k); // } // // public XSSFCellStyle get(CellStyle k){ // XSSFCellStyle v=CELL_STYLE_MAP.get(k); // if(null==v){ // throw new CellStyleNotFoundException("the cell style have not been defined!"); // } // return v; // } // // public void clear(){ // CELL_STYLE_MAP.clear(); // } // } // // Path: extention/XSSFCellStyleRule.java // public interface XSSFCellStyleRule { // /** // * 註冊樣式 // */ // void registerStyleRule(CellStyle k,XSSFCellStyle v,XSSFCellStyleLib lib); // /** // * 移除樣式 // */ // void removeStyleRule(CellStyle k,XSSFCellStyleLib lib); // // } // // Path: extention/impl/XSSFCellStyleRuleImpl.java // public class XSSFCellStyleRuleImpl implements XSSFCellStyleRule{ // // @Override // public void registerStyleRule(CellStyle k, XSSFCellStyle v, // XSSFCellStyleLib lib) { // // lib.addStyle(k, v); // } // // @Override // public void removeStyleRule(CellStyle k, XSSFCellStyleLib lib) { // lib.removeStyle(k); // // } // // // // } // // Path: helper/CellStyle.java // public enum CellStyle { // <<<<<<< HEAD // NONE,DEFAULT,TITLE,STANDARD // ======= // NONE,DEFAULT,STANDARD // >>>>>>> fe2012a7f8558d8df36b789847bdc41c788d6eaf // } // // Path: style/ICellStyleFactory.java // public interface ICellStyleFactory { // // /** // * @param wb // * @return {@code XSSFCellStyle} // */ // XSSFCellStyle create(); // } // Path: convert/CellStyleConvert.java import com.ld.datacenter.poi.extention.XSSFCellStyleLib; import com.ld.datacenter.poi.extention.XSSFCellStyleRule; import com.ld.datacenter.poi.extention.impl.XSSFCellStyleRuleImpl; import com.ld.datacenter.poi.helper.CellStyle; import com.ld.datacenter.poi.style.ICellStyleFactory; package com.ld.datacenter.poi.convert; public class CellStyleConvert implements ICellStyleConvert { @Override
public void convert(CellStyle k, ICellStyleFactory v,XSSFCellStyleLib lib) {
gp15237125756/PoiExcelExport2.0
convert/CellStyleConvert.java
// Path: extention/XSSFCellStyleLib.java // public class XSSFCellStyleLib { // /** 樣式緩存*/ // private final Map<CellStyle,XSSFCellStyle> CELL_STYLE_MAP=new LinkedHashMap<CellStyle, XSSFCellStyle>(); // // <<<<<<< HEAD // @SuppressWarnings("unused") // ======= // >>>>>>> fe2012a7f8558d8df36b789847bdc41c788d6eaf // private final XSSFWorkbook wb; // // public XSSFCellStyleLib(XSSFWorkbook wb){ // this.wb=wb; // ICellStyleConvert convert=new CellStyleConvert(); // //添加cell樣式 // convert.convert(CellStyle.NONE, new DefaultCellStyleImpl(wb),this); // convert.convert(CellStyle.DEFAULT, new DefaultCellStyleImpl(wb),this); // convert.convert(CellStyle.STANDARD, new TextCellStyleImpl(wb),this); // <<<<<<< HEAD // convert.convert(CellStyle.TITLE, new TitleCellStyleImpl(wb),this); // ======= // >>>>>>> fe2012a7f8558d8df36b789847bdc41c788d6eaf // } // // // public void addStyle(CellStyle k,XSSFCellStyle v){ // CELL_STYLE_MAP.put(k, v); // } // // public void removeStyle(CellStyle k){ // CELL_STYLE_MAP.remove(k); // } // // public XSSFCellStyle get(CellStyle k){ // XSSFCellStyle v=CELL_STYLE_MAP.get(k); // if(null==v){ // throw new CellStyleNotFoundException("the cell style have not been defined!"); // } // return v; // } // // public void clear(){ // CELL_STYLE_MAP.clear(); // } // } // // Path: extention/XSSFCellStyleRule.java // public interface XSSFCellStyleRule { // /** // * 註冊樣式 // */ // void registerStyleRule(CellStyle k,XSSFCellStyle v,XSSFCellStyleLib lib); // /** // * 移除樣式 // */ // void removeStyleRule(CellStyle k,XSSFCellStyleLib lib); // // } // // Path: extention/impl/XSSFCellStyleRuleImpl.java // public class XSSFCellStyleRuleImpl implements XSSFCellStyleRule{ // // @Override // public void registerStyleRule(CellStyle k, XSSFCellStyle v, // XSSFCellStyleLib lib) { // // lib.addStyle(k, v); // } // // @Override // public void removeStyleRule(CellStyle k, XSSFCellStyleLib lib) { // lib.removeStyle(k); // // } // // // // } // // Path: helper/CellStyle.java // public enum CellStyle { // <<<<<<< HEAD // NONE,DEFAULT,TITLE,STANDARD // ======= // NONE,DEFAULT,STANDARD // >>>>>>> fe2012a7f8558d8df36b789847bdc41c788d6eaf // } // // Path: style/ICellStyleFactory.java // public interface ICellStyleFactory { // // /** // * @param wb // * @return {@code XSSFCellStyle} // */ // XSSFCellStyle create(); // }
import com.ld.datacenter.poi.extention.XSSFCellStyleLib; import com.ld.datacenter.poi.extention.XSSFCellStyleRule; import com.ld.datacenter.poi.extention.impl.XSSFCellStyleRuleImpl; import com.ld.datacenter.poi.helper.CellStyle; import com.ld.datacenter.poi.style.ICellStyleFactory;
package com.ld.datacenter.poi.convert; public class CellStyleConvert implements ICellStyleConvert { @Override
// Path: extention/XSSFCellStyleLib.java // public class XSSFCellStyleLib { // /** 樣式緩存*/ // private final Map<CellStyle,XSSFCellStyle> CELL_STYLE_MAP=new LinkedHashMap<CellStyle, XSSFCellStyle>(); // // <<<<<<< HEAD // @SuppressWarnings("unused") // ======= // >>>>>>> fe2012a7f8558d8df36b789847bdc41c788d6eaf // private final XSSFWorkbook wb; // // public XSSFCellStyleLib(XSSFWorkbook wb){ // this.wb=wb; // ICellStyleConvert convert=new CellStyleConvert(); // //添加cell樣式 // convert.convert(CellStyle.NONE, new DefaultCellStyleImpl(wb),this); // convert.convert(CellStyle.DEFAULT, new DefaultCellStyleImpl(wb),this); // convert.convert(CellStyle.STANDARD, new TextCellStyleImpl(wb),this); // <<<<<<< HEAD // convert.convert(CellStyle.TITLE, new TitleCellStyleImpl(wb),this); // ======= // >>>>>>> fe2012a7f8558d8df36b789847bdc41c788d6eaf // } // // // public void addStyle(CellStyle k,XSSFCellStyle v){ // CELL_STYLE_MAP.put(k, v); // } // // public void removeStyle(CellStyle k){ // CELL_STYLE_MAP.remove(k); // } // // public XSSFCellStyle get(CellStyle k){ // XSSFCellStyle v=CELL_STYLE_MAP.get(k); // if(null==v){ // throw new CellStyleNotFoundException("the cell style have not been defined!"); // } // return v; // } // // public void clear(){ // CELL_STYLE_MAP.clear(); // } // } // // Path: extention/XSSFCellStyleRule.java // public interface XSSFCellStyleRule { // /** // * 註冊樣式 // */ // void registerStyleRule(CellStyle k,XSSFCellStyle v,XSSFCellStyleLib lib); // /** // * 移除樣式 // */ // void removeStyleRule(CellStyle k,XSSFCellStyleLib lib); // // } // // Path: extention/impl/XSSFCellStyleRuleImpl.java // public class XSSFCellStyleRuleImpl implements XSSFCellStyleRule{ // // @Override // public void registerStyleRule(CellStyle k, XSSFCellStyle v, // XSSFCellStyleLib lib) { // // lib.addStyle(k, v); // } // // @Override // public void removeStyleRule(CellStyle k, XSSFCellStyleLib lib) { // lib.removeStyle(k); // // } // // // // } // // Path: helper/CellStyle.java // public enum CellStyle { // <<<<<<< HEAD // NONE,DEFAULT,TITLE,STANDARD // ======= // NONE,DEFAULT,STANDARD // >>>>>>> fe2012a7f8558d8df36b789847bdc41c788d6eaf // } // // Path: style/ICellStyleFactory.java // public interface ICellStyleFactory { // // /** // * @param wb // * @return {@code XSSFCellStyle} // */ // XSSFCellStyle create(); // } // Path: convert/CellStyleConvert.java import com.ld.datacenter.poi.extention.XSSFCellStyleLib; import com.ld.datacenter.poi.extention.XSSFCellStyleRule; import com.ld.datacenter.poi.extention.impl.XSSFCellStyleRuleImpl; import com.ld.datacenter.poi.helper.CellStyle; import com.ld.datacenter.poi.style.ICellStyleFactory; package com.ld.datacenter.poi.convert; public class CellStyleConvert implements ICellStyleConvert { @Override
public void convert(CellStyle k, ICellStyleFactory v,XSSFCellStyleLib lib) {
gp15237125756/PoiExcelExport2.0
convert/CellStyleConvert.java
// Path: extention/XSSFCellStyleLib.java // public class XSSFCellStyleLib { // /** 樣式緩存*/ // private final Map<CellStyle,XSSFCellStyle> CELL_STYLE_MAP=new LinkedHashMap<CellStyle, XSSFCellStyle>(); // // <<<<<<< HEAD // @SuppressWarnings("unused") // ======= // >>>>>>> fe2012a7f8558d8df36b789847bdc41c788d6eaf // private final XSSFWorkbook wb; // // public XSSFCellStyleLib(XSSFWorkbook wb){ // this.wb=wb; // ICellStyleConvert convert=new CellStyleConvert(); // //添加cell樣式 // convert.convert(CellStyle.NONE, new DefaultCellStyleImpl(wb),this); // convert.convert(CellStyle.DEFAULT, new DefaultCellStyleImpl(wb),this); // convert.convert(CellStyle.STANDARD, new TextCellStyleImpl(wb),this); // <<<<<<< HEAD // convert.convert(CellStyle.TITLE, new TitleCellStyleImpl(wb),this); // ======= // >>>>>>> fe2012a7f8558d8df36b789847bdc41c788d6eaf // } // // // public void addStyle(CellStyle k,XSSFCellStyle v){ // CELL_STYLE_MAP.put(k, v); // } // // public void removeStyle(CellStyle k){ // CELL_STYLE_MAP.remove(k); // } // // public XSSFCellStyle get(CellStyle k){ // XSSFCellStyle v=CELL_STYLE_MAP.get(k); // if(null==v){ // throw new CellStyleNotFoundException("the cell style have not been defined!"); // } // return v; // } // // public void clear(){ // CELL_STYLE_MAP.clear(); // } // } // // Path: extention/XSSFCellStyleRule.java // public interface XSSFCellStyleRule { // /** // * 註冊樣式 // */ // void registerStyleRule(CellStyle k,XSSFCellStyle v,XSSFCellStyleLib lib); // /** // * 移除樣式 // */ // void removeStyleRule(CellStyle k,XSSFCellStyleLib lib); // // } // // Path: extention/impl/XSSFCellStyleRuleImpl.java // public class XSSFCellStyleRuleImpl implements XSSFCellStyleRule{ // // @Override // public void registerStyleRule(CellStyle k, XSSFCellStyle v, // XSSFCellStyleLib lib) { // // lib.addStyle(k, v); // } // // @Override // public void removeStyleRule(CellStyle k, XSSFCellStyleLib lib) { // lib.removeStyle(k); // // } // // // // } // // Path: helper/CellStyle.java // public enum CellStyle { // <<<<<<< HEAD // NONE,DEFAULT,TITLE,STANDARD // ======= // NONE,DEFAULT,STANDARD // >>>>>>> fe2012a7f8558d8df36b789847bdc41c788d6eaf // } // // Path: style/ICellStyleFactory.java // public interface ICellStyleFactory { // // /** // * @param wb // * @return {@code XSSFCellStyle} // */ // XSSFCellStyle create(); // }
import com.ld.datacenter.poi.extention.XSSFCellStyleLib; import com.ld.datacenter.poi.extention.XSSFCellStyleRule; import com.ld.datacenter.poi.extention.impl.XSSFCellStyleRuleImpl; import com.ld.datacenter.poi.helper.CellStyle; import com.ld.datacenter.poi.style.ICellStyleFactory;
package com.ld.datacenter.poi.convert; public class CellStyleConvert implements ICellStyleConvert { @Override public void convert(CellStyle k, ICellStyleFactory v,XSSFCellStyleLib lib) { <<<<<<< HEAD ======= // TODO Auto-generated method stub >>>>>>> fe2012a7f8558d8df36b789847bdc41c788d6eaf
// Path: extention/XSSFCellStyleLib.java // public class XSSFCellStyleLib { // /** 樣式緩存*/ // private final Map<CellStyle,XSSFCellStyle> CELL_STYLE_MAP=new LinkedHashMap<CellStyle, XSSFCellStyle>(); // // <<<<<<< HEAD // @SuppressWarnings("unused") // ======= // >>>>>>> fe2012a7f8558d8df36b789847bdc41c788d6eaf // private final XSSFWorkbook wb; // // public XSSFCellStyleLib(XSSFWorkbook wb){ // this.wb=wb; // ICellStyleConvert convert=new CellStyleConvert(); // //添加cell樣式 // convert.convert(CellStyle.NONE, new DefaultCellStyleImpl(wb),this); // convert.convert(CellStyle.DEFAULT, new DefaultCellStyleImpl(wb),this); // convert.convert(CellStyle.STANDARD, new TextCellStyleImpl(wb),this); // <<<<<<< HEAD // convert.convert(CellStyle.TITLE, new TitleCellStyleImpl(wb),this); // ======= // >>>>>>> fe2012a7f8558d8df36b789847bdc41c788d6eaf // } // // // public void addStyle(CellStyle k,XSSFCellStyle v){ // CELL_STYLE_MAP.put(k, v); // } // // public void removeStyle(CellStyle k){ // CELL_STYLE_MAP.remove(k); // } // // public XSSFCellStyle get(CellStyle k){ // XSSFCellStyle v=CELL_STYLE_MAP.get(k); // if(null==v){ // throw new CellStyleNotFoundException("the cell style have not been defined!"); // } // return v; // } // // public void clear(){ // CELL_STYLE_MAP.clear(); // } // } // // Path: extention/XSSFCellStyleRule.java // public interface XSSFCellStyleRule { // /** // * 註冊樣式 // */ // void registerStyleRule(CellStyle k,XSSFCellStyle v,XSSFCellStyleLib lib); // /** // * 移除樣式 // */ // void removeStyleRule(CellStyle k,XSSFCellStyleLib lib); // // } // // Path: extention/impl/XSSFCellStyleRuleImpl.java // public class XSSFCellStyleRuleImpl implements XSSFCellStyleRule{ // // @Override // public void registerStyleRule(CellStyle k, XSSFCellStyle v, // XSSFCellStyleLib lib) { // // lib.addStyle(k, v); // } // // @Override // public void removeStyleRule(CellStyle k, XSSFCellStyleLib lib) { // lib.removeStyle(k); // // } // // // // } // // Path: helper/CellStyle.java // public enum CellStyle { // <<<<<<< HEAD // NONE,DEFAULT,TITLE,STANDARD // ======= // NONE,DEFAULT,STANDARD // >>>>>>> fe2012a7f8558d8df36b789847bdc41c788d6eaf // } // // Path: style/ICellStyleFactory.java // public interface ICellStyleFactory { // // /** // * @param wb // * @return {@code XSSFCellStyle} // */ // XSSFCellStyle create(); // } // Path: convert/CellStyleConvert.java import com.ld.datacenter.poi.extention.XSSFCellStyleLib; import com.ld.datacenter.poi.extention.XSSFCellStyleRule; import com.ld.datacenter.poi.extention.impl.XSSFCellStyleRuleImpl; import com.ld.datacenter.poi.helper.CellStyle; import com.ld.datacenter.poi.style.ICellStyleFactory; package com.ld.datacenter.poi.convert; public class CellStyleConvert implements ICellStyleConvert { @Override public void convert(CellStyle k, ICellStyleFactory v,XSSFCellStyleLib lib) { <<<<<<< HEAD ======= // TODO Auto-generated method stub >>>>>>> fe2012a7f8558d8df36b789847bdc41c788d6eaf
XSSFCellStyleRule rule=new XSSFCellStyleRuleImpl();
gp15237125756/PoiExcelExport2.0
convert/CellStyleConvert.java
// Path: extention/XSSFCellStyleLib.java // public class XSSFCellStyleLib { // /** 樣式緩存*/ // private final Map<CellStyle,XSSFCellStyle> CELL_STYLE_MAP=new LinkedHashMap<CellStyle, XSSFCellStyle>(); // // <<<<<<< HEAD // @SuppressWarnings("unused") // ======= // >>>>>>> fe2012a7f8558d8df36b789847bdc41c788d6eaf // private final XSSFWorkbook wb; // // public XSSFCellStyleLib(XSSFWorkbook wb){ // this.wb=wb; // ICellStyleConvert convert=new CellStyleConvert(); // //添加cell樣式 // convert.convert(CellStyle.NONE, new DefaultCellStyleImpl(wb),this); // convert.convert(CellStyle.DEFAULT, new DefaultCellStyleImpl(wb),this); // convert.convert(CellStyle.STANDARD, new TextCellStyleImpl(wb),this); // <<<<<<< HEAD // convert.convert(CellStyle.TITLE, new TitleCellStyleImpl(wb),this); // ======= // >>>>>>> fe2012a7f8558d8df36b789847bdc41c788d6eaf // } // // // public void addStyle(CellStyle k,XSSFCellStyle v){ // CELL_STYLE_MAP.put(k, v); // } // // public void removeStyle(CellStyle k){ // CELL_STYLE_MAP.remove(k); // } // // public XSSFCellStyle get(CellStyle k){ // XSSFCellStyle v=CELL_STYLE_MAP.get(k); // if(null==v){ // throw new CellStyleNotFoundException("the cell style have not been defined!"); // } // return v; // } // // public void clear(){ // CELL_STYLE_MAP.clear(); // } // } // // Path: extention/XSSFCellStyleRule.java // public interface XSSFCellStyleRule { // /** // * 註冊樣式 // */ // void registerStyleRule(CellStyle k,XSSFCellStyle v,XSSFCellStyleLib lib); // /** // * 移除樣式 // */ // void removeStyleRule(CellStyle k,XSSFCellStyleLib lib); // // } // // Path: extention/impl/XSSFCellStyleRuleImpl.java // public class XSSFCellStyleRuleImpl implements XSSFCellStyleRule{ // // @Override // public void registerStyleRule(CellStyle k, XSSFCellStyle v, // XSSFCellStyleLib lib) { // // lib.addStyle(k, v); // } // // @Override // public void removeStyleRule(CellStyle k, XSSFCellStyleLib lib) { // lib.removeStyle(k); // // } // // // // } // // Path: helper/CellStyle.java // public enum CellStyle { // <<<<<<< HEAD // NONE,DEFAULT,TITLE,STANDARD // ======= // NONE,DEFAULT,STANDARD // >>>>>>> fe2012a7f8558d8df36b789847bdc41c788d6eaf // } // // Path: style/ICellStyleFactory.java // public interface ICellStyleFactory { // // /** // * @param wb // * @return {@code XSSFCellStyle} // */ // XSSFCellStyle create(); // }
import com.ld.datacenter.poi.extention.XSSFCellStyleLib; import com.ld.datacenter.poi.extention.XSSFCellStyleRule; import com.ld.datacenter.poi.extention.impl.XSSFCellStyleRuleImpl; import com.ld.datacenter.poi.helper.CellStyle; import com.ld.datacenter.poi.style.ICellStyleFactory;
package com.ld.datacenter.poi.convert; public class CellStyleConvert implements ICellStyleConvert { @Override public void convert(CellStyle k, ICellStyleFactory v,XSSFCellStyleLib lib) { <<<<<<< HEAD ======= // TODO Auto-generated method stub >>>>>>> fe2012a7f8558d8df36b789847bdc41c788d6eaf
// Path: extention/XSSFCellStyleLib.java // public class XSSFCellStyleLib { // /** 樣式緩存*/ // private final Map<CellStyle,XSSFCellStyle> CELL_STYLE_MAP=new LinkedHashMap<CellStyle, XSSFCellStyle>(); // // <<<<<<< HEAD // @SuppressWarnings("unused") // ======= // >>>>>>> fe2012a7f8558d8df36b789847bdc41c788d6eaf // private final XSSFWorkbook wb; // // public XSSFCellStyleLib(XSSFWorkbook wb){ // this.wb=wb; // ICellStyleConvert convert=new CellStyleConvert(); // //添加cell樣式 // convert.convert(CellStyle.NONE, new DefaultCellStyleImpl(wb),this); // convert.convert(CellStyle.DEFAULT, new DefaultCellStyleImpl(wb),this); // convert.convert(CellStyle.STANDARD, new TextCellStyleImpl(wb),this); // <<<<<<< HEAD // convert.convert(CellStyle.TITLE, new TitleCellStyleImpl(wb),this); // ======= // >>>>>>> fe2012a7f8558d8df36b789847bdc41c788d6eaf // } // // // public void addStyle(CellStyle k,XSSFCellStyle v){ // CELL_STYLE_MAP.put(k, v); // } // // public void removeStyle(CellStyle k){ // CELL_STYLE_MAP.remove(k); // } // // public XSSFCellStyle get(CellStyle k){ // XSSFCellStyle v=CELL_STYLE_MAP.get(k); // if(null==v){ // throw new CellStyleNotFoundException("the cell style have not been defined!"); // } // return v; // } // // public void clear(){ // CELL_STYLE_MAP.clear(); // } // } // // Path: extention/XSSFCellStyleRule.java // public interface XSSFCellStyleRule { // /** // * 註冊樣式 // */ // void registerStyleRule(CellStyle k,XSSFCellStyle v,XSSFCellStyleLib lib); // /** // * 移除樣式 // */ // void removeStyleRule(CellStyle k,XSSFCellStyleLib lib); // // } // // Path: extention/impl/XSSFCellStyleRuleImpl.java // public class XSSFCellStyleRuleImpl implements XSSFCellStyleRule{ // // @Override // public void registerStyleRule(CellStyle k, XSSFCellStyle v, // XSSFCellStyleLib lib) { // // lib.addStyle(k, v); // } // // @Override // public void removeStyleRule(CellStyle k, XSSFCellStyleLib lib) { // lib.removeStyle(k); // // } // // // // } // // Path: helper/CellStyle.java // public enum CellStyle { // <<<<<<< HEAD // NONE,DEFAULT,TITLE,STANDARD // ======= // NONE,DEFAULT,STANDARD // >>>>>>> fe2012a7f8558d8df36b789847bdc41c788d6eaf // } // // Path: style/ICellStyleFactory.java // public interface ICellStyleFactory { // // /** // * @param wb // * @return {@code XSSFCellStyle} // */ // XSSFCellStyle create(); // } // Path: convert/CellStyleConvert.java import com.ld.datacenter.poi.extention.XSSFCellStyleLib; import com.ld.datacenter.poi.extention.XSSFCellStyleRule; import com.ld.datacenter.poi.extention.impl.XSSFCellStyleRuleImpl; import com.ld.datacenter.poi.helper.CellStyle; import com.ld.datacenter.poi.style.ICellStyleFactory; package com.ld.datacenter.poi.convert; public class CellStyleConvert implements ICellStyleConvert { @Override public void convert(CellStyle k, ICellStyleFactory v,XSSFCellStyleLib lib) { <<<<<<< HEAD ======= // TODO Auto-generated method stub >>>>>>> fe2012a7f8558d8df36b789847bdc41c788d6eaf
XSSFCellStyleRule rule=new XSSFCellStyleRuleImpl();
gp15237125756/PoiExcelExport2.0
annotation/TitleAttribute.java
// Path: helper/CellStyle.java // public enum CellStyle { // <<<<<<< HEAD // NONE,DEFAULT,TITLE,STANDARD // ======= // NONE,DEFAULT,STANDARD // >>>>>>> fe2012a7f8558d8df36b789847bdc41c788d6eaf // } // // Path: helper/FontStyle.java // public enum FontStyle { // <<<<<<< HEAD // NONE,DEFAULT,TITLE,COLOR // ======= // NONE,DEFAULT,COLOR // >>>>>>> fe2012a7f8558d8df36b789847bdc41c788d6eaf // }
import java.lang.annotation.Documented; import java.lang.annotation.ElementType; import java.lang.annotation.Repeatable; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; import com.ld.datacenter.poi.helper.CellStyle; import com.ld.datacenter.poi.helper.FontStyle;
package com.ld.datacenter.poi.annotation; /** * 标记excel标题栏 */ @Repeatable(TitleAttributes.class) @Target({ ElementType.TYPE }) @Retention(RetentionPolicy.RUNTIME) @Documented public @interface TitleAttribute { /** * 格子样式 */
// Path: helper/CellStyle.java // public enum CellStyle { // <<<<<<< HEAD // NONE,DEFAULT,TITLE,STANDARD // ======= // NONE,DEFAULT,STANDARD // >>>>>>> fe2012a7f8558d8df36b789847bdc41c788d6eaf // } // // Path: helper/FontStyle.java // public enum FontStyle { // <<<<<<< HEAD // NONE,DEFAULT,TITLE,COLOR // ======= // NONE,DEFAULT,COLOR // >>>>>>> fe2012a7f8558d8df36b789847bdc41c788d6eaf // } // Path: annotation/TitleAttribute.java import java.lang.annotation.Documented; import java.lang.annotation.ElementType; import java.lang.annotation.Repeatable; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; import com.ld.datacenter.poi.helper.CellStyle; import com.ld.datacenter.poi.helper.FontStyle; package com.ld.datacenter.poi.annotation; /** * 标记excel标题栏 */ @Repeatable(TitleAttributes.class) @Target({ ElementType.TYPE }) @Retention(RetentionPolicy.RUNTIME) @Documented public @interface TitleAttribute { /** * 格子样式 */
CellStyle cellStyle() default CellStyle.NONE;
gp15237125756/PoiExcelExport2.0
annotation/TitleAttribute.java
// Path: helper/CellStyle.java // public enum CellStyle { // <<<<<<< HEAD // NONE,DEFAULT,TITLE,STANDARD // ======= // NONE,DEFAULT,STANDARD // >>>>>>> fe2012a7f8558d8df36b789847bdc41c788d6eaf // } // // Path: helper/FontStyle.java // public enum FontStyle { // <<<<<<< HEAD // NONE,DEFAULT,TITLE,COLOR // ======= // NONE,DEFAULT,COLOR // >>>>>>> fe2012a7f8558d8df36b789847bdc41c788d6eaf // }
import java.lang.annotation.Documented; import java.lang.annotation.ElementType; import java.lang.annotation.Repeatable; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; import com.ld.datacenter.poi.helper.CellStyle; import com.ld.datacenter.poi.helper.FontStyle;
package com.ld.datacenter.poi.annotation; /** * 标记excel标题栏 */ @Repeatable(TitleAttributes.class) @Target({ ElementType.TYPE }) @Retention(RetentionPolicy.RUNTIME) @Documented public @interface TitleAttribute { /** * 格子样式 */ CellStyle cellStyle() default CellStyle.NONE; /** * 格子字体 */
// Path: helper/CellStyle.java // public enum CellStyle { // <<<<<<< HEAD // NONE,DEFAULT,TITLE,STANDARD // ======= // NONE,DEFAULT,STANDARD // >>>>>>> fe2012a7f8558d8df36b789847bdc41c788d6eaf // } // // Path: helper/FontStyle.java // public enum FontStyle { // <<<<<<< HEAD // NONE,DEFAULT,TITLE,COLOR // ======= // NONE,DEFAULT,COLOR // >>>>>>> fe2012a7f8558d8df36b789847bdc41c788d6eaf // } // Path: annotation/TitleAttribute.java import java.lang.annotation.Documented; import java.lang.annotation.ElementType; import java.lang.annotation.Repeatable; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; import com.ld.datacenter.poi.helper.CellStyle; import com.ld.datacenter.poi.helper.FontStyle; package com.ld.datacenter.poi.annotation; /** * 标记excel标题栏 */ @Repeatable(TitleAttributes.class) @Target({ ElementType.TYPE }) @Retention(RetentionPolicy.RUNTIME) @Documented public @interface TitleAttribute { /** * 格子样式 */ CellStyle cellStyle() default CellStyle.NONE; /** * 格子字体 */
FontStyle fontStyle() default FontStyle.NONE;
fengyuwusong/blog
src/test/java/cn/niriqiang/blog/service/TagServiceTest.java
// Path: src/test/java/cn/niriqiang/BlogApplicationTests.java // @RunWith(SpringRunner.class) // @SpringBootTest // public class BlogApplicationTests { // // @Test // public void contextLoads() { // } // // } // // Path: src/main/java/cn/niriqiang/blog/domain/Tag.java // @ApiModel // @Data // public class Tag { // @ApiModelProperty(value = "ID") // private Integer id; // @ApiModelProperty(value = "标签名") // @NotNull(message = "标签名字不能为空!") // private String tagName; // }
import cn.niriqiang.BlogApplicationTests; import cn.niriqiang.blog.domain.Tag; import org.junit.Test; import org.springframework.beans.factory.annotation.Autowired;
package cn.niriqiang.blog.service; /** * Created by fengyuwusong on 2017/9/26 1:03. */ //@Transactional public class TagServiceTest extends BlogApplicationTests { @Autowired private TagService tagService; @Test public void insertTag() throws Exception {
// Path: src/test/java/cn/niriqiang/BlogApplicationTests.java // @RunWith(SpringRunner.class) // @SpringBootTest // public class BlogApplicationTests { // // @Test // public void contextLoads() { // } // // } // // Path: src/main/java/cn/niriqiang/blog/domain/Tag.java // @ApiModel // @Data // public class Tag { // @ApiModelProperty(value = "ID") // private Integer id; // @ApiModelProperty(value = "标签名") // @NotNull(message = "标签名字不能为空!") // private String tagName; // } // Path: src/test/java/cn/niriqiang/blog/service/TagServiceTest.java import cn.niriqiang.BlogApplicationTests; import cn.niriqiang.blog.domain.Tag; import org.junit.Test; import org.springframework.beans.factory.annotation.Autowired; package cn.niriqiang.blog.service; /** * Created by fengyuwusong on 2017/9/26 1:03. */ //@Transactional public class TagServiceTest extends BlogApplicationTests { @Autowired private TagService tagService; @Test public void insertTag() throws Exception {
Tag tag = new Tag();
fengyuwusong/blog
src/main/java/cn/niriqiang/blog/service/CategoryService.java
// Path: src/main/java/cn/niriqiang/blog/domain/Category.java // @ApiModel // @Data // public class Category { // @ApiModelProperty(value = "ID") // private Integer id; // @ApiModelProperty(value = "分类名") // @NotNull(message = "类型名称不能为空") // private String categoryName; // @ApiModelProperty(value = "分类描述") // @NotNull(message = "描述不能为空") // private String description; // } // // Path: src/main/java/cn/niriqiang/blog/domain/CategoryMapper.java // @Mapper // @Repository // public interface CategoryMapper { // Category findByCategoryName(String categoryName); // // Category findOne(int id); // // int update(Category category); // // int insert(Category category); // // int delete(int id); // // List<Category> findAll(); // } // // Path: src/main/java/cn/niriqiang/blog/dto/Result.java // public class Result<T> { // // // private Integer code; // // private String message; // // private T data; // // @Override // public String toString() { // return "Result{" + // "code=" + code + // ", message='" + message + '\'' + // ", data=" + data + // '}'; // } // // public Result(Integer code, String message) { // this.code = code; // this.message = message; // } // // public Result(Integer code, String message, T data) { // this.code = code; // this.message = message; // this.data = data; // } // // public Integer getCode() { // return code; // } // // public void setCode(Integer code) { // this.code = code; // } // // public String getMessage() { // return message; // } // // public void setMessage(String message) { // this.message = message; // } // // public T getData() { // return data; // } // // public void setData(T data) { // this.data = data; // } // } // // Path: src/main/java/cn/niriqiang/blog/enums/ResultEnum.java // @ApiModel // public enum ResultEnum { // OK(200, "成功"), // NOT_BLANK(0, "不能为空"), // UNKNOW_ERROR(-1, "未知错误"), // NOT_FOUND(-2, "目标未找到"), // ADD_EXITS(-3, "目标已存在"), // DELETE_FALSE(-4, "不能删除相关文章还存在的分类"), // CURRENT_PAGE_NOT_NULL(-5, "页码不能为空"), // ERROR_NAME_PW(-6, "用户名密码错误"), // NOT_LOGIN(-7, "还没登陆!"); // // ResultEnum(Integer code, String message) { // this.code = code; // this.message = message; // } // // public Integer getCode() { // return code; // } // // public String getMessage() { // return message; // } // // @Override // public String toString() { // return "ResultEnum{" + // "code=" + code + // ", message='" + message + '\'' + // '}'; // } // // Integer code; // String message; // } // // Path: src/main/java/cn/niriqiang/blog/exception/ArticleException.java // public class ArticleException extends Exception { // // public ArticleException(ResultEnum resultEnum) { // super(resultEnum); // } // // public ArticleException(String message, Integer code) { // super(message, code); // } // // } // // Path: src/main/java/cn/niriqiang/blog/exception/CategoryException.java // public class CategoryException extends Exception { // public CategoryException(ResultEnum resultEnum) { // super(resultEnum); // } // // public CategoryException(String message, Integer code) { // super(message, code); // } // // } // // Path: src/main/java/cn/niriqiang/blog/util/ResultUtil.java // public class ResultUtil { // public static <T> Result<T> success(ResultEnum resultEnum, T t) { // return new Result(resultEnum.getCode(), resultEnum.getMessage(), t); // } // // public static Result error(Integer code, String message) { // return new Result(code, message); // } // // public static Result error(ResultEnum resultEnum) { // return new Result(resultEnum.getCode(), resultEnum.getMessage()); // } // }
import cn.niriqiang.blog.domain.Category; import cn.niriqiang.blog.domain.CategoryMapper; import cn.niriqiang.blog.dto.Result; import cn.niriqiang.blog.enums.ResultEnum; import cn.niriqiang.blog.exception.ArticleException; import cn.niriqiang.blog.exception.CategoryException; import cn.niriqiang.blog.util.ResultUtil; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import java.util.List;
package cn.niriqiang.blog.service; /** * Created by fengyuwusong on 2017/9/27 0:43. */ @Service public class CategoryService { @Autowired
// Path: src/main/java/cn/niriqiang/blog/domain/Category.java // @ApiModel // @Data // public class Category { // @ApiModelProperty(value = "ID") // private Integer id; // @ApiModelProperty(value = "分类名") // @NotNull(message = "类型名称不能为空") // private String categoryName; // @ApiModelProperty(value = "分类描述") // @NotNull(message = "描述不能为空") // private String description; // } // // Path: src/main/java/cn/niriqiang/blog/domain/CategoryMapper.java // @Mapper // @Repository // public interface CategoryMapper { // Category findByCategoryName(String categoryName); // // Category findOne(int id); // // int update(Category category); // // int insert(Category category); // // int delete(int id); // // List<Category> findAll(); // } // // Path: src/main/java/cn/niriqiang/blog/dto/Result.java // public class Result<T> { // // // private Integer code; // // private String message; // // private T data; // // @Override // public String toString() { // return "Result{" + // "code=" + code + // ", message='" + message + '\'' + // ", data=" + data + // '}'; // } // // public Result(Integer code, String message) { // this.code = code; // this.message = message; // } // // public Result(Integer code, String message, T data) { // this.code = code; // this.message = message; // this.data = data; // } // // public Integer getCode() { // return code; // } // // public void setCode(Integer code) { // this.code = code; // } // // public String getMessage() { // return message; // } // // public void setMessage(String message) { // this.message = message; // } // // public T getData() { // return data; // } // // public void setData(T data) { // this.data = data; // } // } // // Path: src/main/java/cn/niriqiang/blog/enums/ResultEnum.java // @ApiModel // public enum ResultEnum { // OK(200, "成功"), // NOT_BLANK(0, "不能为空"), // UNKNOW_ERROR(-1, "未知错误"), // NOT_FOUND(-2, "目标未找到"), // ADD_EXITS(-3, "目标已存在"), // DELETE_FALSE(-4, "不能删除相关文章还存在的分类"), // CURRENT_PAGE_NOT_NULL(-5, "页码不能为空"), // ERROR_NAME_PW(-6, "用户名密码错误"), // NOT_LOGIN(-7, "还没登陆!"); // // ResultEnum(Integer code, String message) { // this.code = code; // this.message = message; // } // // public Integer getCode() { // return code; // } // // public String getMessage() { // return message; // } // // @Override // public String toString() { // return "ResultEnum{" + // "code=" + code + // ", message='" + message + '\'' + // '}'; // } // // Integer code; // String message; // } // // Path: src/main/java/cn/niriqiang/blog/exception/ArticleException.java // public class ArticleException extends Exception { // // public ArticleException(ResultEnum resultEnum) { // super(resultEnum); // } // // public ArticleException(String message, Integer code) { // super(message, code); // } // // } // // Path: src/main/java/cn/niriqiang/blog/exception/CategoryException.java // public class CategoryException extends Exception { // public CategoryException(ResultEnum resultEnum) { // super(resultEnum); // } // // public CategoryException(String message, Integer code) { // super(message, code); // } // // } // // Path: src/main/java/cn/niriqiang/blog/util/ResultUtil.java // public class ResultUtil { // public static <T> Result<T> success(ResultEnum resultEnum, T t) { // return new Result(resultEnum.getCode(), resultEnum.getMessage(), t); // } // // public static Result error(Integer code, String message) { // return new Result(code, message); // } // // public static Result error(ResultEnum resultEnum) { // return new Result(resultEnum.getCode(), resultEnum.getMessage()); // } // } // Path: src/main/java/cn/niriqiang/blog/service/CategoryService.java import cn.niriqiang.blog.domain.Category; import cn.niriqiang.blog.domain.CategoryMapper; import cn.niriqiang.blog.dto.Result; import cn.niriqiang.blog.enums.ResultEnum; import cn.niriqiang.blog.exception.ArticleException; import cn.niriqiang.blog.exception.CategoryException; import cn.niriqiang.blog.util.ResultUtil; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import java.util.List; package cn.niriqiang.blog.service; /** * Created by fengyuwusong on 2017/9/27 0:43. */ @Service public class CategoryService { @Autowired
private CategoryMapper mapper;
fengyuwusong/blog
src/main/java/cn/niriqiang/blog/service/CategoryService.java
// Path: src/main/java/cn/niriqiang/blog/domain/Category.java // @ApiModel // @Data // public class Category { // @ApiModelProperty(value = "ID") // private Integer id; // @ApiModelProperty(value = "分类名") // @NotNull(message = "类型名称不能为空") // private String categoryName; // @ApiModelProperty(value = "分类描述") // @NotNull(message = "描述不能为空") // private String description; // } // // Path: src/main/java/cn/niriqiang/blog/domain/CategoryMapper.java // @Mapper // @Repository // public interface CategoryMapper { // Category findByCategoryName(String categoryName); // // Category findOne(int id); // // int update(Category category); // // int insert(Category category); // // int delete(int id); // // List<Category> findAll(); // } // // Path: src/main/java/cn/niriqiang/blog/dto/Result.java // public class Result<T> { // // // private Integer code; // // private String message; // // private T data; // // @Override // public String toString() { // return "Result{" + // "code=" + code + // ", message='" + message + '\'' + // ", data=" + data + // '}'; // } // // public Result(Integer code, String message) { // this.code = code; // this.message = message; // } // // public Result(Integer code, String message, T data) { // this.code = code; // this.message = message; // this.data = data; // } // // public Integer getCode() { // return code; // } // // public void setCode(Integer code) { // this.code = code; // } // // public String getMessage() { // return message; // } // // public void setMessage(String message) { // this.message = message; // } // // public T getData() { // return data; // } // // public void setData(T data) { // this.data = data; // } // } // // Path: src/main/java/cn/niriqiang/blog/enums/ResultEnum.java // @ApiModel // public enum ResultEnum { // OK(200, "成功"), // NOT_BLANK(0, "不能为空"), // UNKNOW_ERROR(-1, "未知错误"), // NOT_FOUND(-2, "目标未找到"), // ADD_EXITS(-3, "目标已存在"), // DELETE_FALSE(-4, "不能删除相关文章还存在的分类"), // CURRENT_PAGE_NOT_NULL(-5, "页码不能为空"), // ERROR_NAME_PW(-6, "用户名密码错误"), // NOT_LOGIN(-7, "还没登陆!"); // // ResultEnum(Integer code, String message) { // this.code = code; // this.message = message; // } // // public Integer getCode() { // return code; // } // // public String getMessage() { // return message; // } // // @Override // public String toString() { // return "ResultEnum{" + // "code=" + code + // ", message='" + message + '\'' + // '}'; // } // // Integer code; // String message; // } // // Path: src/main/java/cn/niriqiang/blog/exception/ArticleException.java // public class ArticleException extends Exception { // // public ArticleException(ResultEnum resultEnum) { // super(resultEnum); // } // // public ArticleException(String message, Integer code) { // super(message, code); // } // // } // // Path: src/main/java/cn/niriqiang/blog/exception/CategoryException.java // public class CategoryException extends Exception { // public CategoryException(ResultEnum resultEnum) { // super(resultEnum); // } // // public CategoryException(String message, Integer code) { // super(message, code); // } // // } // // Path: src/main/java/cn/niriqiang/blog/util/ResultUtil.java // public class ResultUtil { // public static <T> Result<T> success(ResultEnum resultEnum, T t) { // return new Result(resultEnum.getCode(), resultEnum.getMessage(), t); // } // // public static Result error(Integer code, String message) { // return new Result(code, message); // } // // public static Result error(ResultEnum resultEnum) { // return new Result(resultEnum.getCode(), resultEnum.getMessage()); // } // }
import cn.niriqiang.blog.domain.Category; import cn.niriqiang.blog.domain.CategoryMapper; import cn.niriqiang.blog.dto.Result; import cn.niriqiang.blog.enums.ResultEnum; import cn.niriqiang.blog.exception.ArticleException; import cn.niriqiang.blog.exception.CategoryException; import cn.niriqiang.blog.util.ResultUtil; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import java.util.List;
package cn.niriqiang.blog.service; /** * Created by fengyuwusong on 2017/9/27 0:43. */ @Service public class CategoryService { @Autowired private CategoryMapper mapper; @Autowired private ArticleService articleService;
// Path: src/main/java/cn/niriqiang/blog/domain/Category.java // @ApiModel // @Data // public class Category { // @ApiModelProperty(value = "ID") // private Integer id; // @ApiModelProperty(value = "分类名") // @NotNull(message = "类型名称不能为空") // private String categoryName; // @ApiModelProperty(value = "分类描述") // @NotNull(message = "描述不能为空") // private String description; // } // // Path: src/main/java/cn/niriqiang/blog/domain/CategoryMapper.java // @Mapper // @Repository // public interface CategoryMapper { // Category findByCategoryName(String categoryName); // // Category findOne(int id); // // int update(Category category); // // int insert(Category category); // // int delete(int id); // // List<Category> findAll(); // } // // Path: src/main/java/cn/niriqiang/blog/dto/Result.java // public class Result<T> { // // // private Integer code; // // private String message; // // private T data; // // @Override // public String toString() { // return "Result{" + // "code=" + code + // ", message='" + message + '\'' + // ", data=" + data + // '}'; // } // // public Result(Integer code, String message) { // this.code = code; // this.message = message; // } // // public Result(Integer code, String message, T data) { // this.code = code; // this.message = message; // this.data = data; // } // // public Integer getCode() { // return code; // } // // public void setCode(Integer code) { // this.code = code; // } // // public String getMessage() { // return message; // } // // public void setMessage(String message) { // this.message = message; // } // // public T getData() { // return data; // } // // public void setData(T data) { // this.data = data; // } // } // // Path: src/main/java/cn/niriqiang/blog/enums/ResultEnum.java // @ApiModel // public enum ResultEnum { // OK(200, "成功"), // NOT_BLANK(0, "不能为空"), // UNKNOW_ERROR(-1, "未知错误"), // NOT_FOUND(-2, "目标未找到"), // ADD_EXITS(-3, "目标已存在"), // DELETE_FALSE(-4, "不能删除相关文章还存在的分类"), // CURRENT_PAGE_NOT_NULL(-5, "页码不能为空"), // ERROR_NAME_PW(-6, "用户名密码错误"), // NOT_LOGIN(-7, "还没登陆!"); // // ResultEnum(Integer code, String message) { // this.code = code; // this.message = message; // } // // public Integer getCode() { // return code; // } // // public String getMessage() { // return message; // } // // @Override // public String toString() { // return "ResultEnum{" + // "code=" + code + // ", message='" + message + '\'' + // '}'; // } // // Integer code; // String message; // } // // Path: src/main/java/cn/niriqiang/blog/exception/ArticleException.java // public class ArticleException extends Exception { // // public ArticleException(ResultEnum resultEnum) { // super(resultEnum); // } // // public ArticleException(String message, Integer code) { // super(message, code); // } // // } // // Path: src/main/java/cn/niriqiang/blog/exception/CategoryException.java // public class CategoryException extends Exception { // public CategoryException(ResultEnum resultEnum) { // super(resultEnum); // } // // public CategoryException(String message, Integer code) { // super(message, code); // } // // } // // Path: src/main/java/cn/niriqiang/blog/util/ResultUtil.java // public class ResultUtil { // public static <T> Result<T> success(ResultEnum resultEnum, T t) { // return new Result(resultEnum.getCode(), resultEnum.getMessage(), t); // } // // public static Result error(Integer code, String message) { // return new Result(code, message); // } // // public static Result error(ResultEnum resultEnum) { // return new Result(resultEnum.getCode(), resultEnum.getMessage()); // } // } // Path: src/main/java/cn/niriqiang/blog/service/CategoryService.java import cn.niriqiang.blog.domain.Category; import cn.niriqiang.blog.domain.CategoryMapper; import cn.niriqiang.blog.dto.Result; import cn.niriqiang.blog.enums.ResultEnum; import cn.niriqiang.blog.exception.ArticleException; import cn.niriqiang.blog.exception.CategoryException; import cn.niriqiang.blog.util.ResultUtil; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import java.util.List; package cn.niriqiang.blog.service; /** * Created by fengyuwusong on 2017/9/27 0:43. */ @Service public class CategoryService { @Autowired private CategoryMapper mapper; @Autowired private ArticleService articleService;
public Result insertCategory(Category category) {
fengyuwusong/blog
src/main/java/cn/niriqiang/blog/service/CategoryService.java
// Path: src/main/java/cn/niriqiang/blog/domain/Category.java // @ApiModel // @Data // public class Category { // @ApiModelProperty(value = "ID") // private Integer id; // @ApiModelProperty(value = "分类名") // @NotNull(message = "类型名称不能为空") // private String categoryName; // @ApiModelProperty(value = "分类描述") // @NotNull(message = "描述不能为空") // private String description; // } // // Path: src/main/java/cn/niriqiang/blog/domain/CategoryMapper.java // @Mapper // @Repository // public interface CategoryMapper { // Category findByCategoryName(String categoryName); // // Category findOne(int id); // // int update(Category category); // // int insert(Category category); // // int delete(int id); // // List<Category> findAll(); // } // // Path: src/main/java/cn/niriqiang/blog/dto/Result.java // public class Result<T> { // // // private Integer code; // // private String message; // // private T data; // // @Override // public String toString() { // return "Result{" + // "code=" + code + // ", message='" + message + '\'' + // ", data=" + data + // '}'; // } // // public Result(Integer code, String message) { // this.code = code; // this.message = message; // } // // public Result(Integer code, String message, T data) { // this.code = code; // this.message = message; // this.data = data; // } // // public Integer getCode() { // return code; // } // // public void setCode(Integer code) { // this.code = code; // } // // public String getMessage() { // return message; // } // // public void setMessage(String message) { // this.message = message; // } // // public T getData() { // return data; // } // // public void setData(T data) { // this.data = data; // } // } // // Path: src/main/java/cn/niriqiang/blog/enums/ResultEnum.java // @ApiModel // public enum ResultEnum { // OK(200, "成功"), // NOT_BLANK(0, "不能为空"), // UNKNOW_ERROR(-1, "未知错误"), // NOT_FOUND(-2, "目标未找到"), // ADD_EXITS(-3, "目标已存在"), // DELETE_FALSE(-4, "不能删除相关文章还存在的分类"), // CURRENT_PAGE_NOT_NULL(-5, "页码不能为空"), // ERROR_NAME_PW(-6, "用户名密码错误"), // NOT_LOGIN(-7, "还没登陆!"); // // ResultEnum(Integer code, String message) { // this.code = code; // this.message = message; // } // // public Integer getCode() { // return code; // } // // public String getMessage() { // return message; // } // // @Override // public String toString() { // return "ResultEnum{" + // "code=" + code + // ", message='" + message + '\'' + // '}'; // } // // Integer code; // String message; // } // // Path: src/main/java/cn/niriqiang/blog/exception/ArticleException.java // public class ArticleException extends Exception { // // public ArticleException(ResultEnum resultEnum) { // super(resultEnum); // } // // public ArticleException(String message, Integer code) { // super(message, code); // } // // } // // Path: src/main/java/cn/niriqiang/blog/exception/CategoryException.java // public class CategoryException extends Exception { // public CategoryException(ResultEnum resultEnum) { // super(resultEnum); // } // // public CategoryException(String message, Integer code) { // super(message, code); // } // // } // // Path: src/main/java/cn/niriqiang/blog/util/ResultUtil.java // public class ResultUtil { // public static <T> Result<T> success(ResultEnum resultEnum, T t) { // return new Result(resultEnum.getCode(), resultEnum.getMessage(), t); // } // // public static Result error(Integer code, String message) { // return new Result(code, message); // } // // public static Result error(ResultEnum resultEnum) { // return new Result(resultEnum.getCode(), resultEnum.getMessage()); // } // }
import cn.niriqiang.blog.domain.Category; import cn.niriqiang.blog.domain.CategoryMapper; import cn.niriqiang.blog.dto.Result; import cn.niriqiang.blog.enums.ResultEnum; import cn.niriqiang.blog.exception.ArticleException; import cn.niriqiang.blog.exception.CategoryException; import cn.niriqiang.blog.util.ResultUtil; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import java.util.List;
package cn.niriqiang.blog.service; /** * Created by fengyuwusong on 2017/9/27 0:43. */ @Service public class CategoryService { @Autowired private CategoryMapper mapper; @Autowired private ArticleService articleService;
// Path: src/main/java/cn/niriqiang/blog/domain/Category.java // @ApiModel // @Data // public class Category { // @ApiModelProperty(value = "ID") // private Integer id; // @ApiModelProperty(value = "分类名") // @NotNull(message = "类型名称不能为空") // private String categoryName; // @ApiModelProperty(value = "分类描述") // @NotNull(message = "描述不能为空") // private String description; // } // // Path: src/main/java/cn/niriqiang/blog/domain/CategoryMapper.java // @Mapper // @Repository // public interface CategoryMapper { // Category findByCategoryName(String categoryName); // // Category findOne(int id); // // int update(Category category); // // int insert(Category category); // // int delete(int id); // // List<Category> findAll(); // } // // Path: src/main/java/cn/niriqiang/blog/dto/Result.java // public class Result<T> { // // // private Integer code; // // private String message; // // private T data; // // @Override // public String toString() { // return "Result{" + // "code=" + code + // ", message='" + message + '\'' + // ", data=" + data + // '}'; // } // // public Result(Integer code, String message) { // this.code = code; // this.message = message; // } // // public Result(Integer code, String message, T data) { // this.code = code; // this.message = message; // this.data = data; // } // // public Integer getCode() { // return code; // } // // public void setCode(Integer code) { // this.code = code; // } // // public String getMessage() { // return message; // } // // public void setMessage(String message) { // this.message = message; // } // // public T getData() { // return data; // } // // public void setData(T data) { // this.data = data; // } // } // // Path: src/main/java/cn/niriqiang/blog/enums/ResultEnum.java // @ApiModel // public enum ResultEnum { // OK(200, "成功"), // NOT_BLANK(0, "不能为空"), // UNKNOW_ERROR(-1, "未知错误"), // NOT_FOUND(-2, "目标未找到"), // ADD_EXITS(-3, "目标已存在"), // DELETE_FALSE(-4, "不能删除相关文章还存在的分类"), // CURRENT_PAGE_NOT_NULL(-5, "页码不能为空"), // ERROR_NAME_PW(-6, "用户名密码错误"), // NOT_LOGIN(-7, "还没登陆!"); // // ResultEnum(Integer code, String message) { // this.code = code; // this.message = message; // } // // public Integer getCode() { // return code; // } // // public String getMessage() { // return message; // } // // @Override // public String toString() { // return "ResultEnum{" + // "code=" + code + // ", message='" + message + '\'' + // '}'; // } // // Integer code; // String message; // } // // Path: src/main/java/cn/niriqiang/blog/exception/ArticleException.java // public class ArticleException extends Exception { // // public ArticleException(ResultEnum resultEnum) { // super(resultEnum); // } // // public ArticleException(String message, Integer code) { // super(message, code); // } // // } // // Path: src/main/java/cn/niriqiang/blog/exception/CategoryException.java // public class CategoryException extends Exception { // public CategoryException(ResultEnum resultEnum) { // super(resultEnum); // } // // public CategoryException(String message, Integer code) { // super(message, code); // } // // } // // Path: src/main/java/cn/niriqiang/blog/util/ResultUtil.java // public class ResultUtil { // public static <T> Result<T> success(ResultEnum resultEnum, T t) { // return new Result(resultEnum.getCode(), resultEnum.getMessage(), t); // } // // public static Result error(Integer code, String message) { // return new Result(code, message); // } // // public static Result error(ResultEnum resultEnum) { // return new Result(resultEnum.getCode(), resultEnum.getMessage()); // } // } // Path: src/main/java/cn/niriqiang/blog/service/CategoryService.java import cn.niriqiang.blog.domain.Category; import cn.niriqiang.blog.domain.CategoryMapper; import cn.niriqiang.blog.dto.Result; import cn.niriqiang.blog.enums.ResultEnum; import cn.niriqiang.blog.exception.ArticleException; import cn.niriqiang.blog.exception.CategoryException; import cn.niriqiang.blog.util.ResultUtil; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import java.util.List; package cn.niriqiang.blog.service; /** * Created by fengyuwusong on 2017/9/27 0:43. */ @Service public class CategoryService { @Autowired private CategoryMapper mapper; @Autowired private ArticleService articleService;
public Result insertCategory(Category category) {
fengyuwusong/blog
src/main/java/cn/niriqiang/blog/service/CategoryService.java
// Path: src/main/java/cn/niriqiang/blog/domain/Category.java // @ApiModel // @Data // public class Category { // @ApiModelProperty(value = "ID") // private Integer id; // @ApiModelProperty(value = "分类名") // @NotNull(message = "类型名称不能为空") // private String categoryName; // @ApiModelProperty(value = "分类描述") // @NotNull(message = "描述不能为空") // private String description; // } // // Path: src/main/java/cn/niriqiang/blog/domain/CategoryMapper.java // @Mapper // @Repository // public interface CategoryMapper { // Category findByCategoryName(String categoryName); // // Category findOne(int id); // // int update(Category category); // // int insert(Category category); // // int delete(int id); // // List<Category> findAll(); // } // // Path: src/main/java/cn/niriqiang/blog/dto/Result.java // public class Result<T> { // // // private Integer code; // // private String message; // // private T data; // // @Override // public String toString() { // return "Result{" + // "code=" + code + // ", message='" + message + '\'' + // ", data=" + data + // '}'; // } // // public Result(Integer code, String message) { // this.code = code; // this.message = message; // } // // public Result(Integer code, String message, T data) { // this.code = code; // this.message = message; // this.data = data; // } // // public Integer getCode() { // return code; // } // // public void setCode(Integer code) { // this.code = code; // } // // public String getMessage() { // return message; // } // // public void setMessage(String message) { // this.message = message; // } // // public T getData() { // return data; // } // // public void setData(T data) { // this.data = data; // } // } // // Path: src/main/java/cn/niriqiang/blog/enums/ResultEnum.java // @ApiModel // public enum ResultEnum { // OK(200, "成功"), // NOT_BLANK(0, "不能为空"), // UNKNOW_ERROR(-1, "未知错误"), // NOT_FOUND(-2, "目标未找到"), // ADD_EXITS(-3, "目标已存在"), // DELETE_FALSE(-4, "不能删除相关文章还存在的分类"), // CURRENT_PAGE_NOT_NULL(-5, "页码不能为空"), // ERROR_NAME_PW(-6, "用户名密码错误"), // NOT_LOGIN(-7, "还没登陆!"); // // ResultEnum(Integer code, String message) { // this.code = code; // this.message = message; // } // // public Integer getCode() { // return code; // } // // public String getMessage() { // return message; // } // // @Override // public String toString() { // return "ResultEnum{" + // "code=" + code + // ", message='" + message + '\'' + // '}'; // } // // Integer code; // String message; // } // // Path: src/main/java/cn/niriqiang/blog/exception/ArticleException.java // public class ArticleException extends Exception { // // public ArticleException(ResultEnum resultEnum) { // super(resultEnum); // } // // public ArticleException(String message, Integer code) { // super(message, code); // } // // } // // Path: src/main/java/cn/niriqiang/blog/exception/CategoryException.java // public class CategoryException extends Exception { // public CategoryException(ResultEnum resultEnum) { // super(resultEnum); // } // // public CategoryException(String message, Integer code) { // super(message, code); // } // // } // // Path: src/main/java/cn/niriqiang/blog/util/ResultUtil.java // public class ResultUtil { // public static <T> Result<T> success(ResultEnum resultEnum, T t) { // return new Result(resultEnum.getCode(), resultEnum.getMessage(), t); // } // // public static Result error(Integer code, String message) { // return new Result(code, message); // } // // public static Result error(ResultEnum resultEnum) { // return new Result(resultEnum.getCode(), resultEnum.getMessage()); // } // }
import cn.niriqiang.blog.domain.Category; import cn.niriqiang.blog.domain.CategoryMapper; import cn.niriqiang.blog.dto.Result; import cn.niriqiang.blog.enums.ResultEnum; import cn.niriqiang.blog.exception.ArticleException; import cn.niriqiang.blog.exception.CategoryException; import cn.niriqiang.blog.util.ResultUtil; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import java.util.List;
package cn.niriqiang.blog.service; /** * Created by fengyuwusong on 2017/9/27 0:43. */ @Service public class CategoryService { @Autowired private CategoryMapper mapper; @Autowired private ArticleService articleService; public Result insertCategory(Category category) { try { findByCategoryName(category.getCategoryName());
// Path: src/main/java/cn/niriqiang/blog/domain/Category.java // @ApiModel // @Data // public class Category { // @ApiModelProperty(value = "ID") // private Integer id; // @ApiModelProperty(value = "分类名") // @NotNull(message = "类型名称不能为空") // private String categoryName; // @ApiModelProperty(value = "分类描述") // @NotNull(message = "描述不能为空") // private String description; // } // // Path: src/main/java/cn/niriqiang/blog/domain/CategoryMapper.java // @Mapper // @Repository // public interface CategoryMapper { // Category findByCategoryName(String categoryName); // // Category findOne(int id); // // int update(Category category); // // int insert(Category category); // // int delete(int id); // // List<Category> findAll(); // } // // Path: src/main/java/cn/niriqiang/blog/dto/Result.java // public class Result<T> { // // // private Integer code; // // private String message; // // private T data; // // @Override // public String toString() { // return "Result{" + // "code=" + code + // ", message='" + message + '\'' + // ", data=" + data + // '}'; // } // // public Result(Integer code, String message) { // this.code = code; // this.message = message; // } // // public Result(Integer code, String message, T data) { // this.code = code; // this.message = message; // this.data = data; // } // // public Integer getCode() { // return code; // } // // public void setCode(Integer code) { // this.code = code; // } // // public String getMessage() { // return message; // } // // public void setMessage(String message) { // this.message = message; // } // // public T getData() { // return data; // } // // public void setData(T data) { // this.data = data; // } // } // // Path: src/main/java/cn/niriqiang/blog/enums/ResultEnum.java // @ApiModel // public enum ResultEnum { // OK(200, "成功"), // NOT_BLANK(0, "不能为空"), // UNKNOW_ERROR(-1, "未知错误"), // NOT_FOUND(-2, "目标未找到"), // ADD_EXITS(-3, "目标已存在"), // DELETE_FALSE(-4, "不能删除相关文章还存在的分类"), // CURRENT_PAGE_NOT_NULL(-5, "页码不能为空"), // ERROR_NAME_PW(-6, "用户名密码错误"), // NOT_LOGIN(-7, "还没登陆!"); // // ResultEnum(Integer code, String message) { // this.code = code; // this.message = message; // } // // public Integer getCode() { // return code; // } // // public String getMessage() { // return message; // } // // @Override // public String toString() { // return "ResultEnum{" + // "code=" + code + // ", message='" + message + '\'' + // '}'; // } // // Integer code; // String message; // } // // Path: src/main/java/cn/niriqiang/blog/exception/ArticleException.java // public class ArticleException extends Exception { // // public ArticleException(ResultEnum resultEnum) { // super(resultEnum); // } // // public ArticleException(String message, Integer code) { // super(message, code); // } // // } // // Path: src/main/java/cn/niriqiang/blog/exception/CategoryException.java // public class CategoryException extends Exception { // public CategoryException(ResultEnum resultEnum) { // super(resultEnum); // } // // public CategoryException(String message, Integer code) { // super(message, code); // } // // } // // Path: src/main/java/cn/niriqiang/blog/util/ResultUtil.java // public class ResultUtil { // public static <T> Result<T> success(ResultEnum resultEnum, T t) { // return new Result(resultEnum.getCode(), resultEnum.getMessage(), t); // } // // public static Result error(Integer code, String message) { // return new Result(code, message); // } // // public static Result error(ResultEnum resultEnum) { // return new Result(resultEnum.getCode(), resultEnum.getMessage()); // } // } // Path: src/main/java/cn/niriqiang/blog/service/CategoryService.java import cn.niriqiang.blog.domain.Category; import cn.niriqiang.blog.domain.CategoryMapper; import cn.niriqiang.blog.dto.Result; import cn.niriqiang.blog.enums.ResultEnum; import cn.niriqiang.blog.exception.ArticleException; import cn.niriqiang.blog.exception.CategoryException; import cn.niriqiang.blog.util.ResultUtil; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import java.util.List; package cn.niriqiang.blog.service; /** * Created by fengyuwusong on 2017/9/27 0:43. */ @Service public class CategoryService { @Autowired private CategoryMapper mapper; @Autowired private ArticleService articleService; public Result insertCategory(Category category) { try { findByCategoryName(category.getCategoryName());
} catch (CategoryException e) {
fengyuwusong/blog
src/main/java/cn/niriqiang/blog/service/CategoryService.java
// Path: src/main/java/cn/niriqiang/blog/domain/Category.java // @ApiModel // @Data // public class Category { // @ApiModelProperty(value = "ID") // private Integer id; // @ApiModelProperty(value = "分类名") // @NotNull(message = "类型名称不能为空") // private String categoryName; // @ApiModelProperty(value = "分类描述") // @NotNull(message = "描述不能为空") // private String description; // } // // Path: src/main/java/cn/niriqiang/blog/domain/CategoryMapper.java // @Mapper // @Repository // public interface CategoryMapper { // Category findByCategoryName(String categoryName); // // Category findOne(int id); // // int update(Category category); // // int insert(Category category); // // int delete(int id); // // List<Category> findAll(); // } // // Path: src/main/java/cn/niriqiang/blog/dto/Result.java // public class Result<T> { // // // private Integer code; // // private String message; // // private T data; // // @Override // public String toString() { // return "Result{" + // "code=" + code + // ", message='" + message + '\'' + // ", data=" + data + // '}'; // } // // public Result(Integer code, String message) { // this.code = code; // this.message = message; // } // // public Result(Integer code, String message, T data) { // this.code = code; // this.message = message; // this.data = data; // } // // public Integer getCode() { // return code; // } // // public void setCode(Integer code) { // this.code = code; // } // // public String getMessage() { // return message; // } // // public void setMessage(String message) { // this.message = message; // } // // public T getData() { // return data; // } // // public void setData(T data) { // this.data = data; // } // } // // Path: src/main/java/cn/niriqiang/blog/enums/ResultEnum.java // @ApiModel // public enum ResultEnum { // OK(200, "成功"), // NOT_BLANK(0, "不能为空"), // UNKNOW_ERROR(-1, "未知错误"), // NOT_FOUND(-2, "目标未找到"), // ADD_EXITS(-3, "目标已存在"), // DELETE_FALSE(-4, "不能删除相关文章还存在的分类"), // CURRENT_PAGE_NOT_NULL(-5, "页码不能为空"), // ERROR_NAME_PW(-6, "用户名密码错误"), // NOT_LOGIN(-7, "还没登陆!"); // // ResultEnum(Integer code, String message) { // this.code = code; // this.message = message; // } // // public Integer getCode() { // return code; // } // // public String getMessage() { // return message; // } // // @Override // public String toString() { // return "ResultEnum{" + // "code=" + code + // ", message='" + message + '\'' + // '}'; // } // // Integer code; // String message; // } // // Path: src/main/java/cn/niriqiang/blog/exception/ArticleException.java // public class ArticleException extends Exception { // // public ArticleException(ResultEnum resultEnum) { // super(resultEnum); // } // // public ArticleException(String message, Integer code) { // super(message, code); // } // // } // // Path: src/main/java/cn/niriqiang/blog/exception/CategoryException.java // public class CategoryException extends Exception { // public CategoryException(ResultEnum resultEnum) { // super(resultEnum); // } // // public CategoryException(String message, Integer code) { // super(message, code); // } // // } // // Path: src/main/java/cn/niriqiang/blog/util/ResultUtil.java // public class ResultUtil { // public static <T> Result<T> success(ResultEnum resultEnum, T t) { // return new Result(resultEnum.getCode(), resultEnum.getMessage(), t); // } // // public static Result error(Integer code, String message) { // return new Result(code, message); // } // // public static Result error(ResultEnum resultEnum) { // return new Result(resultEnum.getCode(), resultEnum.getMessage()); // } // }
import cn.niriqiang.blog.domain.Category; import cn.niriqiang.blog.domain.CategoryMapper; import cn.niriqiang.blog.dto.Result; import cn.niriqiang.blog.enums.ResultEnum; import cn.niriqiang.blog.exception.ArticleException; import cn.niriqiang.blog.exception.CategoryException; import cn.niriqiang.blog.util.ResultUtil; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import java.util.List;
package cn.niriqiang.blog.service; /** * Created by fengyuwusong on 2017/9/27 0:43. */ @Service public class CategoryService { @Autowired private CategoryMapper mapper; @Autowired private ArticleService articleService; public Result insertCategory(Category category) { try { findByCategoryName(category.getCategoryName()); } catch (CategoryException e) { mapper.insert(category);
// Path: src/main/java/cn/niriqiang/blog/domain/Category.java // @ApiModel // @Data // public class Category { // @ApiModelProperty(value = "ID") // private Integer id; // @ApiModelProperty(value = "分类名") // @NotNull(message = "类型名称不能为空") // private String categoryName; // @ApiModelProperty(value = "分类描述") // @NotNull(message = "描述不能为空") // private String description; // } // // Path: src/main/java/cn/niriqiang/blog/domain/CategoryMapper.java // @Mapper // @Repository // public interface CategoryMapper { // Category findByCategoryName(String categoryName); // // Category findOne(int id); // // int update(Category category); // // int insert(Category category); // // int delete(int id); // // List<Category> findAll(); // } // // Path: src/main/java/cn/niriqiang/blog/dto/Result.java // public class Result<T> { // // // private Integer code; // // private String message; // // private T data; // // @Override // public String toString() { // return "Result{" + // "code=" + code + // ", message='" + message + '\'' + // ", data=" + data + // '}'; // } // // public Result(Integer code, String message) { // this.code = code; // this.message = message; // } // // public Result(Integer code, String message, T data) { // this.code = code; // this.message = message; // this.data = data; // } // // public Integer getCode() { // return code; // } // // public void setCode(Integer code) { // this.code = code; // } // // public String getMessage() { // return message; // } // // public void setMessage(String message) { // this.message = message; // } // // public T getData() { // return data; // } // // public void setData(T data) { // this.data = data; // } // } // // Path: src/main/java/cn/niriqiang/blog/enums/ResultEnum.java // @ApiModel // public enum ResultEnum { // OK(200, "成功"), // NOT_BLANK(0, "不能为空"), // UNKNOW_ERROR(-1, "未知错误"), // NOT_FOUND(-2, "目标未找到"), // ADD_EXITS(-3, "目标已存在"), // DELETE_FALSE(-4, "不能删除相关文章还存在的分类"), // CURRENT_PAGE_NOT_NULL(-5, "页码不能为空"), // ERROR_NAME_PW(-6, "用户名密码错误"), // NOT_LOGIN(-7, "还没登陆!"); // // ResultEnum(Integer code, String message) { // this.code = code; // this.message = message; // } // // public Integer getCode() { // return code; // } // // public String getMessage() { // return message; // } // // @Override // public String toString() { // return "ResultEnum{" + // "code=" + code + // ", message='" + message + '\'' + // '}'; // } // // Integer code; // String message; // } // // Path: src/main/java/cn/niriqiang/blog/exception/ArticleException.java // public class ArticleException extends Exception { // // public ArticleException(ResultEnum resultEnum) { // super(resultEnum); // } // // public ArticleException(String message, Integer code) { // super(message, code); // } // // } // // Path: src/main/java/cn/niriqiang/blog/exception/CategoryException.java // public class CategoryException extends Exception { // public CategoryException(ResultEnum resultEnum) { // super(resultEnum); // } // // public CategoryException(String message, Integer code) { // super(message, code); // } // // } // // Path: src/main/java/cn/niriqiang/blog/util/ResultUtil.java // public class ResultUtil { // public static <T> Result<T> success(ResultEnum resultEnum, T t) { // return new Result(resultEnum.getCode(), resultEnum.getMessage(), t); // } // // public static Result error(Integer code, String message) { // return new Result(code, message); // } // // public static Result error(ResultEnum resultEnum) { // return new Result(resultEnum.getCode(), resultEnum.getMessage()); // } // } // Path: src/main/java/cn/niriqiang/blog/service/CategoryService.java import cn.niriqiang.blog.domain.Category; import cn.niriqiang.blog.domain.CategoryMapper; import cn.niriqiang.blog.dto.Result; import cn.niriqiang.blog.enums.ResultEnum; import cn.niriqiang.blog.exception.ArticleException; import cn.niriqiang.blog.exception.CategoryException; import cn.niriqiang.blog.util.ResultUtil; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import java.util.List; package cn.niriqiang.blog.service; /** * Created by fengyuwusong on 2017/9/27 0:43. */ @Service public class CategoryService { @Autowired private CategoryMapper mapper; @Autowired private ArticleService articleService; public Result insertCategory(Category category) { try { findByCategoryName(category.getCategoryName()); } catch (CategoryException e) { mapper.insert(category);
return ResultUtil.success(ResultEnum.OK, category);
fengyuwusong/blog
src/main/java/cn/niriqiang/blog/service/CategoryService.java
// Path: src/main/java/cn/niriqiang/blog/domain/Category.java // @ApiModel // @Data // public class Category { // @ApiModelProperty(value = "ID") // private Integer id; // @ApiModelProperty(value = "分类名") // @NotNull(message = "类型名称不能为空") // private String categoryName; // @ApiModelProperty(value = "分类描述") // @NotNull(message = "描述不能为空") // private String description; // } // // Path: src/main/java/cn/niriqiang/blog/domain/CategoryMapper.java // @Mapper // @Repository // public interface CategoryMapper { // Category findByCategoryName(String categoryName); // // Category findOne(int id); // // int update(Category category); // // int insert(Category category); // // int delete(int id); // // List<Category> findAll(); // } // // Path: src/main/java/cn/niriqiang/blog/dto/Result.java // public class Result<T> { // // // private Integer code; // // private String message; // // private T data; // // @Override // public String toString() { // return "Result{" + // "code=" + code + // ", message='" + message + '\'' + // ", data=" + data + // '}'; // } // // public Result(Integer code, String message) { // this.code = code; // this.message = message; // } // // public Result(Integer code, String message, T data) { // this.code = code; // this.message = message; // this.data = data; // } // // public Integer getCode() { // return code; // } // // public void setCode(Integer code) { // this.code = code; // } // // public String getMessage() { // return message; // } // // public void setMessage(String message) { // this.message = message; // } // // public T getData() { // return data; // } // // public void setData(T data) { // this.data = data; // } // } // // Path: src/main/java/cn/niriqiang/blog/enums/ResultEnum.java // @ApiModel // public enum ResultEnum { // OK(200, "成功"), // NOT_BLANK(0, "不能为空"), // UNKNOW_ERROR(-1, "未知错误"), // NOT_FOUND(-2, "目标未找到"), // ADD_EXITS(-3, "目标已存在"), // DELETE_FALSE(-4, "不能删除相关文章还存在的分类"), // CURRENT_PAGE_NOT_NULL(-5, "页码不能为空"), // ERROR_NAME_PW(-6, "用户名密码错误"), // NOT_LOGIN(-7, "还没登陆!"); // // ResultEnum(Integer code, String message) { // this.code = code; // this.message = message; // } // // public Integer getCode() { // return code; // } // // public String getMessage() { // return message; // } // // @Override // public String toString() { // return "ResultEnum{" + // "code=" + code + // ", message='" + message + '\'' + // '}'; // } // // Integer code; // String message; // } // // Path: src/main/java/cn/niriqiang/blog/exception/ArticleException.java // public class ArticleException extends Exception { // // public ArticleException(ResultEnum resultEnum) { // super(resultEnum); // } // // public ArticleException(String message, Integer code) { // super(message, code); // } // // } // // Path: src/main/java/cn/niriqiang/blog/exception/CategoryException.java // public class CategoryException extends Exception { // public CategoryException(ResultEnum resultEnum) { // super(resultEnum); // } // // public CategoryException(String message, Integer code) { // super(message, code); // } // // } // // Path: src/main/java/cn/niriqiang/blog/util/ResultUtil.java // public class ResultUtil { // public static <T> Result<T> success(ResultEnum resultEnum, T t) { // return new Result(resultEnum.getCode(), resultEnum.getMessage(), t); // } // // public static Result error(Integer code, String message) { // return new Result(code, message); // } // // public static Result error(ResultEnum resultEnum) { // return new Result(resultEnum.getCode(), resultEnum.getMessage()); // } // }
import cn.niriqiang.blog.domain.Category; import cn.niriqiang.blog.domain.CategoryMapper; import cn.niriqiang.blog.dto.Result; import cn.niriqiang.blog.enums.ResultEnum; import cn.niriqiang.blog.exception.ArticleException; import cn.niriqiang.blog.exception.CategoryException; import cn.niriqiang.blog.util.ResultUtil; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import java.util.List;
package cn.niriqiang.blog.service; /** * Created by fengyuwusong on 2017/9/27 0:43. */ @Service public class CategoryService { @Autowired private CategoryMapper mapper; @Autowired private ArticleService articleService; public Result insertCategory(Category category) { try { findByCategoryName(category.getCategoryName()); } catch (CategoryException e) { mapper.insert(category);
// Path: src/main/java/cn/niriqiang/blog/domain/Category.java // @ApiModel // @Data // public class Category { // @ApiModelProperty(value = "ID") // private Integer id; // @ApiModelProperty(value = "分类名") // @NotNull(message = "类型名称不能为空") // private String categoryName; // @ApiModelProperty(value = "分类描述") // @NotNull(message = "描述不能为空") // private String description; // } // // Path: src/main/java/cn/niriqiang/blog/domain/CategoryMapper.java // @Mapper // @Repository // public interface CategoryMapper { // Category findByCategoryName(String categoryName); // // Category findOne(int id); // // int update(Category category); // // int insert(Category category); // // int delete(int id); // // List<Category> findAll(); // } // // Path: src/main/java/cn/niriqiang/blog/dto/Result.java // public class Result<T> { // // // private Integer code; // // private String message; // // private T data; // // @Override // public String toString() { // return "Result{" + // "code=" + code + // ", message='" + message + '\'' + // ", data=" + data + // '}'; // } // // public Result(Integer code, String message) { // this.code = code; // this.message = message; // } // // public Result(Integer code, String message, T data) { // this.code = code; // this.message = message; // this.data = data; // } // // public Integer getCode() { // return code; // } // // public void setCode(Integer code) { // this.code = code; // } // // public String getMessage() { // return message; // } // // public void setMessage(String message) { // this.message = message; // } // // public T getData() { // return data; // } // // public void setData(T data) { // this.data = data; // } // } // // Path: src/main/java/cn/niriqiang/blog/enums/ResultEnum.java // @ApiModel // public enum ResultEnum { // OK(200, "成功"), // NOT_BLANK(0, "不能为空"), // UNKNOW_ERROR(-1, "未知错误"), // NOT_FOUND(-2, "目标未找到"), // ADD_EXITS(-3, "目标已存在"), // DELETE_FALSE(-4, "不能删除相关文章还存在的分类"), // CURRENT_PAGE_NOT_NULL(-5, "页码不能为空"), // ERROR_NAME_PW(-6, "用户名密码错误"), // NOT_LOGIN(-7, "还没登陆!"); // // ResultEnum(Integer code, String message) { // this.code = code; // this.message = message; // } // // public Integer getCode() { // return code; // } // // public String getMessage() { // return message; // } // // @Override // public String toString() { // return "ResultEnum{" + // "code=" + code + // ", message='" + message + '\'' + // '}'; // } // // Integer code; // String message; // } // // Path: src/main/java/cn/niriqiang/blog/exception/ArticleException.java // public class ArticleException extends Exception { // // public ArticleException(ResultEnum resultEnum) { // super(resultEnum); // } // // public ArticleException(String message, Integer code) { // super(message, code); // } // // } // // Path: src/main/java/cn/niriqiang/blog/exception/CategoryException.java // public class CategoryException extends Exception { // public CategoryException(ResultEnum resultEnum) { // super(resultEnum); // } // // public CategoryException(String message, Integer code) { // super(message, code); // } // // } // // Path: src/main/java/cn/niriqiang/blog/util/ResultUtil.java // public class ResultUtil { // public static <T> Result<T> success(ResultEnum resultEnum, T t) { // return new Result(resultEnum.getCode(), resultEnum.getMessage(), t); // } // // public static Result error(Integer code, String message) { // return new Result(code, message); // } // // public static Result error(ResultEnum resultEnum) { // return new Result(resultEnum.getCode(), resultEnum.getMessage()); // } // } // Path: src/main/java/cn/niriqiang/blog/service/CategoryService.java import cn.niriqiang.blog.domain.Category; import cn.niriqiang.blog.domain.CategoryMapper; import cn.niriqiang.blog.dto.Result; import cn.niriqiang.blog.enums.ResultEnum; import cn.niriqiang.blog.exception.ArticleException; import cn.niriqiang.blog.exception.CategoryException; import cn.niriqiang.blog.util.ResultUtil; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import java.util.List; package cn.niriqiang.blog.service; /** * Created by fengyuwusong on 2017/9/27 0:43. */ @Service public class CategoryService { @Autowired private CategoryMapper mapper; @Autowired private ArticleService articleService; public Result insertCategory(Category category) { try { findByCategoryName(category.getCategoryName()); } catch (CategoryException e) { mapper.insert(category);
return ResultUtil.success(ResultEnum.OK, category);
fengyuwusong/blog
src/main/java/cn/niriqiang/blog/controller/TagController.java
// Path: src/main/java/cn/niriqiang/blog/domain/Tag.java // @ApiModel // @Data // public class Tag { // @ApiModelProperty(value = "ID") // private Integer id; // @ApiModelProperty(value = "标签名") // @NotNull(message = "标签名字不能为空!") // private String tagName; // } // // Path: src/main/java/cn/niriqiang/blog/dto/Result.java // public class Result<T> { // // // private Integer code; // // private String message; // // private T data; // // @Override // public String toString() { // return "Result{" + // "code=" + code + // ", message='" + message + '\'' + // ", data=" + data + // '}'; // } // // public Result(Integer code, String message) { // this.code = code; // this.message = message; // } // // public Result(Integer code, String message, T data) { // this.code = code; // this.message = message; // this.data = data; // } // // public Integer getCode() { // return code; // } // // public void setCode(Integer code) { // this.code = code; // } // // public String getMessage() { // return message; // } // // public void setMessage(String message) { // this.message = message; // } // // public T getData() { // return data; // } // // public void setData(T data) { // this.data = data; // } // } // // Path: src/main/java/cn/niriqiang/blog/exception/TagException.java // public class TagException extends Exception { // // public TagException(ResultEnum resultEnum) { // super(resultEnum); // } // // public TagException(String message, Integer code) { // super(message, code); // } // } // // Path: src/main/java/cn/niriqiang/blog/service/TagService.java // @Service // public class TagService { // @Autowired // private TagMapper mapper; // @Autowired // private ArticleTagsMapper articleTagsMapper; // // public Result insertTag(Tag tag) { // if (tag.getId() != null) { // throw new TagException(ResultEnum.ADD_EXITS); // } // try { // findByTagName(tag.getTagName()); // } catch (TagException e) { // mapper.insert(tag); // return ResultUtil.success(ResultEnum.OK, tag); // } // throw new TagException(ResultEnum.ADD_EXITS); // } // // public Result updateTag(Tag tag) { // // 查找id是否存在 // findOne(tag.getId()); // // 查找更改的tagName是否已经存在 // try { // findByTagName(tag.getTagName()); // } catch (TagException e) { // mapper.update(tag); // return ResultUtil.success(ResultEnum.OK, tag); // } // throw new TagException(ResultEnum.ADD_EXITS); // } // // public Result findOne(int id) { // Tag tag = mapper.findOne(id); // if (tag != null) { // return ResultUtil.success(ResultEnum.OK, tag); // } else { // throw new TagException(ResultEnum.NOT_FOUND); // } // } // // public Result findByTagName(String tagName) { // Tag tag = mapper.findByTagName(tagName); // if (tag != null) { // return ResultUtil.success(ResultEnum.OK, tag); // } else { // throw new TagException(ResultEnum.NOT_FOUND); // } // } // // public Result findAll() { // List<Tag> tagPage = mapper.findAll(); // return ResultUtil.success(ResultEnum.OK, tagPage); // } // // public Result delete(int id) { // findOne(id); // ArticleTags articleTags = new ArticleTags(); // articleTags.setTagId(id); // // 先删除article_tags表中数据 // articleTagsMapper.delete(articleTags); // mapper.delete(id); // return ResultUtil.success(ResultEnum.OK, id); // } // // // }
import cn.niriqiang.blog.annotation.Admin; import cn.niriqiang.blog.domain.Tag; import cn.niriqiang.blog.dto.Result; import cn.niriqiang.blog.exception.TagException; import cn.niriqiang.blog.service.TagService; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.validation.Errors; import org.springframework.web.bind.annotation.*; import javax.validation.Valid;
package cn.niriqiang.blog.controller; /** * Created by fengyuwusong on 2017/10/1 23:24. */ @Api(value = "标签管理接口") @RestController @RequestMapping("/tag") public class TagController { @Autowired
// Path: src/main/java/cn/niriqiang/blog/domain/Tag.java // @ApiModel // @Data // public class Tag { // @ApiModelProperty(value = "ID") // private Integer id; // @ApiModelProperty(value = "标签名") // @NotNull(message = "标签名字不能为空!") // private String tagName; // } // // Path: src/main/java/cn/niriqiang/blog/dto/Result.java // public class Result<T> { // // // private Integer code; // // private String message; // // private T data; // // @Override // public String toString() { // return "Result{" + // "code=" + code + // ", message='" + message + '\'' + // ", data=" + data + // '}'; // } // // public Result(Integer code, String message) { // this.code = code; // this.message = message; // } // // public Result(Integer code, String message, T data) { // this.code = code; // this.message = message; // this.data = data; // } // // public Integer getCode() { // return code; // } // // public void setCode(Integer code) { // this.code = code; // } // // public String getMessage() { // return message; // } // // public void setMessage(String message) { // this.message = message; // } // // public T getData() { // return data; // } // // public void setData(T data) { // this.data = data; // } // } // // Path: src/main/java/cn/niriqiang/blog/exception/TagException.java // public class TagException extends Exception { // // public TagException(ResultEnum resultEnum) { // super(resultEnum); // } // // public TagException(String message, Integer code) { // super(message, code); // } // } // // Path: src/main/java/cn/niriqiang/blog/service/TagService.java // @Service // public class TagService { // @Autowired // private TagMapper mapper; // @Autowired // private ArticleTagsMapper articleTagsMapper; // // public Result insertTag(Tag tag) { // if (tag.getId() != null) { // throw new TagException(ResultEnum.ADD_EXITS); // } // try { // findByTagName(tag.getTagName()); // } catch (TagException e) { // mapper.insert(tag); // return ResultUtil.success(ResultEnum.OK, tag); // } // throw new TagException(ResultEnum.ADD_EXITS); // } // // public Result updateTag(Tag tag) { // // 查找id是否存在 // findOne(tag.getId()); // // 查找更改的tagName是否已经存在 // try { // findByTagName(tag.getTagName()); // } catch (TagException e) { // mapper.update(tag); // return ResultUtil.success(ResultEnum.OK, tag); // } // throw new TagException(ResultEnum.ADD_EXITS); // } // // public Result findOne(int id) { // Tag tag = mapper.findOne(id); // if (tag != null) { // return ResultUtil.success(ResultEnum.OK, tag); // } else { // throw new TagException(ResultEnum.NOT_FOUND); // } // } // // public Result findByTagName(String tagName) { // Tag tag = mapper.findByTagName(tagName); // if (tag != null) { // return ResultUtil.success(ResultEnum.OK, tag); // } else { // throw new TagException(ResultEnum.NOT_FOUND); // } // } // // public Result findAll() { // List<Tag> tagPage = mapper.findAll(); // return ResultUtil.success(ResultEnum.OK, tagPage); // } // // public Result delete(int id) { // findOne(id); // ArticleTags articleTags = new ArticleTags(); // articleTags.setTagId(id); // // 先删除article_tags表中数据 // articleTagsMapper.delete(articleTags); // mapper.delete(id); // return ResultUtil.success(ResultEnum.OK, id); // } // // // } // Path: src/main/java/cn/niriqiang/blog/controller/TagController.java import cn.niriqiang.blog.annotation.Admin; import cn.niriqiang.blog.domain.Tag; import cn.niriqiang.blog.dto.Result; import cn.niriqiang.blog.exception.TagException; import cn.niriqiang.blog.service.TagService; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.validation.Errors; import org.springframework.web.bind.annotation.*; import javax.validation.Valid; package cn.niriqiang.blog.controller; /** * Created by fengyuwusong on 2017/10/1 23:24. */ @Api(value = "标签管理接口") @RestController @RequestMapping("/tag") public class TagController { @Autowired
private TagService tagService;
fengyuwusong/blog
src/main/java/cn/niriqiang/blog/controller/TagController.java
// Path: src/main/java/cn/niriqiang/blog/domain/Tag.java // @ApiModel // @Data // public class Tag { // @ApiModelProperty(value = "ID") // private Integer id; // @ApiModelProperty(value = "标签名") // @NotNull(message = "标签名字不能为空!") // private String tagName; // } // // Path: src/main/java/cn/niriqiang/blog/dto/Result.java // public class Result<T> { // // // private Integer code; // // private String message; // // private T data; // // @Override // public String toString() { // return "Result{" + // "code=" + code + // ", message='" + message + '\'' + // ", data=" + data + // '}'; // } // // public Result(Integer code, String message) { // this.code = code; // this.message = message; // } // // public Result(Integer code, String message, T data) { // this.code = code; // this.message = message; // this.data = data; // } // // public Integer getCode() { // return code; // } // // public void setCode(Integer code) { // this.code = code; // } // // public String getMessage() { // return message; // } // // public void setMessage(String message) { // this.message = message; // } // // public T getData() { // return data; // } // // public void setData(T data) { // this.data = data; // } // } // // Path: src/main/java/cn/niriqiang/blog/exception/TagException.java // public class TagException extends Exception { // // public TagException(ResultEnum resultEnum) { // super(resultEnum); // } // // public TagException(String message, Integer code) { // super(message, code); // } // } // // Path: src/main/java/cn/niriqiang/blog/service/TagService.java // @Service // public class TagService { // @Autowired // private TagMapper mapper; // @Autowired // private ArticleTagsMapper articleTagsMapper; // // public Result insertTag(Tag tag) { // if (tag.getId() != null) { // throw new TagException(ResultEnum.ADD_EXITS); // } // try { // findByTagName(tag.getTagName()); // } catch (TagException e) { // mapper.insert(tag); // return ResultUtil.success(ResultEnum.OK, tag); // } // throw new TagException(ResultEnum.ADD_EXITS); // } // // public Result updateTag(Tag tag) { // // 查找id是否存在 // findOne(tag.getId()); // // 查找更改的tagName是否已经存在 // try { // findByTagName(tag.getTagName()); // } catch (TagException e) { // mapper.update(tag); // return ResultUtil.success(ResultEnum.OK, tag); // } // throw new TagException(ResultEnum.ADD_EXITS); // } // // public Result findOne(int id) { // Tag tag = mapper.findOne(id); // if (tag != null) { // return ResultUtil.success(ResultEnum.OK, tag); // } else { // throw new TagException(ResultEnum.NOT_FOUND); // } // } // // public Result findByTagName(String tagName) { // Tag tag = mapper.findByTagName(tagName); // if (tag != null) { // return ResultUtil.success(ResultEnum.OK, tag); // } else { // throw new TagException(ResultEnum.NOT_FOUND); // } // } // // public Result findAll() { // List<Tag> tagPage = mapper.findAll(); // return ResultUtil.success(ResultEnum.OK, tagPage); // } // // public Result delete(int id) { // findOne(id); // ArticleTags articleTags = new ArticleTags(); // articleTags.setTagId(id); // // 先删除article_tags表中数据 // articleTagsMapper.delete(articleTags); // mapper.delete(id); // return ResultUtil.success(ResultEnum.OK, id); // } // // // }
import cn.niriqiang.blog.annotation.Admin; import cn.niriqiang.blog.domain.Tag; import cn.niriqiang.blog.dto.Result; import cn.niriqiang.blog.exception.TagException; import cn.niriqiang.blog.service.TagService; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.validation.Errors; import org.springframework.web.bind.annotation.*; import javax.validation.Valid;
package cn.niriqiang.blog.controller; /** * Created by fengyuwusong on 2017/10/1 23:24. */ @Api(value = "标签管理接口") @RestController @RequestMapping("/tag") public class TagController { @Autowired private TagService tagService; @Admin @ApiOperation(value = "添加新的tag") @PostMapping
// Path: src/main/java/cn/niriqiang/blog/domain/Tag.java // @ApiModel // @Data // public class Tag { // @ApiModelProperty(value = "ID") // private Integer id; // @ApiModelProperty(value = "标签名") // @NotNull(message = "标签名字不能为空!") // private String tagName; // } // // Path: src/main/java/cn/niriqiang/blog/dto/Result.java // public class Result<T> { // // // private Integer code; // // private String message; // // private T data; // // @Override // public String toString() { // return "Result{" + // "code=" + code + // ", message='" + message + '\'' + // ", data=" + data + // '}'; // } // // public Result(Integer code, String message) { // this.code = code; // this.message = message; // } // // public Result(Integer code, String message, T data) { // this.code = code; // this.message = message; // this.data = data; // } // // public Integer getCode() { // return code; // } // // public void setCode(Integer code) { // this.code = code; // } // // public String getMessage() { // return message; // } // // public void setMessage(String message) { // this.message = message; // } // // public T getData() { // return data; // } // // public void setData(T data) { // this.data = data; // } // } // // Path: src/main/java/cn/niriqiang/blog/exception/TagException.java // public class TagException extends Exception { // // public TagException(ResultEnum resultEnum) { // super(resultEnum); // } // // public TagException(String message, Integer code) { // super(message, code); // } // } // // Path: src/main/java/cn/niriqiang/blog/service/TagService.java // @Service // public class TagService { // @Autowired // private TagMapper mapper; // @Autowired // private ArticleTagsMapper articleTagsMapper; // // public Result insertTag(Tag tag) { // if (tag.getId() != null) { // throw new TagException(ResultEnum.ADD_EXITS); // } // try { // findByTagName(tag.getTagName()); // } catch (TagException e) { // mapper.insert(tag); // return ResultUtil.success(ResultEnum.OK, tag); // } // throw new TagException(ResultEnum.ADD_EXITS); // } // // public Result updateTag(Tag tag) { // // 查找id是否存在 // findOne(tag.getId()); // // 查找更改的tagName是否已经存在 // try { // findByTagName(tag.getTagName()); // } catch (TagException e) { // mapper.update(tag); // return ResultUtil.success(ResultEnum.OK, tag); // } // throw new TagException(ResultEnum.ADD_EXITS); // } // // public Result findOne(int id) { // Tag tag = mapper.findOne(id); // if (tag != null) { // return ResultUtil.success(ResultEnum.OK, tag); // } else { // throw new TagException(ResultEnum.NOT_FOUND); // } // } // // public Result findByTagName(String tagName) { // Tag tag = mapper.findByTagName(tagName); // if (tag != null) { // return ResultUtil.success(ResultEnum.OK, tag); // } else { // throw new TagException(ResultEnum.NOT_FOUND); // } // } // // public Result findAll() { // List<Tag> tagPage = mapper.findAll(); // return ResultUtil.success(ResultEnum.OK, tagPage); // } // // public Result delete(int id) { // findOne(id); // ArticleTags articleTags = new ArticleTags(); // articleTags.setTagId(id); // // 先删除article_tags表中数据 // articleTagsMapper.delete(articleTags); // mapper.delete(id); // return ResultUtil.success(ResultEnum.OK, id); // } // // // } // Path: src/main/java/cn/niriqiang/blog/controller/TagController.java import cn.niriqiang.blog.annotation.Admin; import cn.niriqiang.blog.domain.Tag; import cn.niriqiang.blog.dto.Result; import cn.niriqiang.blog.exception.TagException; import cn.niriqiang.blog.service.TagService; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.validation.Errors; import org.springframework.web.bind.annotation.*; import javax.validation.Valid; package cn.niriqiang.blog.controller; /** * Created by fengyuwusong on 2017/10/1 23:24. */ @Api(value = "标签管理接口") @RestController @RequestMapping("/tag") public class TagController { @Autowired private TagService tagService; @Admin @ApiOperation(value = "添加新的tag") @PostMapping
public Result insert(@Valid @RequestBody Tag tag, Errors errors) {
fengyuwusong/blog
src/main/java/cn/niriqiang/blog/controller/TagController.java
// Path: src/main/java/cn/niriqiang/blog/domain/Tag.java // @ApiModel // @Data // public class Tag { // @ApiModelProperty(value = "ID") // private Integer id; // @ApiModelProperty(value = "标签名") // @NotNull(message = "标签名字不能为空!") // private String tagName; // } // // Path: src/main/java/cn/niriqiang/blog/dto/Result.java // public class Result<T> { // // // private Integer code; // // private String message; // // private T data; // // @Override // public String toString() { // return "Result{" + // "code=" + code + // ", message='" + message + '\'' + // ", data=" + data + // '}'; // } // // public Result(Integer code, String message) { // this.code = code; // this.message = message; // } // // public Result(Integer code, String message, T data) { // this.code = code; // this.message = message; // this.data = data; // } // // public Integer getCode() { // return code; // } // // public void setCode(Integer code) { // this.code = code; // } // // public String getMessage() { // return message; // } // // public void setMessage(String message) { // this.message = message; // } // // public T getData() { // return data; // } // // public void setData(T data) { // this.data = data; // } // } // // Path: src/main/java/cn/niriqiang/blog/exception/TagException.java // public class TagException extends Exception { // // public TagException(ResultEnum resultEnum) { // super(resultEnum); // } // // public TagException(String message, Integer code) { // super(message, code); // } // } // // Path: src/main/java/cn/niriqiang/blog/service/TagService.java // @Service // public class TagService { // @Autowired // private TagMapper mapper; // @Autowired // private ArticleTagsMapper articleTagsMapper; // // public Result insertTag(Tag tag) { // if (tag.getId() != null) { // throw new TagException(ResultEnum.ADD_EXITS); // } // try { // findByTagName(tag.getTagName()); // } catch (TagException e) { // mapper.insert(tag); // return ResultUtil.success(ResultEnum.OK, tag); // } // throw new TagException(ResultEnum.ADD_EXITS); // } // // public Result updateTag(Tag tag) { // // 查找id是否存在 // findOne(tag.getId()); // // 查找更改的tagName是否已经存在 // try { // findByTagName(tag.getTagName()); // } catch (TagException e) { // mapper.update(tag); // return ResultUtil.success(ResultEnum.OK, tag); // } // throw new TagException(ResultEnum.ADD_EXITS); // } // // public Result findOne(int id) { // Tag tag = mapper.findOne(id); // if (tag != null) { // return ResultUtil.success(ResultEnum.OK, tag); // } else { // throw new TagException(ResultEnum.NOT_FOUND); // } // } // // public Result findByTagName(String tagName) { // Tag tag = mapper.findByTagName(tagName); // if (tag != null) { // return ResultUtil.success(ResultEnum.OK, tag); // } else { // throw new TagException(ResultEnum.NOT_FOUND); // } // } // // public Result findAll() { // List<Tag> tagPage = mapper.findAll(); // return ResultUtil.success(ResultEnum.OK, tagPage); // } // // public Result delete(int id) { // findOne(id); // ArticleTags articleTags = new ArticleTags(); // articleTags.setTagId(id); // // 先删除article_tags表中数据 // articleTagsMapper.delete(articleTags); // mapper.delete(id); // return ResultUtil.success(ResultEnum.OK, id); // } // // // }
import cn.niriqiang.blog.annotation.Admin; import cn.niriqiang.blog.domain.Tag; import cn.niriqiang.blog.dto.Result; import cn.niriqiang.blog.exception.TagException; import cn.niriqiang.blog.service.TagService; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.validation.Errors; import org.springframework.web.bind.annotation.*; import javax.validation.Valid;
package cn.niriqiang.blog.controller; /** * Created by fengyuwusong on 2017/10/1 23:24. */ @Api(value = "标签管理接口") @RestController @RequestMapping("/tag") public class TagController { @Autowired private TagService tagService; @Admin @ApiOperation(value = "添加新的tag") @PostMapping
// Path: src/main/java/cn/niriqiang/blog/domain/Tag.java // @ApiModel // @Data // public class Tag { // @ApiModelProperty(value = "ID") // private Integer id; // @ApiModelProperty(value = "标签名") // @NotNull(message = "标签名字不能为空!") // private String tagName; // } // // Path: src/main/java/cn/niriqiang/blog/dto/Result.java // public class Result<T> { // // // private Integer code; // // private String message; // // private T data; // // @Override // public String toString() { // return "Result{" + // "code=" + code + // ", message='" + message + '\'' + // ", data=" + data + // '}'; // } // // public Result(Integer code, String message) { // this.code = code; // this.message = message; // } // // public Result(Integer code, String message, T data) { // this.code = code; // this.message = message; // this.data = data; // } // // public Integer getCode() { // return code; // } // // public void setCode(Integer code) { // this.code = code; // } // // public String getMessage() { // return message; // } // // public void setMessage(String message) { // this.message = message; // } // // public T getData() { // return data; // } // // public void setData(T data) { // this.data = data; // } // } // // Path: src/main/java/cn/niriqiang/blog/exception/TagException.java // public class TagException extends Exception { // // public TagException(ResultEnum resultEnum) { // super(resultEnum); // } // // public TagException(String message, Integer code) { // super(message, code); // } // } // // Path: src/main/java/cn/niriqiang/blog/service/TagService.java // @Service // public class TagService { // @Autowired // private TagMapper mapper; // @Autowired // private ArticleTagsMapper articleTagsMapper; // // public Result insertTag(Tag tag) { // if (tag.getId() != null) { // throw new TagException(ResultEnum.ADD_EXITS); // } // try { // findByTagName(tag.getTagName()); // } catch (TagException e) { // mapper.insert(tag); // return ResultUtil.success(ResultEnum.OK, tag); // } // throw new TagException(ResultEnum.ADD_EXITS); // } // // public Result updateTag(Tag tag) { // // 查找id是否存在 // findOne(tag.getId()); // // 查找更改的tagName是否已经存在 // try { // findByTagName(tag.getTagName()); // } catch (TagException e) { // mapper.update(tag); // return ResultUtil.success(ResultEnum.OK, tag); // } // throw new TagException(ResultEnum.ADD_EXITS); // } // // public Result findOne(int id) { // Tag tag = mapper.findOne(id); // if (tag != null) { // return ResultUtil.success(ResultEnum.OK, tag); // } else { // throw new TagException(ResultEnum.NOT_FOUND); // } // } // // public Result findByTagName(String tagName) { // Tag tag = mapper.findByTagName(tagName); // if (tag != null) { // return ResultUtil.success(ResultEnum.OK, tag); // } else { // throw new TagException(ResultEnum.NOT_FOUND); // } // } // // public Result findAll() { // List<Tag> tagPage = mapper.findAll(); // return ResultUtil.success(ResultEnum.OK, tagPage); // } // // public Result delete(int id) { // findOne(id); // ArticleTags articleTags = new ArticleTags(); // articleTags.setTagId(id); // // 先删除article_tags表中数据 // articleTagsMapper.delete(articleTags); // mapper.delete(id); // return ResultUtil.success(ResultEnum.OK, id); // } // // // } // Path: src/main/java/cn/niriqiang/blog/controller/TagController.java import cn.niriqiang.blog.annotation.Admin; import cn.niriqiang.blog.domain.Tag; import cn.niriqiang.blog.dto.Result; import cn.niriqiang.blog.exception.TagException; import cn.niriqiang.blog.service.TagService; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.validation.Errors; import org.springframework.web.bind.annotation.*; import javax.validation.Valid; package cn.niriqiang.blog.controller; /** * Created by fengyuwusong on 2017/10/1 23:24. */ @Api(value = "标签管理接口") @RestController @RequestMapping("/tag") public class TagController { @Autowired private TagService tagService; @Admin @ApiOperation(value = "添加新的tag") @PostMapping
public Result insert(@Valid @RequestBody Tag tag, Errors errors) {
fengyuwusong/blog
src/main/java/cn/niriqiang/blog/controller/TagController.java
// Path: src/main/java/cn/niriqiang/blog/domain/Tag.java // @ApiModel // @Data // public class Tag { // @ApiModelProperty(value = "ID") // private Integer id; // @ApiModelProperty(value = "标签名") // @NotNull(message = "标签名字不能为空!") // private String tagName; // } // // Path: src/main/java/cn/niriqiang/blog/dto/Result.java // public class Result<T> { // // // private Integer code; // // private String message; // // private T data; // // @Override // public String toString() { // return "Result{" + // "code=" + code + // ", message='" + message + '\'' + // ", data=" + data + // '}'; // } // // public Result(Integer code, String message) { // this.code = code; // this.message = message; // } // // public Result(Integer code, String message, T data) { // this.code = code; // this.message = message; // this.data = data; // } // // public Integer getCode() { // return code; // } // // public void setCode(Integer code) { // this.code = code; // } // // public String getMessage() { // return message; // } // // public void setMessage(String message) { // this.message = message; // } // // public T getData() { // return data; // } // // public void setData(T data) { // this.data = data; // } // } // // Path: src/main/java/cn/niriqiang/blog/exception/TagException.java // public class TagException extends Exception { // // public TagException(ResultEnum resultEnum) { // super(resultEnum); // } // // public TagException(String message, Integer code) { // super(message, code); // } // } // // Path: src/main/java/cn/niriqiang/blog/service/TagService.java // @Service // public class TagService { // @Autowired // private TagMapper mapper; // @Autowired // private ArticleTagsMapper articleTagsMapper; // // public Result insertTag(Tag tag) { // if (tag.getId() != null) { // throw new TagException(ResultEnum.ADD_EXITS); // } // try { // findByTagName(tag.getTagName()); // } catch (TagException e) { // mapper.insert(tag); // return ResultUtil.success(ResultEnum.OK, tag); // } // throw new TagException(ResultEnum.ADD_EXITS); // } // // public Result updateTag(Tag tag) { // // 查找id是否存在 // findOne(tag.getId()); // // 查找更改的tagName是否已经存在 // try { // findByTagName(tag.getTagName()); // } catch (TagException e) { // mapper.update(tag); // return ResultUtil.success(ResultEnum.OK, tag); // } // throw new TagException(ResultEnum.ADD_EXITS); // } // // public Result findOne(int id) { // Tag tag = mapper.findOne(id); // if (tag != null) { // return ResultUtil.success(ResultEnum.OK, tag); // } else { // throw new TagException(ResultEnum.NOT_FOUND); // } // } // // public Result findByTagName(String tagName) { // Tag tag = mapper.findByTagName(tagName); // if (tag != null) { // return ResultUtil.success(ResultEnum.OK, tag); // } else { // throw new TagException(ResultEnum.NOT_FOUND); // } // } // // public Result findAll() { // List<Tag> tagPage = mapper.findAll(); // return ResultUtil.success(ResultEnum.OK, tagPage); // } // // public Result delete(int id) { // findOne(id); // ArticleTags articleTags = new ArticleTags(); // articleTags.setTagId(id); // // 先删除article_tags表中数据 // articleTagsMapper.delete(articleTags); // mapper.delete(id); // return ResultUtil.success(ResultEnum.OK, id); // } // // // }
import cn.niriqiang.blog.annotation.Admin; import cn.niriqiang.blog.domain.Tag; import cn.niriqiang.blog.dto.Result; import cn.niriqiang.blog.exception.TagException; import cn.niriqiang.blog.service.TagService; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.validation.Errors; import org.springframework.web.bind.annotation.*; import javax.validation.Valid;
package cn.niriqiang.blog.controller; /** * Created by fengyuwusong on 2017/10/1 23:24. */ @Api(value = "标签管理接口") @RestController @RequestMapping("/tag") public class TagController { @Autowired private TagService tagService; @Admin @ApiOperation(value = "添加新的tag") @PostMapping public Result insert(@Valid @RequestBody Tag tag, Errors errors) { if (errors.hasErrors()) {
// Path: src/main/java/cn/niriqiang/blog/domain/Tag.java // @ApiModel // @Data // public class Tag { // @ApiModelProperty(value = "ID") // private Integer id; // @ApiModelProperty(value = "标签名") // @NotNull(message = "标签名字不能为空!") // private String tagName; // } // // Path: src/main/java/cn/niriqiang/blog/dto/Result.java // public class Result<T> { // // // private Integer code; // // private String message; // // private T data; // // @Override // public String toString() { // return "Result{" + // "code=" + code + // ", message='" + message + '\'' + // ", data=" + data + // '}'; // } // // public Result(Integer code, String message) { // this.code = code; // this.message = message; // } // // public Result(Integer code, String message, T data) { // this.code = code; // this.message = message; // this.data = data; // } // // public Integer getCode() { // return code; // } // // public void setCode(Integer code) { // this.code = code; // } // // public String getMessage() { // return message; // } // // public void setMessage(String message) { // this.message = message; // } // // public T getData() { // return data; // } // // public void setData(T data) { // this.data = data; // } // } // // Path: src/main/java/cn/niriqiang/blog/exception/TagException.java // public class TagException extends Exception { // // public TagException(ResultEnum resultEnum) { // super(resultEnum); // } // // public TagException(String message, Integer code) { // super(message, code); // } // } // // Path: src/main/java/cn/niriqiang/blog/service/TagService.java // @Service // public class TagService { // @Autowired // private TagMapper mapper; // @Autowired // private ArticleTagsMapper articleTagsMapper; // // public Result insertTag(Tag tag) { // if (tag.getId() != null) { // throw new TagException(ResultEnum.ADD_EXITS); // } // try { // findByTagName(tag.getTagName()); // } catch (TagException e) { // mapper.insert(tag); // return ResultUtil.success(ResultEnum.OK, tag); // } // throw new TagException(ResultEnum.ADD_EXITS); // } // // public Result updateTag(Tag tag) { // // 查找id是否存在 // findOne(tag.getId()); // // 查找更改的tagName是否已经存在 // try { // findByTagName(tag.getTagName()); // } catch (TagException e) { // mapper.update(tag); // return ResultUtil.success(ResultEnum.OK, tag); // } // throw new TagException(ResultEnum.ADD_EXITS); // } // // public Result findOne(int id) { // Tag tag = mapper.findOne(id); // if (tag != null) { // return ResultUtil.success(ResultEnum.OK, tag); // } else { // throw new TagException(ResultEnum.NOT_FOUND); // } // } // // public Result findByTagName(String tagName) { // Tag tag = mapper.findByTagName(tagName); // if (tag != null) { // return ResultUtil.success(ResultEnum.OK, tag); // } else { // throw new TagException(ResultEnum.NOT_FOUND); // } // } // // public Result findAll() { // List<Tag> tagPage = mapper.findAll(); // return ResultUtil.success(ResultEnum.OK, tagPage); // } // // public Result delete(int id) { // findOne(id); // ArticleTags articleTags = new ArticleTags(); // articleTags.setTagId(id); // // 先删除article_tags表中数据 // articleTagsMapper.delete(articleTags); // mapper.delete(id); // return ResultUtil.success(ResultEnum.OK, id); // } // // // } // Path: src/main/java/cn/niriqiang/blog/controller/TagController.java import cn.niriqiang.blog.annotation.Admin; import cn.niriqiang.blog.domain.Tag; import cn.niriqiang.blog.dto.Result; import cn.niriqiang.blog.exception.TagException; import cn.niriqiang.blog.service.TagService; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.validation.Errors; import org.springframework.web.bind.annotation.*; import javax.validation.Valid; package cn.niriqiang.blog.controller; /** * Created by fengyuwusong on 2017/10/1 23:24. */ @Api(value = "标签管理接口") @RestController @RequestMapping("/tag") public class TagController { @Autowired private TagService tagService; @Admin @ApiOperation(value = "添加新的tag") @PostMapping public Result insert(@Valid @RequestBody Tag tag, Errors errors) { if (errors.hasErrors()) {
throw new TagException(errors.getFieldError().getDefaultMessage(), -6);
fengyuwusong/blog
src/main/java/cn/niriqiang/blog/service/ArticleService.java
// Path: src/main/java/cn/niriqiang/blog/dto/Result.java // public class Result<T> { // // // private Integer code; // // private String message; // // private T data; // // @Override // public String toString() { // return "Result{" + // "code=" + code + // ", message='" + message + '\'' + // ", data=" + data + // '}'; // } // // public Result(Integer code, String message) { // this.code = code; // this.message = message; // } // // public Result(Integer code, String message, T data) { // this.code = code; // this.message = message; // this.data = data; // } // // public Integer getCode() { // return code; // } // // public void setCode(Integer code) { // this.code = code; // } // // public String getMessage() { // return message; // } // // public void setMessage(String message) { // this.message = message; // } // // public T getData() { // return data; // } // // public void setData(T data) { // this.data = data; // } // } // // Path: src/main/java/cn/niriqiang/blog/enums/ResultEnum.java // @ApiModel // public enum ResultEnum { // OK(200, "成功"), // NOT_BLANK(0, "不能为空"), // UNKNOW_ERROR(-1, "未知错误"), // NOT_FOUND(-2, "目标未找到"), // ADD_EXITS(-3, "目标已存在"), // DELETE_FALSE(-4, "不能删除相关文章还存在的分类"), // CURRENT_PAGE_NOT_NULL(-5, "页码不能为空"), // ERROR_NAME_PW(-6, "用户名密码错误"), // NOT_LOGIN(-7, "还没登陆!"); // // ResultEnum(Integer code, String message) { // this.code = code; // this.message = message; // } // // public Integer getCode() { // return code; // } // // public String getMessage() { // return message; // } // // @Override // public String toString() { // return "ResultEnum{" + // "code=" + code + // ", message='" + message + '\'' + // '}'; // } // // Integer code; // String message; // } // // Path: src/main/java/cn/niriqiang/blog/exception/ArticleException.java // public class ArticleException extends Exception { // // public ArticleException(ResultEnum resultEnum) { // super(resultEnum); // } // // public ArticleException(String message, Integer code) { // super(message, code); // } // // } // // Path: src/main/java/cn/niriqiang/blog/exception/TagException.java // public class TagException extends Exception { // // public TagException(ResultEnum resultEnum) { // super(resultEnum); // } // // public TagException(String message, Integer code) { // super(message, code); // } // } // // Path: src/main/java/cn/niriqiang/blog/util/ResultUtil.java // public class ResultUtil { // public static <T> Result<T> success(ResultEnum resultEnum, T t) { // return new Result(resultEnum.getCode(), resultEnum.getMessage(), t); // } // // public static Result error(Integer code, String message) { // return new Result(code, message); // } // // public static Result error(ResultEnum resultEnum) { // return new Result(resultEnum.getCode(), resultEnum.getMessage()); // } // }
import cn.niriqiang.blog.domain.*; import cn.niriqiang.blog.dto.Result; import cn.niriqiang.blog.enums.ResultEnum; import cn.niriqiang.blog.exception.ArticleException; import cn.niriqiang.blog.exception.TagException; import cn.niriqiang.blog.util.ResultUtil; import com.github.pagehelper.Page; import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageInfo; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import java.util.Date; import java.util.HashSet; import java.util.List; import java.util.Set;
package cn.niriqiang.blog.service; /** * 文章Service * Created by fengyuwusong on 2017/9/24 16:27. */ @Service public class ArticleService { @Autowired private ArticleMapper mapper; @Autowired private CategoryService categoryService; @Autowired private TagService tagService; @Autowired private ArticleTagsMapper articleTagsMapper; @Autowired private ConfigService configService; @Value("${page.size}") private int pageSize; @Transactional
// Path: src/main/java/cn/niriqiang/blog/dto/Result.java // public class Result<T> { // // // private Integer code; // // private String message; // // private T data; // // @Override // public String toString() { // return "Result{" + // "code=" + code + // ", message='" + message + '\'' + // ", data=" + data + // '}'; // } // // public Result(Integer code, String message) { // this.code = code; // this.message = message; // } // // public Result(Integer code, String message, T data) { // this.code = code; // this.message = message; // this.data = data; // } // // public Integer getCode() { // return code; // } // // public void setCode(Integer code) { // this.code = code; // } // // public String getMessage() { // return message; // } // // public void setMessage(String message) { // this.message = message; // } // // public T getData() { // return data; // } // // public void setData(T data) { // this.data = data; // } // } // // Path: src/main/java/cn/niriqiang/blog/enums/ResultEnum.java // @ApiModel // public enum ResultEnum { // OK(200, "成功"), // NOT_BLANK(0, "不能为空"), // UNKNOW_ERROR(-1, "未知错误"), // NOT_FOUND(-2, "目标未找到"), // ADD_EXITS(-3, "目标已存在"), // DELETE_FALSE(-4, "不能删除相关文章还存在的分类"), // CURRENT_PAGE_NOT_NULL(-5, "页码不能为空"), // ERROR_NAME_PW(-6, "用户名密码错误"), // NOT_LOGIN(-7, "还没登陆!"); // // ResultEnum(Integer code, String message) { // this.code = code; // this.message = message; // } // // public Integer getCode() { // return code; // } // // public String getMessage() { // return message; // } // // @Override // public String toString() { // return "ResultEnum{" + // "code=" + code + // ", message='" + message + '\'' + // '}'; // } // // Integer code; // String message; // } // // Path: src/main/java/cn/niriqiang/blog/exception/ArticleException.java // public class ArticleException extends Exception { // // public ArticleException(ResultEnum resultEnum) { // super(resultEnum); // } // // public ArticleException(String message, Integer code) { // super(message, code); // } // // } // // Path: src/main/java/cn/niriqiang/blog/exception/TagException.java // public class TagException extends Exception { // // public TagException(ResultEnum resultEnum) { // super(resultEnum); // } // // public TagException(String message, Integer code) { // super(message, code); // } // } // // Path: src/main/java/cn/niriqiang/blog/util/ResultUtil.java // public class ResultUtil { // public static <T> Result<T> success(ResultEnum resultEnum, T t) { // return new Result(resultEnum.getCode(), resultEnum.getMessage(), t); // } // // public static Result error(Integer code, String message) { // return new Result(code, message); // } // // public static Result error(ResultEnum resultEnum) { // return new Result(resultEnum.getCode(), resultEnum.getMessage()); // } // } // Path: src/main/java/cn/niriqiang/blog/service/ArticleService.java import cn.niriqiang.blog.domain.*; import cn.niriqiang.blog.dto.Result; import cn.niriqiang.blog.enums.ResultEnum; import cn.niriqiang.blog.exception.ArticleException; import cn.niriqiang.blog.exception.TagException; import cn.niriqiang.blog.util.ResultUtil; import com.github.pagehelper.Page; import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageInfo; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import java.util.Date; import java.util.HashSet; import java.util.List; import java.util.Set; package cn.niriqiang.blog.service; /** * 文章Service * Created by fengyuwusong on 2017/9/24 16:27. */ @Service public class ArticleService { @Autowired private ArticleMapper mapper; @Autowired private CategoryService categoryService; @Autowired private TagService tagService; @Autowired private ArticleTagsMapper articleTagsMapper; @Autowired private ConfigService configService; @Value("${page.size}") private int pageSize; @Transactional
public Result insertArticle(Article article) {
fengyuwusong/blog
src/main/java/cn/niriqiang/blog/service/ArticleService.java
// Path: src/main/java/cn/niriqiang/blog/dto/Result.java // public class Result<T> { // // // private Integer code; // // private String message; // // private T data; // // @Override // public String toString() { // return "Result{" + // "code=" + code + // ", message='" + message + '\'' + // ", data=" + data + // '}'; // } // // public Result(Integer code, String message) { // this.code = code; // this.message = message; // } // // public Result(Integer code, String message, T data) { // this.code = code; // this.message = message; // this.data = data; // } // // public Integer getCode() { // return code; // } // // public void setCode(Integer code) { // this.code = code; // } // // public String getMessage() { // return message; // } // // public void setMessage(String message) { // this.message = message; // } // // public T getData() { // return data; // } // // public void setData(T data) { // this.data = data; // } // } // // Path: src/main/java/cn/niriqiang/blog/enums/ResultEnum.java // @ApiModel // public enum ResultEnum { // OK(200, "成功"), // NOT_BLANK(0, "不能为空"), // UNKNOW_ERROR(-1, "未知错误"), // NOT_FOUND(-2, "目标未找到"), // ADD_EXITS(-3, "目标已存在"), // DELETE_FALSE(-4, "不能删除相关文章还存在的分类"), // CURRENT_PAGE_NOT_NULL(-5, "页码不能为空"), // ERROR_NAME_PW(-6, "用户名密码错误"), // NOT_LOGIN(-7, "还没登陆!"); // // ResultEnum(Integer code, String message) { // this.code = code; // this.message = message; // } // // public Integer getCode() { // return code; // } // // public String getMessage() { // return message; // } // // @Override // public String toString() { // return "ResultEnum{" + // "code=" + code + // ", message='" + message + '\'' + // '}'; // } // // Integer code; // String message; // } // // Path: src/main/java/cn/niriqiang/blog/exception/ArticleException.java // public class ArticleException extends Exception { // // public ArticleException(ResultEnum resultEnum) { // super(resultEnum); // } // // public ArticleException(String message, Integer code) { // super(message, code); // } // // } // // Path: src/main/java/cn/niriqiang/blog/exception/TagException.java // public class TagException extends Exception { // // public TagException(ResultEnum resultEnum) { // super(resultEnum); // } // // public TagException(String message, Integer code) { // super(message, code); // } // } // // Path: src/main/java/cn/niriqiang/blog/util/ResultUtil.java // public class ResultUtil { // public static <T> Result<T> success(ResultEnum resultEnum, T t) { // return new Result(resultEnum.getCode(), resultEnum.getMessage(), t); // } // // public static Result error(Integer code, String message) { // return new Result(code, message); // } // // public static Result error(ResultEnum resultEnum) { // return new Result(resultEnum.getCode(), resultEnum.getMessage()); // } // }
import cn.niriqiang.blog.domain.*; import cn.niriqiang.blog.dto.Result; import cn.niriqiang.blog.enums.ResultEnum; import cn.niriqiang.blog.exception.ArticleException; import cn.niriqiang.blog.exception.TagException; import cn.niriqiang.blog.util.ResultUtil; import com.github.pagehelper.Page; import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageInfo; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import java.util.Date; import java.util.HashSet; import java.util.List; import java.util.Set;
package cn.niriqiang.blog.service; /** * 文章Service * Created by fengyuwusong on 2017/9/24 16:27. */ @Service public class ArticleService { @Autowired private ArticleMapper mapper; @Autowired private CategoryService categoryService; @Autowired private TagService tagService; @Autowired private ArticleTagsMapper articleTagsMapper; @Autowired private ConfigService configService; @Value("${page.size}") private int pageSize; @Transactional public Result insertArticle(Article article) { // 查找分类是否存在 categoryService.findOne(article.getCategoryId()); try { findByTitle(article.getTitle());
// Path: src/main/java/cn/niriqiang/blog/dto/Result.java // public class Result<T> { // // // private Integer code; // // private String message; // // private T data; // // @Override // public String toString() { // return "Result{" + // "code=" + code + // ", message='" + message + '\'' + // ", data=" + data + // '}'; // } // // public Result(Integer code, String message) { // this.code = code; // this.message = message; // } // // public Result(Integer code, String message, T data) { // this.code = code; // this.message = message; // this.data = data; // } // // public Integer getCode() { // return code; // } // // public void setCode(Integer code) { // this.code = code; // } // // public String getMessage() { // return message; // } // // public void setMessage(String message) { // this.message = message; // } // // public T getData() { // return data; // } // // public void setData(T data) { // this.data = data; // } // } // // Path: src/main/java/cn/niriqiang/blog/enums/ResultEnum.java // @ApiModel // public enum ResultEnum { // OK(200, "成功"), // NOT_BLANK(0, "不能为空"), // UNKNOW_ERROR(-1, "未知错误"), // NOT_FOUND(-2, "目标未找到"), // ADD_EXITS(-3, "目标已存在"), // DELETE_FALSE(-4, "不能删除相关文章还存在的分类"), // CURRENT_PAGE_NOT_NULL(-5, "页码不能为空"), // ERROR_NAME_PW(-6, "用户名密码错误"), // NOT_LOGIN(-7, "还没登陆!"); // // ResultEnum(Integer code, String message) { // this.code = code; // this.message = message; // } // // public Integer getCode() { // return code; // } // // public String getMessage() { // return message; // } // // @Override // public String toString() { // return "ResultEnum{" + // "code=" + code + // ", message='" + message + '\'' + // '}'; // } // // Integer code; // String message; // } // // Path: src/main/java/cn/niriqiang/blog/exception/ArticleException.java // public class ArticleException extends Exception { // // public ArticleException(ResultEnum resultEnum) { // super(resultEnum); // } // // public ArticleException(String message, Integer code) { // super(message, code); // } // // } // // Path: src/main/java/cn/niriqiang/blog/exception/TagException.java // public class TagException extends Exception { // // public TagException(ResultEnum resultEnum) { // super(resultEnum); // } // // public TagException(String message, Integer code) { // super(message, code); // } // } // // Path: src/main/java/cn/niriqiang/blog/util/ResultUtil.java // public class ResultUtil { // public static <T> Result<T> success(ResultEnum resultEnum, T t) { // return new Result(resultEnum.getCode(), resultEnum.getMessage(), t); // } // // public static Result error(Integer code, String message) { // return new Result(code, message); // } // // public static Result error(ResultEnum resultEnum) { // return new Result(resultEnum.getCode(), resultEnum.getMessage()); // } // } // Path: src/main/java/cn/niriqiang/blog/service/ArticleService.java import cn.niriqiang.blog.domain.*; import cn.niriqiang.blog.dto.Result; import cn.niriqiang.blog.enums.ResultEnum; import cn.niriqiang.blog.exception.ArticleException; import cn.niriqiang.blog.exception.TagException; import cn.niriqiang.blog.util.ResultUtil; import com.github.pagehelper.Page; import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageInfo; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import java.util.Date; import java.util.HashSet; import java.util.List; import java.util.Set; package cn.niriqiang.blog.service; /** * 文章Service * Created by fengyuwusong on 2017/9/24 16:27. */ @Service public class ArticleService { @Autowired private ArticleMapper mapper; @Autowired private CategoryService categoryService; @Autowired private TagService tagService; @Autowired private ArticleTagsMapper articleTagsMapper; @Autowired private ConfigService configService; @Value("${page.size}") private int pageSize; @Transactional public Result insertArticle(Article article) { // 查找分类是否存在 categoryService.findOne(article.getCategoryId()); try { findByTitle(article.getTitle());
} catch (ArticleException e) {
fengyuwusong/blog
src/main/java/cn/niriqiang/blog/service/ArticleService.java
// Path: src/main/java/cn/niriqiang/blog/dto/Result.java // public class Result<T> { // // // private Integer code; // // private String message; // // private T data; // // @Override // public String toString() { // return "Result{" + // "code=" + code + // ", message='" + message + '\'' + // ", data=" + data + // '}'; // } // // public Result(Integer code, String message) { // this.code = code; // this.message = message; // } // // public Result(Integer code, String message, T data) { // this.code = code; // this.message = message; // this.data = data; // } // // public Integer getCode() { // return code; // } // // public void setCode(Integer code) { // this.code = code; // } // // public String getMessage() { // return message; // } // // public void setMessage(String message) { // this.message = message; // } // // public T getData() { // return data; // } // // public void setData(T data) { // this.data = data; // } // } // // Path: src/main/java/cn/niriqiang/blog/enums/ResultEnum.java // @ApiModel // public enum ResultEnum { // OK(200, "成功"), // NOT_BLANK(0, "不能为空"), // UNKNOW_ERROR(-1, "未知错误"), // NOT_FOUND(-2, "目标未找到"), // ADD_EXITS(-3, "目标已存在"), // DELETE_FALSE(-4, "不能删除相关文章还存在的分类"), // CURRENT_PAGE_NOT_NULL(-5, "页码不能为空"), // ERROR_NAME_PW(-6, "用户名密码错误"), // NOT_LOGIN(-7, "还没登陆!"); // // ResultEnum(Integer code, String message) { // this.code = code; // this.message = message; // } // // public Integer getCode() { // return code; // } // // public String getMessage() { // return message; // } // // @Override // public String toString() { // return "ResultEnum{" + // "code=" + code + // ", message='" + message + '\'' + // '}'; // } // // Integer code; // String message; // } // // Path: src/main/java/cn/niriqiang/blog/exception/ArticleException.java // public class ArticleException extends Exception { // // public ArticleException(ResultEnum resultEnum) { // super(resultEnum); // } // // public ArticleException(String message, Integer code) { // super(message, code); // } // // } // // Path: src/main/java/cn/niriqiang/blog/exception/TagException.java // public class TagException extends Exception { // // public TagException(ResultEnum resultEnum) { // super(resultEnum); // } // // public TagException(String message, Integer code) { // super(message, code); // } // } // // Path: src/main/java/cn/niriqiang/blog/util/ResultUtil.java // public class ResultUtil { // public static <T> Result<T> success(ResultEnum resultEnum, T t) { // return new Result(resultEnum.getCode(), resultEnum.getMessage(), t); // } // // public static Result error(Integer code, String message) { // return new Result(code, message); // } // // public static Result error(ResultEnum resultEnum) { // return new Result(resultEnum.getCode(), resultEnum.getMessage()); // } // }
import cn.niriqiang.blog.domain.*; import cn.niriqiang.blog.dto.Result; import cn.niriqiang.blog.enums.ResultEnum; import cn.niriqiang.blog.exception.ArticleException; import cn.niriqiang.blog.exception.TagException; import cn.niriqiang.blog.util.ResultUtil; import com.github.pagehelper.Page; import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageInfo; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import java.util.Date; import java.util.HashSet; import java.util.List; import java.util.Set;
package cn.niriqiang.blog.service; /** * 文章Service * Created by fengyuwusong on 2017/9/24 16:27. */ @Service public class ArticleService { @Autowired private ArticleMapper mapper; @Autowired private CategoryService categoryService; @Autowired private TagService tagService; @Autowired private ArticleTagsMapper articleTagsMapper; @Autowired private ConfigService configService; @Value("${page.size}") private int pageSize; @Transactional public Result insertArticle(Article article) { // 查找分类是否存在 categoryService.findOne(article.getCategoryId()); try { findByTitle(article.getTitle()); } catch (ArticleException e) {
// Path: src/main/java/cn/niriqiang/blog/dto/Result.java // public class Result<T> { // // // private Integer code; // // private String message; // // private T data; // // @Override // public String toString() { // return "Result{" + // "code=" + code + // ", message='" + message + '\'' + // ", data=" + data + // '}'; // } // // public Result(Integer code, String message) { // this.code = code; // this.message = message; // } // // public Result(Integer code, String message, T data) { // this.code = code; // this.message = message; // this.data = data; // } // // public Integer getCode() { // return code; // } // // public void setCode(Integer code) { // this.code = code; // } // // public String getMessage() { // return message; // } // // public void setMessage(String message) { // this.message = message; // } // // public T getData() { // return data; // } // // public void setData(T data) { // this.data = data; // } // } // // Path: src/main/java/cn/niriqiang/blog/enums/ResultEnum.java // @ApiModel // public enum ResultEnum { // OK(200, "成功"), // NOT_BLANK(0, "不能为空"), // UNKNOW_ERROR(-1, "未知错误"), // NOT_FOUND(-2, "目标未找到"), // ADD_EXITS(-3, "目标已存在"), // DELETE_FALSE(-4, "不能删除相关文章还存在的分类"), // CURRENT_PAGE_NOT_NULL(-5, "页码不能为空"), // ERROR_NAME_PW(-6, "用户名密码错误"), // NOT_LOGIN(-7, "还没登陆!"); // // ResultEnum(Integer code, String message) { // this.code = code; // this.message = message; // } // // public Integer getCode() { // return code; // } // // public String getMessage() { // return message; // } // // @Override // public String toString() { // return "ResultEnum{" + // "code=" + code + // ", message='" + message + '\'' + // '}'; // } // // Integer code; // String message; // } // // Path: src/main/java/cn/niriqiang/blog/exception/ArticleException.java // public class ArticleException extends Exception { // // public ArticleException(ResultEnum resultEnum) { // super(resultEnum); // } // // public ArticleException(String message, Integer code) { // super(message, code); // } // // } // // Path: src/main/java/cn/niriqiang/blog/exception/TagException.java // public class TagException extends Exception { // // public TagException(ResultEnum resultEnum) { // super(resultEnum); // } // // public TagException(String message, Integer code) { // super(message, code); // } // } // // Path: src/main/java/cn/niriqiang/blog/util/ResultUtil.java // public class ResultUtil { // public static <T> Result<T> success(ResultEnum resultEnum, T t) { // return new Result(resultEnum.getCode(), resultEnum.getMessage(), t); // } // // public static Result error(Integer code, String message) { // return new Result(code, message); // } // // public static Result error(ResultEnum resultEnum) { // return new Result(resultEnum.getCode(), resultEnum.getMessage()); // } // } // Path: src/main/java/cn/niriqiang/blog/service/ArticleService.java import cn.niriqiang.blog.domain.*; import cn.niriqiang.blog.dto.Result; import cn.niriqiang.blog.enums.ResultEnum; import cn.niriqiang.blog.exception.ArticleException; import cn.niriqiang.blog.exception.TagException; import cn.niriqiang.blog.util.ResultUtil; import com.github.pagehelper.Page; import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageInfo; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import java.util.Date; import java.util.HashSet; import java.util.List; import java.util.Set; package cn.niriqiang.blog.service; /** * 文章Service * Created by fengyuwusong on 2017/9/24 16:27. */ @Service public class ArticleService { @Autowired private ArticleMapper mapper; @Autowired private CategoryService categoryService; @Autowired private TagService tagService; @Autowired private ArticleTagsMapper articleTagsMapper; @Autowired private ConfigService configService; @Value("${page.size}") private int pageSize; @Transactional public Result insertArticle(Article article) { // 查找分类是否存在 categoryService.findOne(article.getCategoryId()); try { findByTitle(article.getTitle()); } catch (ArticleException e) {
if (e.getCode().equals(ResultEnum.NOT_FOUND.getCode())) {
fengyuwusong/blog
src/main/java/cn/niriqiang/blog/service/ArticleService.java
// Path: src/main/java/cn/niriqiang/blog/dto/Result.java // public class Result<T> { // // // private Integer code; // // private String message; // // private T data; // // @Override // public String toString() { // return "Result{" + // "code=" + code + // ", message='" + message + '\'' + // ", data=" + data + // '}'; // } // // public Result(Integer code, String message) { // this.code = code; // this.message = message; // } // // public Result(Integer code, String message, T data) { // this.code = code; // this.message = message; // this.data = data; // } // // public Integer getCode() { // return code; // } // // public void setCode(Integer code) { // this.code = code; // } // // public String getMessage() { // return message; // } // // public void setMessage(String message) { // this.message = message; // } // // public T getData() { // return data; // } // // public void setData(T data) { // this.data = data; // } // } // // Path: src/main/java/cn/niriqiang/blog/enums/ResultEnum.java // @ApiModel // public enum ResultEnum { // OK(200, "成功"), // NOT_BLANK(0, "不能为空"), // UNKNOW_ERROR(-1, "未知错误"), // NOT_FOUND(-2, "目标未找到"), // ADD_EXITS(-3, "目标已存在"), // DELETE_FALSE(-4, "不能删除相关文章还存在的分类"), // CURRENT_PAGE_NOT_NULL(-5, "页码不能为空"), // ERROR_NAME_PW(-6, "用户名密码错误"), // NOT_LOGIN(-7, "还没登陆!"); // // ResultEnum(Integer code, String message) { // this.code = code; // this.message = message; // } // // public Integer getCode() { // return code; // } // // public String getMessage() { // return message; // } // // @Override // public String toString() { // return "ResultEnum{" + // "code=" + code + // ", message='" + message + '\'' + // '}'; // } // // Integer code; // String message; // } // // Path: src/main/java/cn/niriqiang/blog/exception/ArticleException.java // public class ArticleException extends Exception { // // public ArticleException(ResultEnum resultEnum) { // super(resultEnum); // } // // public ArticleException(String message, Integer code) { // super(message, code); // } // // } // // Path: src/main/java/cn/niriqiang/blog/exception/TagException.java // public class TagException extends Exception { // // public TagException(ResultEnum resultEnum) { // super(resultEnum); // } // // public TagException(String message, Integer code) { // super(message, code); // } // } // // Path: src/main/java/cn/niriqiang/blog/util/ResultUtil.java // public class ResultUtil { // public static <T> Result<T> success(ResultEnum resultEnum, T t) { // return new Result(resultEnum.getCode(), resultEnum.getMessage(), t); // } // // public static Result error(Integer code, String message) { // return new Result(code, message); // } // // public static Result error(ResultEnum resultEnum) { // return new Result(resultEnum.getCode(), resultEnum.getMessage()); // } // }
import cn.niriqiang.blog.domain.*; import cn.niriqiang.blog.dto.Result; import cn.niriqiang.blog.enums.ResultEnum; import cn.niriqiang.blog.exception.ArticleException; import cn.niriqiang.blog.exception.TagException; import cn.niriqiang.blog.util.ResultUtil; import com.github.pagehelper.Page; import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageInfo; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import java.util.Date; import java.util.HashSet; import java.util.List; import java.util.Set;
package cn.niriqiang.blog.service; /** * 文章Service * Created by fengyuwusong on 2017/9/24 16:27. */ @Service public class ArticleService { @Autowired private ArticleMapper mapper; @Autowired private CategoryService categoryService; @Autowired private TagService tagService; @Autowired private ArticleTagsMapper articleTagsMapper; @Autowired private ConfigService configService; @Value("${page.size}") private int pageSize; @Transactional public Result insertArticle(Article article) { // 查找分类是否存在 categoryService.findOne(article.getCategoryId()); try { findByTitle(article.getTitle()); } catch (ArticleException e) { if (e.getCode().equals(ResultEnum.NOT_FOUND.getCode())) { mapper.insert(article); if (article.getArticleTags().size() != 0) { insertArticleTags(article.getId(), article.getArticleTags()); }
// Path: src/main/java/cn/niriqiang/blog/dto/Result.java // public class Result<T> { // // // private Integer code; // // private String message; // // private T data; // // @Override // public String toString() { // return "Result{" + // "code=" + code + // ", message='" + message + '\'' + // ", data=" + data + // '}'; // } // // public Result(Integer code, String message) { // this.code = code; // this.message = message; // } // // public Result(Integer code, String message, T data) { // this.code = code; // this.message = message; // this.data = data; // } // // public Integer getCode() { // return code; // } // // public void setCode(Integer code) { // this.code = code; // } // // public String getMessage() { // return message; // } // // public void setMessage(String message) { // this.message = message; // } // // public T getData() { // return data; // } // // public void setData(T data) { // this.data = data; // } // } // // Path: src/main/java/cn/niriqiang/blog/enums/ResultEnum.java // @ApiModel // public enum ResultEnum { // OK(200, "成功"), // NOT_BLANK(0, "不能为空"), // UNKNOW_ERROR(-1, "未知错误"), // NOT_FOUND(-2, "目标未找到"), // ADD_EXITS(-3, "目标已存在"), // DELETE_FALSE(-4, "不能删除相关文章还存在的分类"), // CURRENT_PAGE_NOT_NULL(-5, "页码不能为空"), // ERROR_NAME_PW(-6, "用户名密码错误"), // NOT_LOGIN(-7, "还没登陆!"); // // ResultEnum(Integer code, String message) { // this.code = code; // this.message = message; // } // // public Integer getCode() { // return code; // } // // public String getMessage() { // return message; // } // // @Override // public String toString() { // return "ResultEnum{" + // "code=" + code + // ", message='" + message + '\'' + // '}'; // } // // Integer code; // String message; // } // // Path: src/main/java/cn/niriqiang/blog/exception/ArticleException.java // public class ArticleException extends Exception { // // public ArticleException(ResultEnum resultEnum) { // super(resultEnum); // } // // public ArticleException(String message, Integer code) { // super(message, code); // } // // } // // Path: src/main/java/cn/niriqiang/blog/exception/TagException.java // public class TagException extends Exception { // // public TagException(ResultEnum resultEnum) { // super(resultEnum); // } // // public TagException(String message, Integer code) { // super(message, code); // } // } // // Path: src/main/java/cn/niriqiang/blog/util/ResultUtil.java // public class ResultUtil { // public static <T> Result<T> success(ResultEnum resultEnum, T t) { // return new Result(resultEnum.getCode(), resultEnum.getMessage(), t); // } // // public static Result error(Integer code, String message) { // return new Result(code, message); // } // // public static Result error(ResultEnum resultEnum) { // return new Result(resultEnum.getCode(), resultEnum.getMessage()); // } // } // Path: src/main/java/cn/niriqiang/blog/service/ArticleService.java import cn.niriqiang.blog.domain.*; import cn.niriqiang.blog.dto.Result; import cn.niriqiang.blog.enums.ResultEnum; import cn.niriqiang.blog.exception.ArticleException; import cn.niriqiang.blog.exception.TagException; import cn.niriqiang.blog.util.ResultUtil; import com.github.pagehelper.Page; import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageInfo; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import java.util.Date; import java.util.HashSet; import java.util.List; import java.util.Set; package cn.niriqiang.blog.service; /** * 文章Service * Created by fengyuwusong on 2017/9/24 16:27. */ @Service public class ArticleService { @Autowired private ArticleMapper mapper; @Autowired private CategoryService categoryService; @Autowired private TagService tagService; @Autowired private ArticleTagsMapper articleTagsMapper; @Autowired private ConfigService configService; @Value("${page.size}") private int pageSize; @Transactional public Result insertArticle(Article article) { // 查找分类是否存在 categoryService.findOne(article.getCategoryId()); try { findByTitle(article.getTitle()); } catch (ArticleException e) { if (e.getCode().equals(ResultEnum.NOT_FOUND.getCode())) { mapper.insert(article); if (article.getArticleTags().size() != 0) { insertArticleTags(article.getId(), article.getArticleTags()); }
return ResultUtil.success(ResultEnum.OK, article);
fengyuwusong/blog
src/main/java/cn/niriqiang/blog/service/ArticleService.java
// Path: src/main/java/cn/niriqiang/blog/dto/Result.java // public class Result<T> { // // // private Integer code; // // private String message; // // private T data; // // @Override // public String toString() { // return "Result{" + // "code=" + code + // ", message='" + message + '\'' + // ", data=" + data + // '}'; // } // // public Result(Integer code, String message) { // this.code = code; // this.message = message; // } // // public Result(Integer code, String message, T data) { // this.code = code; // this.message = message; // this.data = data; // } // // public Integer getCode() { // return code; // } // // public void setCode(Integer code) { // this.code = code; // } // // public String getMessage() { // return message; // } // // public void setMessage(String message) { // this.message = message; // } // // public T getData() { // return data; // } // // public void setData(T data) { // this.data = data; // } // } // // Path: src/main/java/cn/niriqiang/blog/enums/ResultEnum.java // @ApiModel // public enum ResultEnum { // OK(200, "成功"), // NOT_BLANK(0, "不能为空"), // UNKNOW_ERROR(-1, "未知错误"), // NOT_FOUND(-2, "目标未找到"), // ADD_EXITS(-3, "目标已存在"), // DELETE_FALSE(-4, "不能删除相关文章还存在的分类"), // CURRENT_PAGE_NOT_NULL(-5, "页码不能为空"), // ERROR_NAME_PW(-6, "用户名密码错误"), // NOT_LOGIN(-7, "还没登陆!"); // // ResultEnum(Integer code, String message) { // this.code = code; // this.message = message; // } // // public Integer getCode() { // return code; // } // // public String getMessage() { // return message; // } // // @Override // public String toString() { // return "ResultEnum{" + // "code=" + code + // ", message='" + message + '\'' + // '}'; // } // // Integer code; // String message; // } // // Path: src/main/java/cn/niriqiang/blog/exception/ArticleException.java // public class ArticleException extends Exception { // // public ArticleException(ResultEnum resultEnum) { // super(resultEnum); // } // // public ArticleException(String message, Integer code) { // super(message, code); // } // // } // // Path: src/main/java/cn/niriqiang/blog/exception/TagException.java // public class TagException extends Exception { // // public TagException(ResultEnum resultEnum) { // super(resultEnum); // } // // public TagException(String message, Integer code) { // super(message, code); // } // } // // Path: src/main/java/cn/niriqiang/blog/util/ResultUtil.java // public class ResultUtil { // public static <T> Result<T> success(ResultEnum resultEnum, T t) { // return new Result(resultEnum.getCode(), resultEnum.getMessage(), t); // } // // public static Result error(Integer code, String message) { // return new Result(code, message); // } // // public static Result error(ResultEnum resultEnum) { // return new Result(resultEnum.getCode(), resultEnum.getMessage()); // } // }
import cn.niriqiang.blog.domain.*; import cn.niriqiang.blog.dto.Result; import cn.niriqiang.blog.enums.ResultEnum; import cn.niriqiang.blog.exception.ArticleException; import cn.niriqiang.blog.exception.TagException; import cn.niriqiang.blog.util.ResultUtil; import com.github.pagehelper.Page; import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageInfo; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import java.util.Date; import java.util.HashSet; import java.util.List; import java.util.Set;
public Result adminSearch(int currentPage, String keyWord) { PageHelper.startPage(currentPage, pageSize); Page<Article> articles = mapper.adminSearch(keyWord); for (Article a : articles) { a.setArticleTags(findTag(a)); } PageInfo<Article> res = articles.toPageInfo(); if (articles.size() != 0) { return ResultUtil.success(ResultEnum.OK, res); } throw new ArticleException(ResultEnum.NOT_FOUND); } /** * 将标签插入表articleTags * * @param articleId 文章id * @param tags 文章标签列表 */ private void insertArticleTags(int articleId, Set<Tag> tags) { ArticleTags articleTags = new ArticleTags(); articleTags.setArticleId(articleId); for (Tag tag : tags) { try { tag = (Tag) tagService.insertTag(tag).getData(); } catch (Exception e) { // 如果存在TagException说明是存在重复 忽略
// Path: src/main/java/cn/niriqiang/blog/dto/Result.java // public class Result<T> { // // // private Integer code; // // private String message; // // private T data; // // @Override // public String toString() { // return "Result{" + // "code=" + code + // ", message='" + message + '\'' + // ", data=" + data + // '}'; // } // // public Result(Integer code, String message) { // this.code = code; // this.message = message; // } // // public Result(Integer code, String message, T data) { // this.code = code; // this.message = message; // this.data = data; // } // // public Integer getCode() { // return code; // } // // public void setCode(Integer code) { // this.code = code; // } // // public String getMessage() { // return message; // } // // public void setMessage(String message) { // this.message = message; // } // // public T getData() { // return data; // } // // public void setData(T data) { // this.data = data; // } // } // // Path: src/main/java/cn/niriqiang/blog/enums/ResultEnum.java // @ApiModel // public enum ResultEnum { // OK(200, "成功"), // NOT_BLANK(0, "不能为空"), // UNKNOW_ERROR(-1, "未知错误"), // NOT_FOUND(-2, "目标未找到"), // ADD_EXITS(-3, "目标已存在"), // DELETE_FALSE(-4, "不能删除相关文章还存在的分类"), // CURRENT_PAGE_NOT_NULL(-5, "页码不能为空"), // ERROR_NAME_PW(-6, "用户名密码错误"), // NOT_LOGIN(-7, "还没登陆!"); // // ResultEnum(Integer code, String message) { // this.code = code; // this.message = message; // } // // public Integer getCode() { // return code; // } // // public String getMessage() { // return message; // } // // @Override // public String toString() { // return "ResultEnum{" + // "code=" + code + // ", message='" + message + '\'' + // '}'; // } // // Integer code; // String message; // } // // Path: src/main/java/cn/niriqiang/blog/exception/ArticleException.java // public class ArticleException extends Exception { // // public ArticleException(ResultEnum resultEnum) { // super(resultEnum); // } // // public ArticleException(String message, Integer code) { // super(message, code); // } // // } // // Path: src/main/java/cn/niriqiang/blog/exception/TagException.java // public class TagException extends Exception { // // public TagException(ResultEnum resultEnum) { // super(resultEnum); // } // // public TagException(String message, Integer code) { // super(message, code); // } // } // // Path: src/main/java/cn/niriqiang/blog/util/ResultUtil.java // public class ResultUtil { // public static <T> Result<T> success(ResultEnum resultEnum, T t) { // return new Result(resultEnum.getCode(), resultEnum.getMessage(), t); // } // // public static Result error(Integer code, String message) { // return new Result(code, message); // } // // public static Result error(ResultEnum resultEnum) { // return new Result(resultEnum.getCode(), resultEnum.getMessage()); // } // } // Path: src/main/java/cn/niriqiang/blog/service/ArticleService.java import cn.niriqiang.blog.domain.*; import cn.niriqiang.blog.dto.Result; import cn.niriqiang.blog.enums.ResultEnum; import cn.niriqiang.blog.exception.ArticleException; import cn.niriqiang.blog.exception.TagException; import cn.niriqiang.blog.util.ResultUtil; import com.github.pagehelper.Page; import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageInfo; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import java.util.Date; import java.util.HashSet; import java.util.List; import java.util.Set; public Result adminSearch(int currentPage, String keyWord) { PageHelper.startPage(currentPage, pageSize); Page<Article> articles = mapper.adminSearch(keyWord); for (Article a : articles) { a.setArticleTags(findTag(a)); } PageInfo<Article> res = articles.toPageInfo(); if (articles.size() != 0) { return ResultUtil.success(ResultEnum.OK, res); } throw new ArticleException(ResultEnum.NOT_FOUND); } /** * 将标签插入表articleTags * * @param articleId 文章id * @param tags 文章标签列表 */ private void insertArticleTags(int articleId, Set<Tag> tags) { ArticleTags articleTags = new ArticleTags(); articleTags.setArticleId(articleId); for (Tag tag : tags) { try { tag = (Tag) tagService.insertTag(tag).getData(); } catch (Exception e) { // 如果存在TagException说明是存在重复 忽略
if (!(e instanceof TagException)) {
fengyuwusong/blog
src/main/java/cn/niriqiang/blog/controller/CategoryController.java
// Path: src/main/java/cn/niriqiang/blog/domain/Category.java // @ApiModel // @Data // public class Category { // @ApiModelProperty(value = "ID") // private Integer id; // @ApiModelProperty(value = "分类名") // @NotNull(message = "类型名称不能为空") // private String categoryName; // @ApiModelProperty(value = "分类描述") // @NotNull(message = "描述不能为空") // private String description; // } // // Path: src/main/java/cn/niriqiang/blog/dto/Result.java // public class Result<T> { // // // private Integer code; // // private String message; // // private T data; // // @Override // public String toString() { // return "Result{" + // "code=" + code + // ", message='" + message + '\'' + // ", data=" + data + // '}'; // } // // public Result(Integer code, String message) { // this.code = code; // this.message = message; // } // // public Result(Integer code, String message, T data) { // this.code = code; // this.message = message; // this.data = data; // } // // public Integer getCode() { // return code; // } // // public void setCode(Integer code) { // this.code = code; // } // // public String getMessage() { // return message; // } // // public void setMessage(String message) { // this.message = message; // } // // public T getData() { // return data; // } // // public void setData(T data) { // this.data = data; // } // } // // Path: src/main/java/cn/niriqiang/blog/exception/CategoryException.java // public class CategoryException extends Exception { // public CategoryException(ResultEnum resultEnum) { // super(resultEnum); // } // // public CategoryException(String message, Integer code) { // super(message, code); // } // // } // // Path: src/main/java/cn/niriqiang/blog/service/CategoryService.java // @Service // public class CategoryService { // @Autowired // private CategoryMapper mapper; // // @Autowired // private ArticleService articleService; // // public Result insertCategory(Category category) { // try { // findByCategoryName(category.getCategoryName()); // } catch (CategoryException e) { // mapper.insert(category); // return ResultUtil.success(ResultEnum.OK, category); // } // throw new CategoryException(ResultEnum.ADD_EXITS); // } // // public Result updateCategory(Category category) { // // 查找id是否存在 // Category res = (Category) findOne(category.getId()).getData(); // // 如果CategoryName是需要修改项 查找更改的categoryName是否已经存在 // if (!category.getCategoryName().equals(res.getCategoryName())) { // try { // findByCategoryName(category.getCategoryName()); // } catch (CategoryException e) { // mapper.update(category); // return ResultUtil.success(ResultEnum.OK, category); // } // throw new CategoryException(ResultEnum.ADD_EXITS); // } // mapper.update(category); // return ResultUtil.success(ResultEnum.OK, category); // } // // public Result findOne(int id) { // Category category = mapper.findOne(id); // if (category != null) { // return ResultUtil.success(ResultEnum.OK, category); // } else { // throw new CategoryException(ResultEnum.NOT_FOUND); // } // } // // public Result findByCategoryName(String categoryName) { // Category category = mapper.findByCategoryName(categoryName); // if (category != null) { // return ResultUtil.success(ResultEnum.OK, category); // } else { // throw new CategoryException(ResultEnum.NOT_FOUND); // } // } // // public Result findAll() { // List<Category> categoryPage = mapper.findAll(); // return ResultUtil.success(ResultEnum.OK, categoryPage); // } // // public Result delete(int id) { // findOne(id); // // 查找该分类下的文章是否存在 若存在则不能删除 // try { // articleService.findByCategory(1, id); // } catch (ArticleException e) { // mapper.delete(id); // return ResultUtil.success(ResultEnum.OK, id); // } // throw new CategoryException(ResultEnum.DELETE_FALSE); // } // }
import cn.niriqiang.blog.annotation.Admin; import cn.niriqiang.blog.domain.Category; import cn.niriqiang.blog.dto.Result; import cn.niriqiang.blog.exception.CategoryException; import cn.niriqiang.blog.service.CategoryService; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.validation.Errors; import org.springframework.web.bind.annotation.*; import javax.validation.Valid;
package cn.niriqiang.blog.controller; /** * Created by fengyuwusong on 2017/10/1 23:45. */ @Api(value = "分类管理接口") @RestController @RequestMapping("/category") public class CategoryController { @Autowired
// Path: src/main/java/cn/niriqiang/blog/domain/Category.java // @ApiModel // @Data // public class Category { // @ApiModelProperty(value = "ID") // private Integer id; // @ApiModelProperty(value = "分类名") // @NotNull(message = "类型名称不能为空") // private String categoryName; // @ApiModelProperty(value = "分类描述") // @NotNull(message = "描述不能为空") // private String description; // } // // Path: src/main/java/cn/niriqiang/blog/dto/Result.java // public class Result<T> { // // // private Integer code; // // private String message; // // private T data; // // @Override // public String toString() { // return "Result{" + // "code=" + code + // ", message='" + message + '\'' + // ", data=" + data + // '}'; // } // // public Result(Integer code, String message) { // this.code = code; // this.message = message; // } // // public Result(Integer code, String message, T data) { // this.code = code; // this.message = message; // this.data = data; // } // // public Integer getCode() { // return code; // } // // public void setCode(Integer code) { // this.code = code; // } // // public String getMessage() { // return message; // } // // public void setMessage(String message) { // this.message = message; // } // // public T getData() { // return data; // } // // public void setData(T data) { // this.data = data; // } // } // // Path: src/main/java/cn/niriqiang/blog/exception/CategoryException.java // public class CategoryException extends Exception { // public CategoryException(ResultEnum resultEnum) { // super(resultEnum); // } // // public CategoryException(String message, Integer code) { // super(message, code); // } // // } // // Path: src/main/java/cn/niriqiang/blog/service/CategoryService.java // @Service // public class CategoryService { // @Autowired // private CategoryMapper mapper; // // @Autowired // private ArticleService articleService; // // public Result insertCategory(Category category) { // try { // findByCategoryName(category.getCategoryName()); // } catch (CategoryException e) { // mapper.insert(category); // return ResultUtil.success(ResultEnum.OK, category); // } // throw new CategoryException(ResultEnum.ADD_EXITS); // } // // public Result updateCategory(Category category) { // // 查找id是否存在 // Category res = (Category) findOne(category.getId()).getData(); // // 如果CategoryName是需要修改项 查找更改的categoryName是否已经存在 // if (!category.getCategoryName().equals(res.getCategoryName())) { // try { // findByCategoryName(category.getCategoryName()); // } catch (CategoryException e) { // mapper.update(category); // return ResultUtil.success(ResultEnum.OK, category); // } // throw new CategoryException(ResultEnum.ADD_EXITS); // } // mapper.update(category); // return ResultUtil.success(ResultEnum.OK, category); // } // // public Result findOne(int id) { // Category category = mapper.findOne(id); // if (category != null) { // return ResultUtil.success(ResultEnum.OK, category); // } else { // throw new CategoryException(ResultEnum.NOT_FOUND); // } // } // // public Result findByCategoryName(String categoryName) { // Category category = mapper.findByCategoryName(categoryName); // if (category != null) { // return ResultUtil.success(ResultEnum.OK, category); // } else { // throw new CategoryException(ResultEnum.NOT_FOUND); // } // } // // public Result findAll() { // List<Category> categoryPage = mapper.findAll(); // return ResultUtil.success(ResultEnum.OK, categoryPage); // } // // public Result delete(int id) { // findOne(id); // // 查找该分类下的文章是否存在 若存在则不能删除 // try { // articleService.findByCategory(1, id); // } catch (ArticleException e) { // mapper.delete(id); // return ResultUtil.success(ResultEnum.OK, id); // } // throw new CategoryException(ResultEnum.DELETE_FALSE); // } // } // Path: src/main/java/cn/niriqiang/blog/controller/CategoryController.java import cn.niriqiang.blog.annotation.Admin; import cn.niriqiang.blog.domain.Category; import cn.niriqiang.blog.dto.Result; import cn.niriqiang.blog.exception.CategoryException; import cn.niriqiang.blog.service.CategoryService; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.validation.Errors; import org.springframework.web.bind.annotation.*; import javax.validation.Valid; package cn.niriqiang.blog.controller; /** * Created by fengyuwusong on 2017/10/1 23:45. */ @Api(value = "分类管理接口") @RestController @RequestMapping("/category") public class CategoryController { @Autowired
private CategoryService categoryService;
fengyuwusong/blog
src/main/java/cn/niriqiang/blog/controller/CategoryController.java
// Path: src/main/java/cn/niriqiang/blog/domain/Category.java // @ApiModel // @Data // public class Category { // @ApiModelProperty(value = "ID") // private Integer id; // @ApiModelProperty(value = "分类名") // @NotNull(message = "类型名称不能为空") // private String categoryName; // @ApiModelProperty(value = "分类描述") // @NotNull(message = "描述不能为空") // private String description; // } // // Path: src/main/java/cn/niriqiang/blog/dto/Result.java // public class Result<T> { // // // private Integer code; // // private String message; // // private T data; // // @Override // public String toString() { // return "Result{" + // "code=" + code + // ", message='" + message + '\'' + // ", data=" + data + // '}'; // } // // public Result(Integer code, String message) { // this.code = code; // this.message = message; // } // // public Result(Integer code, String message, T data) { // this.code = code; // this.message = message; // this.data = data; // } // // public Integer getCode() { // return code; // } // // public void setCode(Integer code) { // this.code = code; // } // // public String getMessage() { // return message; // } // // public void setMessage(String message) { // this.message = message; // } // // public T getData() { // return data; // } // // public void setData(T data) { // this.data = data; // } // } // // Path: src/main/java/cn/niriqiang/blog/exception/CategoryException.java // public class CategoryException extends Exception { // public CategoryException(ResultEnum resultEnum) { // super(resultEnum); // } // // public CategoryException(String message, Integer code) { // super(message, code); // } // // } // // Path: src/main/java/cn/niriqiang/blog/service/CategoryService.java // @Service // public class CategoryService { // @Autowired // private CategoryMapper mapper; // // @Autowired // private ArticleService articleService; // // public Result insertCategory(Category category) { // try { // findByCategoryName(category.getCategoryName()); // } catch (CategoryException e) { // mapper.insert(category); // return ResultUtil.success(ResultEnum.OK, category); // } // throw new CategoryException(ResultEnum.ADD_EXITS); // } // // public Result updateCategory(Category category) { // // 查找id是否存在 // Category res = (Category) findOne(category.getId()).getData(); // // 如果CategoryName是需要修改项 查找更改的categoryName是否已经存在 // if (!category.getCategoryName().equals(res.getCategoryName())) { // try { // findByCategoryName(category.getCategoryName()); // } catch (CategoryException e) { // mapper.update(category); // return ResultUtil.success(ResultEnum.OK, category); // } // throw new CategoryException(ResultEnum.ADD_EXITS); // } // mapper.update(category); // return ResultUtil.success(ResultEnum.OK, category); // } // // public Result findOne(int id) { // Category category = mapper.findOne(id); // if (category != null) { // return ResultUtil.success(ResultEnum.OK, category); // } else { // throw new CategoryException(ResultEnum.NOT_FOUND); // } // } // // public Result findByCategoryName(String categoryName) { // Category category = mapper.findByCategoryName(categoryName); // if (category != null) { // return ResultUtil.success(ResultEnum.OK, category); // } else { // throw new CategoryException(ResultEnum.NOT_FOUND); // } // } // // public Result findAll() { // List<Category> categoryPage = mapper.findAll(); // return ResultUtil.success(ResultEnum.OK, categoryPage); // } // // public Result delete(int id) { // findOne(id); // // 查找该分类下的文章是否存在 若存在则不能删除 // try { // articleService.findByCategory(1, id); // } catch (ArticleException e) { // mapper.delete(id); // return ResultUtil.success(ResultEnum.OK, id); // } // throw new CategoryException(ResultEnum.DELETE_FALSE); // } // }
import cn.niriqiang.blog.annotation.Admin; import cn.niriqiang.blog.domain.Category; import cn.niriqiang.blog.dto.Result; import cn.niriqiang.blog.exception.CategoryException; import cn.niriqiang.blog.service.CategoryService; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.validation.Errors; import org.springframework.web.bind.annotation.*; import javax.validation.Valid;
package cn.niriqiang.blog.controller; /** * Created by fengyuwusong on 2017/10/1 23:45. */ @Api(value = "分类管理接口") @RestController @RequestMapping("/category") public class CategoryController { @Autowired private CategoryService categoryService; @ApiOperation("查找全部") @GetMapping
// Path: src/main/java/cn/niriqiang/blog/domain/Category.java // @ApiModel // @Data // public class Category { // @ApiModelProperty(value = "ID") // private Integer id; // @ApiModelProperty(value = "分类名") // @NotNull(message = "类型名称不能为空") // private String categoryName; // @ApiModelProperty(value = "分类描述") // @NotNull(message = "描述不能为空") // private String description; // } // // Path: src/main/java/cn/niriqiang/blog/dto/Result.java // public class Result<T> { // // // private Integer code; // // private String message; // // private T data; // // @Override // public String toString() { // return "Result{" + // "code=" + code + // ", message='" + message + '\'' + // ", data=" + data + // '}'; // } // // public Result(Integer code, String message) { // this.code = code; // this.message = message; // } // // public Result(Integer code, String message, T data) { // this.code = code; // this.message = message; // this.data = data; // } // // public Integer getCode() { // return code; // } // // public void setCode(Integer code) { // this.code = code; // } // // public String getMessage() { // return message; // } // // public void setMessage(String message) { // this.message = message; // } // // public T getData() { // return data; // } // // public void setData(T data) { // this.data = data; // } // } // // Path: src/main/java/cn/niriqiang/blog/exception/CategoryException.java // public class CategoryException extends Exception { // public CategoryException(ResultEnum resultEnum) { // super(resultEnum); // } // // public CategoryException(String message, Integer code) { // super(message, code); // } // // } // // Path: src/main/java/cn/niriqiang/blog/service/CategoryService.java // @Service // public class CategoryService { // @Autowired // private CategoryMapper mapper; // // @Autowired // private ArticleService articleService; // // public Result insertCategory(Category category) { // try { // findByCategoryName(category.getCategoryName()); // } catch (CategoryException e) { // mapper.insert(category); // return ResultUtil.success(ResultEnum.OK, category); // } // throw new CategoryException(ResultEnum.ADD_EXITS); // } // // public Result updateCategory(Category category) { // // 查找id是否存在 // Category res = (Category) findOne(category.getId()).getData(); // // 如果CategoryName是需要修改项 查找更改的categoryName是否已经存在 // if (!category.getCategoryName().equals(res.getCategoryName())) { // try { // findByCategoryName(category.getCategoryName()); // } catch (CategoryException e) { // mapper.update(category); // return ResultUtil.success(ResultEnum.OK, category); // } // throw new CategoryException(ResultEnum.ADD_EXITS); // } // mapper.update(category); // return ResultUtil.success(ResultEnum.OK, category); // } // // public Result findOne(int id) { // Category category = mapper.findOne(id); // if (category != null) { // return ResultUtil.success(ResultEnum.OK, category); // } else { // throw new CategoryException(ResultEnum.NOT_FOUND); // } // } // // public Result findByCategoryName(String categoryName) { // Category category = mapper.findByCategoryName(categoryName); // if (category != null) { // return ResultUtil.success(ResultEnum.OK, category); // } else { // throw new CategoryException(ResultEnum.NOT_FOUND); // } // } // // public Result findAll() { // List<Category> categoryPage = mapper.findAll(); // return ResultUtil.success(ResultEnum.OK, categoryPage); // } // // public Result delete(int id) { // findOne(id); // // 查找该分类下的文章是否存在 若存在则不能删除 // try { // articleService.findByCategory(1, id); // } catch (ArticleException e) { // mapper.delete(id); // return ResultUtil.success(ResultEnum.OK, id); // } // throw new CategoryException(ResultEnum.DELETE_FALSE); // } // } // Path: src/main/java/cn/niriqiang/blog/controller/CategoryController.java import cn.niriqiang.blog.annotation.Admin; import cn.niriqiang.blog.domain.Category; import cn.niriqiang.blog.dto.Result; import cn.niriqiang.blog.exception.CategoryException; import cn.niriqiang.blog.service.CategoryService; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.validation.Errors; import org.springframework.web.bind.annotation.*; import javax.validation.Valid; package cn.niriqiang.blog.controller; /** * Created by fengyuwusong on 2017/10/1 23:45. */ @Api(value = "分类管理接口") @RestController @RequestMapping("/category") public class CategoryController { @Autowired private CategoryService categoryService; @ApiOperation("查找全部") @GetMapping
public Result findAll() {
fengyuwusong/blog
src/main/java/cn/niriqiang/blog/controller/CategoryController.java
// Path: src/main/java/cn/niriqiang/blog/domain/Category.java // @ApiModel // @Data // public class Category { // @ApiModelProperty(value = "ID") // private Integer id; // @ApiModelProperty(value = "分类名") // @NotNull(message = "类型名称不能为空") // private String categoryName; // @ApiModelProperty(value = "分类描述") // @NotNull(message = "描述不能为空") // private String description; // } // // Path: src/main/java/cn/niriqiang/blog/dto/Result.java // public class Result<T> { // // // private Integer code; // // private String message; // // private T data; // // @Override // public String toString() { // return "Result{" + // "code=" + code + // ", message='" + message + '\'' + // ", data=" + data + // '}'; // } // // public Result(Integer code, String message) { // this.code = code; // this.message = message; // } // // public Result(Integer code, String message, T data) { // this.code = code; // this.message = message; // this.data = data; // } // // public Integer getCode() { // return code; // } // // public void setCode(Integer code) { // this.code = code; // } // // public String getMessage() { // return message; // } // // public void setMessage(String message) { // this.message = message; // } // // public T getData() { // return data; // } // // public void setData(T data) { // this.data = data; // } // } // // Path: src/main/java/cn/niriqiang/blog/exception/CategoryException.java // public class CategoryException extends Exception { // public CategoryException(ResultEnum resultEnum) { // super(resultEnum); // } // // public CategoryException(String message, Integer code) { // super(message, code); // } // // } // // Path: src/main/java/cn/niriqiang/blog/service/CategoryService.java // @Service // public class CategoryService { // @Autowired // private CategoryMapper mapper; // // @Autowired // private ArticleService articleService; // // public Result insertCategory(Category category) { // try { // findByCategoryName(category.getCategoryName()); // } catch (CategoryException e) { // mapper.insert(category); // return ResultUtil.success(ResultEnum.OK, category); // } // throw new CategoryException(ResultEnum.ADD_EXITS); // } // // public Result updateCategory(Category category) { // // 查找id是否存在 // Category res = (Category) findOne(category.getId()).getData(); // // 如果CategoryName是需要修改项 查找更改的categoryName是否已经存在 // if (!category.getCategoryName().equals(res.getCategoryName())) { // try { // findByCategoryName(category.getCategoryName()); // } catch (CategoryException e) { // mapper.update(category); // return ResultUtil.success(ResultEnum.OK, category); // } // throw new CategoryException(ResultEnum.ADD_EXITS); // } // mapper.update(category); // return ResultUtil.success(ResultEnum.OK, category); // } // // public Result findOne(int id) { // Category category = mapper.findOne(id); // if (category != null) { // return ResultUtil.success(ResultEnum.OK, category); // } else { // throw new CategoryException(ResultEnum.NOT_FOUND); // } // } // // public Result findByCategoryName(String categoryName) { // Category category = mapper.findByCategoryName(categoryName); // if (category != null) { // return ResultUtil.success(ResultEnum.OK, category); // } else { // throw new CategoryException(ResultEnum.NOT_FOUND); // } // } // // public Result findAll() { // List<Category> categoryPage = mapper.findAll(); // return ResultUtil.success(ResultEnum.OK, categoryPage); // } // // public Result delete(int id) { // findOne(id); // // 查找该分类下的文章是否存在 若存在则不能删除 // try { // articleService.findByCategory(1, id); // } catch (ArticleException e) { // mapper.delete(id); // return ResultUtil.success(ResultEnum.OK, id); // } // throw new CategoryException(ResultEnum.DELETE_FALSE); // } // }
import cn.niriqiang.blog.annotation.Admin; import cn.niriqiang.blog.domain.Category; import cn.niriqiang.blog.dto.Result; import cn.niriqiang.blog.exception.CategoryException; import cn.niriqiang.blog.service.CategoryService; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.validation.Errors; import org.springframework.web.bind.annotation.*; import javax.validation.Valid;
package cn.niriqiang.blog.controller; /** * Created by fengyuwusong on 2017/10/1 23:45. */ @Api(value = "分类管理接口") @RestController @RequestMapping("/category") public class CategoryController { @Autowired private CategoryService categoryService; @ApiOperation("查找全部") @GetMapping public Result findAll() { return categoryService.findAll(); } @Admin @ApiOperation("更新") @PutMapping
// Path: src/main/java/cn/niriqiang/blog/domain/Category.java // @ApiModel // @Data // public class Category { // @ApiModelProperty(value = "ID") // private Integer id; // @ApiModelProperty(value = "分类名") // @NotNull(message = "类型名称不能为空") // private String categoryName; // @ApiModelProperty(value = "分类描述") // @NotNull(message = "描述不能为空") // private String description; // } // // Path: src/main/java/cn/niriqiang/blog/dto/Result.java // public class Result<T> { // // // private Integer code; // // private String message; // // private T data; // // @Override // public String toString() { // return "Result{" + // "code=" + code + // ", message='" + message + '\'' + // ", data=" + data + // '}'; // } // // public Result(Integer code, String message) { // this.code = code; // this.message = message; // } // // public Result(Integer code, String message, T data) { // this.code = code; // this.message = message; // this.data = data; // } // // public Integer getCode() { // return code; // } // // public void setCode(Integer code) { // this.code = code; // } // // public String getMessage() { // return message; // } // // public void setMessage(String message) { // this.message = message; // } // // public T getData() { // return data; // } // // public void setData(T data) { // this.data = data; // } // } // // Path: src/main/java/cn/niriqiang/blog/exception/CategoryException.java // public class CategoryException extends Exception { // public CategoryException(ResultEnum resultEnum) { // super(resultEnum); // } // // public CategoryException(String message, Integer code) { // super(message, code); // } // // } // // Path: src/main/java/cn/niriqiang/blog/service/CategoryService.java // @Service // public class CategoryService { // @Autowired // private CategoryMapper mapper; // // @Autowired // private ArticleService articleService; // // public Result insertCategory(Category category) { // try { // findByCategoryName(category.getCategoryName()); // } catch (CategoryException e) { // mapper.insert(category); // return ResultUtil.success(ResultEnum.OK, category); // } // throw new CategoryException(ResultEnum.ADD_EXITS); // } // // public Result updateCategory(Category category) { // // 查找id是否存在 // Category res = (Category) findOne(category.getId()).getData(); // // 如果CategoryName是需要修改项 查找更改的categoryName是否已经存在 // if (!category.getCategoryName().equals(res.getCategoryName())) { // try { // findByCategoryName(category.getCategoryName()); // } catch (CategoryException e) { // mapper.update(category); // return ResultUtil.success(ResultEnum.OK, category); // } // throw new CategoryException(ResultEnum.ADD_EXITS); // } // mapper.update(category); // return ResultUtil.success(ResultEnum.OK, category); // } // // public Result findOne(int id) { // Category category = mapper.findOne(id); // if (category != null) { // return ResultUtil.success(ResultEnum.OK, category); // } else { // throw new CategoryException(ResultEnum.NOT_FOUND); // } // } // // public Result findByCategoryName(String categoryName) { // Category category = mapper.findByCategoryName(categoryName); // if (category != null) { // return ResultUtil.success(ResultEnum.OK, category); // } else { // throw new CategoryException(ResultEnum.NOT_FOUND); // } // } // // public Result findAll() { // List<Category> categoryPage = mapper.findAll(); // return ResultUtil.success(ResultEnum.OK, categoryPage); // } // // public Result delete(int id) { // findOne(id); // // 查找该分类下的文章是否存在 若存在则不能删除 // try { // articleService.findByCategory(1, id); // } catch (ArticleException e) { // mapper.delete(id); // return ResultUtil.success(ResultEnum.OK, id); // } // throw new CategoryException(ResultEnum.DELETE_FALSE); // } // } // Path: src/main/java/cn/niriqiang/blog/controller/CategoryController.java import cn.niriqiang.blog.annotation.Admin; import cn.niriqiang.blog.domain.Category; import cn.niriqiang.blog.dto.Result; import cn.niriqiang.blog.exception.CategoryException; import cn.niriqiang.blog.service.CategoryService; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.validation.Errors; import org.springframework.web.bind.annotation.*; import javax.validation.Valid; package cn.niriqiang.blog.controller; /** * Created by fengyuwusong on 2017/10/1 23:45. */ @Api(value = "分类管理接口") @RestController @RequestMapping("/category") public class CategoryController { @Autowired private CategoryService categoryService; @ApiOperation("查找全部") @GetMapping public Result findAll() { return categoryService.findAll(); } @Admin @ApiOperation("更新") @PutMapping
public Result update(@RequestBody Category category) {
fengyuwusong/blog
src/main/java/cn/niriqiang/blog/handle/ExceptionHandle.java
// Path: src/main/java/cn/niriqiang/blog/dto/Result.java // public class Result<T> { // // // private Integer code; // // private String message; // // private T data; // // @Override // public String toString() { // return "Result{" + // "code=" + code + // ", message='" + message + '\'' + // ", data=" + data + // '}'; // } // // public Result(Integer code, String message) { // this.code = code; // this.message = message; // } // // public Result(Integer code, String message, T data) { // this.code = code; // this.message = message; // this.data = data; // } // // public Integer getCode() { // return code; // } // // public void setCode(Integer code) { // this.code = code; // } // // public String getMessage() { // return message; // } // // public void setMessage(String message) { // this.message = message; // } // // public T getData() { // return data; // } // // public void setData(T data) { // this.data = data; // } // } // // Path: src/main/java/cn/niriqiang/blog/enums/ResultEnum.java // @ApiModel // public enum ResultEnum { // OK(200, "成功"), // NOT_BLANK(0, "不能为空"), // UNKNOW_ERROR(-1, "未知错误"), // NOT_FOUND(-2, "目标未找到"), // ADD_EXITS(-3, "目标已存在"), // DELETE_FALSE(-4, "不能删除相关文章还存在的分类"), // CURRENT_PAGE_NOT_NULL(-5, "页码不能为空"), // ERROR_NAME_PW(-6, "用户名密码错误"), // NOT_LOGIN(-7, "还没登陆!"); // // ResultEnum(Integer code, String message) { // this.code = code; // this.message = message; // } // // public Integer getCode() { // return code; // } // // public String getMessage() { // return message; // } // // @Override // public String toString() { // return "ResultEnum{" + // "code=" + code + // ", message='" + message + '\'' + // '}'; // } // // Integer code; // String message; // } // // Path: src/main/java/cn/niriqiang/blog/exception/ArticleException.java // public class ArticleException extends Exception { // // public ArticleException(ResultEnum resultEnum) { // super(resultEnum); // } // // public ArticleException(String message, Integer code) { // super(message, code); // } // // } // // Path: src/main/java/cn/niriqiang/blog/exception/CategoryException.java // public class CategoryException extends Exception { // public CategoryException(ResultEnum resultEnum) { // super(resultEnum); // } // // public CategoryException(String message, Integer code) { // super(message, code); // } // // } // // Path: src/main/java/cn/niriqiang/blog/exception/LoginException.java // public class LoginException extends Exception { // public LoginException(String message, Integer code) { // super(message, code); // } // // public LoginException(ResultEnum resultEnum) { // super(resultEnum); // } // } // // Path: src/main/java/cn/niriqiang/blog/exception/TagException.java // public class TagException extends Exception { // // public TagException(ResultEnum resultEnum) { // super(resultEnum); // } // // public TagException(String message, Integer code) { // super(message, code); // } // } // // Path: src/main/java/cn/niriqiang/blog/util/ResultUtil.java // public class ResultUtil { // public static <T> Result<T> success(ResultEnum resultEnum, T t) { // return new Result(resultEnum.getCode(), resultEnum.getMessage(), t); // } // // public static Result error(Integer code, String message) { // return new Result(code, message); // } // // public static Result error(ResultEnum resultEnum) { // return new Result(resultEnum.getCode(), resultEnum.getMessage()); // } // }
import cn.niriqiang.blog.dto.Result; import cn.niriqiang.blog.enums.ResultEnum; import cn.niriqiang.blog.exception.ArticleException; import cn.niriqiang.blog.exception.CategoryException; import cn.niriqiang.blog.exception.LoginException; import cn.niriqiang.blog.exception.TagException; import cn.niriqiang.blog.util.ResultUtil; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.web.bind.annotation.ControllerAdvice; import org.springframework.web.bind.annotation.ExceptionHandler; import org.springframework.web.bind.annotation.ResponseBody;
package cn.niriqiang.blog.handle; /** * Created by fengyuwusong on 2017/9/24 23:17. */ @ControllerAdvice public class ExceptionHandle { private final static Logger logger = LoggerFactory.getLogger(ExceptionHandle.class); @ExceptionHandler(value = Exception.class) @ResponseBody
// Path: src/main/java/cn/niriqiang/blog/dto/Result.java // public class Result<T> { // // // private Integer code; // // private String message; // // private T data; // // @Override // public String toString() { // return "Result{" + // "code=" + code + // ", message='" + message + '\'' + // ", data=" + data + // '}'; // } // // public Result(Integer code, String message) { // this.code = code; // this.message = message; // } // // public Result(Integer code, String message, T data) { // this.code = code; // this.message = message; // this.data = data; // } // // public Integer getCode() { // return code; // } // // public void setCode(Integer code) { // this.code = code; // } // // public String getMessage() { // return message; // } // // public void setMessage(String message) { // this.message = message; // } // // public T getData() { // return data; // } // // public void setData(T data) { // this.data = data; // } // } // // Path: src/main/java/cn/niriqiang/blog/enums/ResultEnum.java // @ApiModel // public enum ResultEnum { // OK(200, "成功"), // NOT_BLANK(0, "不能为空"), // UNKNOW_ERROR(-1, "未知错误"), // NOT_FOUND(-2, "目标未找到"), // ADD_EXITS(-3, "目标已存在"), // DELETE_FALSE(-4, "不能删除相关文章还存在的分类"), // CURRENT_PAGE_NOT_NULL(-5, "页码不能为空"), // ERROR_NAME_PW(-6, "用户名密码错误"), // NOT_LOGIN(-7, "还没登陆!"); // // ResultEnum(Integer code, String message) { // this.code = code; // this.message = message; // } // // public Integer getCode() { // return code; // } // // public String getMessage() { // return message; // } // // @Override // public String toString() { // return "ResultEnum{" + // "code=" + code + // ", message='" + message + '\'' + // '}'; // } // // Integer code; // String message; // } // // Path: src/main/java/cn/niriqiang/blog/exception/ArticleException.java // public class ArticleException extends Exception { // // public ArticleException(ResultEnum resultEnum) { // super(resultEnum); // } // // public ArticleException(String message, Integer code) { // super(message, code); // } // // } // // Path: src/main/java/cn/niriqiang/blog/exception/CategoryException.java // public class CategoryException extends Exception { // public CategoryException(ResultEnum resultEnum) { // super(resultEnum); // } // // public CategoryException(String message, Integer code) { // super(message, code); // } // // } // // Path: src/main/java/cn/niriqiang/blog/exception/LoginException.java // public class LoginException extends Exception { // public LoginException(String message, Integer code) { // super(message, code); // } // // public LoginException(ResultEnum resultEnum) { // super(resultEnum); // } // } // // Path: src/main/java/cn/niriqiang/blog/exception/TagException.java // public class TagException extends Exception { // // public TagException(ResultEnum resultEnum) { // super(resultEnum); // } // // public TagException(String message, Integer code) { // super(message, code); // } // } // // Path: src/main/java/cn/niriqiang/blog/util/ResultUtil.java // public class ResultUtil { // public static <T> Result<T> success(ResultEnum resultEnum, T t) { // return new Result(resultEnum.getCode(), resultEnum.getMessage(), t); // } // // public static Result error(Integer code, String message) { // return new Result(code, message); // } // // public static Result error(ResultEnum resultEnum) { // return new Result(resultEnum.getCode(), resultEnum.getMessage()); // } // } // Path: src/main/java/cn/niriqiang/blog/handle/ExceptionHandle.java import cn.niriqiang.blog.dto.Result; import cn.niriqiang.blog.enums.ResultEnum; import cn.niriqiang.blog.exception.ArticleException; import cn.niriqiang.blog.exception.CategoryException; import cn.niriqiang.blog.exception.LoginException; import cn.niriqiang.blog.exception.TagException; import cn.niriqiang.blog.util.ResultUtil; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.web.bind.annotation.ControllerAdvice; import org.springframework.web.bind.annotation.ExceptionHandler; import org.springframework.web.bind.annotation.ResponseBody; package cn.niriqiang.blog.handle; /** * Created by fengyuwusong on 2017/9/24 23:17. */ @ControllerAdvice public class ExceptionHandle { private final static Logger logger = LoggerFactory.getLogger(ExceptionHandle.class); @ExceptionHandler(value = Exception.class) @ResponseBody
public Result handle(Exception e) {
fengyuwusong/blog
src/main/java/cn/niriqiang/blog/handle/ExceptionHandle.java
// Path: src/main/java/cn/niriqiang/blog/dto/Result.java // public class Result<T> { // // // private Integer code; // // private String message; // // private T data; // // @Override // public String toString() { // return "Result{" + // "code=" + code + // ", message='" + message + '\'' + // ", data=" + data + // '}'; // } // // public Result(Integer code, String message) { // this.code = code; // this.message = message; // } // // public Result(Integer code, String message, T data) { // this.code = code; // this.message = message; // this.data = data; // } // // public Integer getCode() { // return code; // } // // public void setCode(Integer code) { // this.code = code; // } // // public String getMessage() { // return message; // } // // public void setMessage(String message) { // this.message = message; // } // // public T getData() { // return data; // } // // public void setData(T data) { // this.data = data; // } // } // // Path: src/main/java/cn/niriqiang/blog/enums/ResultEnum.java // @ApiModel // public enum ResultEnum { // OK(200, "成功"), // NOT_BLANK(0, "不能为空"), // UNKNOW_ERROR(-1, "未知错误"), // NOT_FOUND(-2, "目标未找到"), // ADD_EXITS(-3, "目标已存在"), // DELETE_FALSE(-4, "不能删除相关文章还存在的分类"), // CURRENT_PAGE_NOT_NULL(-5, "页码不能为空"), // ERROR_NAME_PW(-6, "用户名密码错误"), // NOT_LOGIN(-7, "还没登陆!"); // // ResultEnum(Integer code, String message) { // this.code = code; // this.message = message; // } // // public Integer getCode() { // return code; // } // // public String getMessage() { // return message; // } // // @Override // public String toString() { // return "ResultEnum{" + // "code=" + code + // ", message='" + message + '\'' + // '}'; // } // // Integer code; // String message; // } // // Path: src/main/java/cn/niriqiang/blog/exception/ArticleException.java // public class ArticleException extends Exception { // // public ArticleException(ResultEnum resultEnum) { // super(resultEnum); // } // // public ArticleException(String message, Integer code) { // super(message, code); // } // // } // // Path: src/main/java/cn/niriqiang/blog/exception/CategoryException.java // public class CategoryException extends Exception { // public CategoryException(ResultEnum resultEnum) { // super(resultEnum); // } // // public CategoryException(String message, Integer code) { // super(message, code); // } // // } // // Path: src/main/java/cn/niriqiang/blog/exception/LoginException.java // public class LoginException extends Exception { // public LoginException(String message, Integer code) { // super(message, code); // } // // public LoginException(ResultEnum resultEnum) { // super(resultEnum); // } // } // // Path: src/main/java/cn/niriqiang/blog/exception/TagException.java // public class TagException extends Exception { // // public TagException(ResultEnum resultEnum) { // super(resultEnum); // } // // public TagException(String message, Integer code) { // super(message, code); // } // } // // Path: src/main/java/cn/niriqiang/blog/util/ResultUtil.java // public class ResultUtil { // public static <T> Result<T> success(ResultEnum resultEnum, T t) { // return new Result(resultEnum.getCode(), resultEnum.getMessage(), t); // } // // public static Result error(Integer code, String message) { // return new Result(code, message); // } // // public static Result error(ResultEnum resultEnum) { // return new Result(resultEnum.getCode(), resultEnum.getMessage()); // } // }
import cn.niriqiang.blog.dto.Result; import cn.niriqiang.blog.enums.ResultEnum; import cn.niriqiang.blog.exception.ArticleException; import cn.niriqiang.blog.exception.CategoryException; import cn.niriqiang.blog.exception.LoginException; import cn.niriqiang.blog.exception.TagException; import cn.niriqiang.blog.util.ResultUtil; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.web.bind.annotation.ControllerAdvice; import org.springframework.web.bind.annotation.ExceptionHandler; import org.springframework.web.bind.annotation.ResponseBody;
package cn.niriqiang.blog.handle; /** * Created by fengyuwusong on 2017/9/24 23:17. */ @ControllerAdvice public class ExceptionHandle { private final static Logger logger = LoggerFactory.getLogger(ExceptionHandle.class); @ExceptionHandler(value = Exception.class) @ResponseBody public Result handle(Exception e) {
// Path: src/main/java/cn/niriqiang/blog/dto/Result.java // public class Result<T> { // // // private Integer code; // // private String message; // // private T data; // // @Override // public String toString() { // return "Result{" + // "code=" + code + // ", message='" + message + '\'' + // ", data=" + data + // '}'; // } // // public Result(Integer code, String message) { // this.code = code; // this.message = message; // } // // public Result(Integer code, String message, T data) { // this.code = code; // this.message = message; // this.data = data; // } // // public Integer getCode() { // return code; // } // // public void setCode(Integer code) { // this.code = code; // } // // public String getMessage() { // return message; // } // // public void setMessage(String message) { // this.message = message; // } // // public T getData() { // return data; // } // // public void setData(T data) { // this.data = data; // } // } // // Path: src/main/java/cn/niriqiang/blog/enums/ResultEnum.java // @ApiModel // public enum ResultEnum { // OK(200, "成功"), // NOT_BLANK(0, "不能为空"), // UNKNOW_ERROR(-1, "未知错误"), // NOT_FOUND(-2, "目标未找到"), // ADD_EXITS(-3, "目标已存在"), // DELETE_FALSE(-4, "不能删除相关文章还存在的分类"), // CURRENT_PAGE_NOT_NULL(-5, "页码不能为空"), // ERROR_NAME_PW(-6, "用户名密码错误"), // NOT_LOGIN(-7, "还没登陆!"); // // ResultEnum(Integer code, String message) { // this.code = code; // this.message = message; // } // // public Integer getCode() { // return code; // } // // public String getMessage() { // return message; // } // // @Override // public String toString() { // return "ResultEnum{" + // "code=" + code + // ", message='" + message + '\'' + // '}'; // } // // Integer code; // String message; // } // // Path: src/main/java/cn/niriqiang/blog/exception/ArticleException.java // public class ArticleException extends Exception { // // public ArticleException(ResultEnum resultEnum) { // super(resultEnum); // } // // public ArticleException(String message, Integer code) { // super(message, code); // } // // } // // Path: src/main/java/cn/niriqiang/blog/exception/CategoryException.java // public class CategoryException extends Exception { // public CategoryException(ResultEnum resultEnum) { // super(resultEnum); // } // // public CategoryException(String message, Integer code) { // super(message, code); // } // // } // // Path: src/main/java/cn/niriqiang/blog/exception/LoginException.java // public class LoginException extends Exception { // public LoginException(String message, Integer code) { // super(message, code); // } // // public LoginException(ResultEnum resultEnum) { // super(resultEnum); // } // } // // Path: src/main/java/cn/niriqiang/blog/exception/TagException.java // public class TagException extends Exception { // // public TagException(ResultEnum resultEnum) { // super(resultEnum); // } // // public TagException(String message, Integer code) { // super(message, code); // } // } // // Path: src/main/java/cn/niriqiang/blog/util/ResultUtil.java // public class ResultUtil { // public static <T> Result<T> success(ResultEnum resultEnum, T t) { // return new Result(resultEnum.getCode(), resultEnum.getMessage(), t); // } // // public static Result error(Integer code, String message) { // return new Result(code, message); // } // // public static Result error(ResultEnum resultEnum) { // return new Result(resultEnum.getCode(), resultEnum.getMessage()); // } // } // Path: src/main/java/cn/niriqiang/blog/handle/ExceptionHandle.java import cn.niriqiang.blog.dto.Result; import cn.niriqiang.blog.enums.ResultEnum; import cn.niriqiang.blog.exception.ArticleException; import cn.niriqiang.blog.exception.CategoryException; import cn.niriqiang.blog.exception.LoginException; import cn.niriqiang.blog.exception.TagException; import cn.niriqiang.blog.util.ResultUtil; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.web.bind.annotation.ControllerAdvice; import org.springframework.web.bind.annotation.ExceptionHandler; import org.springframework.web.bind.annotation.ResponseBody; package cn.niriqiang.blog.handle; /** * Created by fengyuwusong on 2017/9/24 23:17. */ @ControllerAdvice public class ExceptionHandle { private final static Logger logger = LoggerFactory.getLogger(ExceptionHandle.class); @ExceptionHandler(value = Exception.class) @ResponseBody public Result handle(Exception e) {
if (e instanceof ArticleException) {
fengyuwusong/blog
src/main/java/cn/niriqiang/blog/handle/ExceptionHandle.java
// Path: src/main/java/cn/niriqiang/blog/dto/Result.java // public class Result<T> { // // // private Integer code; // // private String message; // // private T data; // // @Override // public String toString() { // return "Result{" + // "code=" + code + // ", message='" + message + '\'' + // ", data=" + data + // '}'; // } // // public Result(Integer code, String message) { // this.code = code; // this.message = message; // } // // public Result(Integer code, String message, T data) { // this.code = code; // this.message = message; // this.data = data; // } // // public Integer getCode() { // return code; // } // // public void setCode(Integer code) { // this.code = code; // } // // public String getMessage() { // return message; // } // // public void setMessage(String message) { // this.message = message; // } // // public T getData() { // return data; // } // // public void setData(T data) { // this.data = data; // } // } // // Path: src/main/java/cn/niriqiang/blog/enums/ResultEnum.java // @ApiModel // public enum ResultEnum { // OK(200, "成功"), // NOT_BLANK(0, "不能为空"), // UNKNOW_ERROR(-1, "未知错误"), // NOT_FOUND(-2, "目标未找到"), // ADD_EXITS(-3, "目标已存在"), // DELETE_FALSE(-4, "不能删除相关文章还存在的分类"), // CURRENT_PAGE_NOT_NULL(-5, "页码不能为空"), // ERROR_NAME_PW(-6, "用户名密码错误"), // NOT_LOGIN(-7, "还没登陆!"); // // ResultEnum(Integer code, String message) { // this.code = code; // this.message = message; // } // // public Integer getCode() { // return code; // } // // public String getMessage() { // return message; // } // // @Override // public String toString() { // return "ResultEnum{" + // "code=" + code + // ", message='" + message + '\'' + // '}'; // } // // Integer code; // String message; // } // // Path: src/main/java/cn/niriqiang/blog/exception/ArticleException.java // public class ArticleException extends Exception { // // public ArticleException(ResultEnum resultEnum) { // super(resultEnum); // } // // public ArticleException(String message, Integer code) { // super(message, code); // } // // } // // Path: src/main/java/cn/niriqiang/blog/exception/CategoryException.java // public class CategoryException extends Exception { // public CategoryException(ResultEnum resultEnum) { // super(resultEnum); // } // // public CategoryException(String message, Integer code) { // super(message, code); // } // // } // // Path: src/main/java/cn/niriqiang/blog/exception/LoginException.java // public class LoginException extends Exception { // public LoginException(String message, Integer code) { // super(message, code); // } // // public LoginException(ResultEnum resultEnum) { // super(resultEnum); // } // } // // Path: src/main/java/cn/niriqiang/blog/exception/TagException.java // public class TagException extends Exception { // // public TagException(ResultEnum resultEnum) { // super(resultEnum); // } // // public TagException(String message, Integer code) { // super(message, code); // } // } // // Path: src/main/java/cn/niriqiang/blog/util/ResultUtil.java // public class ResultUtil { // public static <T> Result<T> success(ResultEnum resultEnum, T t) { // return new Result(resultEnum.getCode(), resultEnum.getMessage(), t); // } // // public static Result error(Integer code, String message) { // return new Result(code, message); // } // // public static Result error(ResultEnum resultEnum) { // return new Result(resultEnum.getCode(), resultEnum.getMessage()); // } // }
import cn.niriqiang.blog.dto.Result; import cn.niriqiang.blog.enums.ResultEnum; import cn.niriqiang.blog.exception.ArticleException; import cn.niriqiang.blog.exception.CategoryException; import cn.niriqiang.blog.exception.LoginException; import cn.niriqiang.blog.exception.TagException; import cn.niriqiang.blog.util.ResultUtil; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.web.bind.annotation.ControllerAdvice; import org.springframework.web.bind.annotation.ExceptionHandler; import org.springframework.web.bind.annotation.ResponseBody;
package cn.niriqiang.blog.handle; /** * Created by fengyuwusong on 2017/9/24 23:17. */ @ControllerAdvice public class ExceptionHandle { private final static Logger logger = LoggerFactory.getLogger(ExceptionHandle.class); @ExceptionHandler(value = Exception.class) @ResponseBody public Result handle(Exception e) { if (e instanceof ArticleException) { logger.error("ArticleException:" + e.getMessage()); ArticleException exception = (ArticleException) e;
// Path: src/main/java/cn/niriqiang/blog/dto/Result.java // public class Result<T> { // // // private Integer code; // // private String message; // // private T data; // // @Override // public String toString() { // return "Result{" + // "code=" + code + // ", message='" + message + '\'' + // ", data=" + data + // '}'; // } // // public Result(Integer code, String message) { // this.code = code; // this.message = message; // } // // public Result(Integer code, String message, T data) { // this.code = code; // this.message = message; // this.data = data; // } // // public Integer getCode() { // return code; // } // // public void setCode(Integer code) { // this.code = code; // } // // public String getMessage() { // return message; // } // // public void setMessage(String message) { // this.message = message; // } // // public T getData() { // return data; // } // // public void setData(T data) { // this.data = data; // } // } // // Path: src/main/java/cn/niriqiang/blog/enums/ResultEnum.java // @ApiModel // public enum ResultEnum { // OK(200, "成功"), // NOT_BLANK(0, "不能为空"), // UNKNOW_ERROR(-1, "未知错误"), // NOT_FOUND(-2, "目标未找到"), // ADD_EXITS(-3, "目标已存在"), // DELETE_FALSE(-4, "不能删除相关文章还存在的分类"), // CURRENT_PAGE_NOT_NULL(-5, "页码不能为空"), // ERROR_NAME_PW(-6, "用户名密码错误"), // NOT_LOGIN(-7, "还没登陆!"); // // ResultEnum(Integer code, String message) { // this.code = code; // this.message = message; // } // // public Integer getCode() { // return code; // } // // public String getMessage() { // return message; // } // // @Override // public String toString() { // return "ResultEnum{" + // "code=" + code + // ", message='" + message + '\'' + // '}'; // } // // Integer code; // String message; // } // // Path: src/main/java/cn/niriqiang/blog/exception/ArticleException.java // public class ArticleException extends Exception { // // public ArticleException(ResultEnum resultEnum) { // super(resultEnum); // } // // public ArticleException(String message, Integer code) { // super(message, code); // } // // } // // Path: src/main/java/cn/niriqiang/blog/exception/CategoryException.java // public class CategoryException extends Exception { // public CategoryException(ResultEnum resultEnum) { // super(resultEnum); // } // // public CategoryException(String message, Integer code) { // super(message, code); // } // // } // // Path: src/main/java/cn/niriqiang/blog/exception/LoginException.java // public class LoginException extends Exception { // public LoginException(String message, Integer code) { // super(message, code); // } // // public LoginException(ResultEnum resultEnum) { // super(resultEnum); // } // } // // Path: src/main/java/cn/niriqiang/blog/exception/TagException.java // public class TagException extends Exception { // // public TagException(ResultEnum resultEnum) { // super(resultEnum); // } // // public TagException(String message, Integer code) { // super(message, code); // } // } // // Path: src/main/java/cn/niriqiang/blog/util/ResultUtil.java // public class ResultUtil { // public static <T> Result<T> success(ResultEnum resultEnum, T t) { // return new Result(resultEnum.getCode(), resultEnum.getMessage(), t); // } // // public static Result error(Integer code, String message) { // return new Result(code, message); // } // // public static Result error(ResultEnum resultEnum) { // return new Result(resultEnum.getCode(), resultEnum.getMessage()); // } // } // Path: src/main/java/cn/niriqiang/blog/handle/ExceptionHandle.java import cn.niriqiang.blog.dto.Result; import cn.niriqiang.blog.enums.ResultEnum; import cn.niriqiang.blog.exception.ArticleException; import cn.niriqiang.blog.exception.CategoryException; import cn.niriqiang.blog.exception.LoginException; import cn.niriqiang.blog.exception.TagException; import cn.niriqiang.blog.util.ResultUtil; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.web.bind.annotation.ControllerAdvice; import org.springframework.web.bind.annotation.ExceptionHandler; import org.springframework.web.bind.annotation.ResponseBody; package cn.niriqiang.blog.handle; /** * Created by fengyuwusong on 2017/9/24 23:17. */ @ControllerAdvice public class ExceptionHandle { private final static Logger logger = LoggerFactory.getLogger(ExceptionHandle.class); @ExceptionHandler(value = Exception.class) @ResponseBody public Result handle(Exception e) { if (e instanceof ArticleException) { logger.error("ArticleException:" + e.getMessage()); ArticleException exception = (ArticleException) e;
return ResultUtil.error(exception.getCode(), exception.getMessage());
fengyuwusong/blog
src/main/java/cn/niriqiang/blog/handle/ExceptionHandle.java
// Path: src/main/java/cn/niriqiang/blog/dto/Result.java // public class Result<T> { // // // private Integer code; // // private String message; // // private T data; // // @Override // public String toString() { // return "Result{" + // "code=" + code + // ", message='" + message + '\'' + // ", data=" + data + // '}'; // } // // public Result(Integer code, String message) { // this.code = code; // this.message = message; // } // // public Result(Integer code, String message, T data) { // this.code = code; // this.message = message; // this.data = data; // } // // public Integer getCode() { // return code; // } // // public void setCode(Integer code) { // this.code = code; // } // // public String getMessage() { // return message; // } // // public void setMessage(String message) { // this.message = message; // } // // public T getData() { // return data; // } // // public void setData(T data) { // this.data = data; // } // } // // Path: src/main/java/cn/niriqiang/blog/enums/ResultEnum.java // @ApiModel // public enum ResultEnum { // OK(200, "成功"), // NOT_BLANK(0, "不能为空"), // UNKNOW_ERROR(-1, "未知错误"), // NOT_FOUND(-2, "目标未找到"), // ADD_EXITS(-3, "目标已存在"), // DELETE_FALSE(-4, "不能删除相关文章还存在的分类"), // CURRENT_PAGE_NOT_NULL(-5, "页码不能为空"), // ERROR_NAME_PW(-6, "用户名密码错误"), // NOT_LOGIN(-7, "还没登陆!"); // // ResultEnum(Integer code, String message) { // this.code = code; // this.message = message; // } // // public Integer getCode() { // return code; // } // // public String getMessage() { // return message; // } // // @Override // public String toString() { // return "ResultEnum{" + // "code=" + code + // ", message='" + message + '\'' + // '}'; // } // // Integer code; // String message; // } // // Path: src/main/java/cn/niriqiang/blog/exception/ArticleException.java // public class ArticleException extends Exception { // // public ArticleException(ResultEnum resultEnum) { // super(resultEnum); // } // // public ArticleException(String message, Integer code) { // super(message, code); // } // // } // // Path: src/main/java/cn/niriqiang/blog/exception/CategoryException.java // public class CategoryException extends Exception { // public CategoryException(ResultEnum resultEnum) { // super(resultEnum); // } // // public CategoryException(String message, Integer code) { // super(message, code); // } // // } // // Path: src/main/java/cn/niriqiang/blog/exception/LoginException.java // public class LoginException extends Exception { // public LoginException(String message, Integer code) { // super(message, code); // } // // public LoginException(ResultEnum resultEnum) { // super(resultEnum); // } // } // // Path: src/main/java/cn/niriqiang/blog/exception/TagException.java // public class TagException extends Exception { // // public TagException(ResultEnum resultEnum) { // super(resultEnum); // } // // public TagException(String message, Integer code) { // super(message, code); // } // } // // Path: src/main/java/cn/niriqiang/blog/util/ResultUtil.java // public class ResultUtil { // public static <T> Result<T> success(ResultEnum resultEnum, T t) { // return new Result(resultEnum.getCode(), resultEnum.getMessage(), t); // } // // public static Result error(Integer code, String message) { // return new Result(code, message); // } // // public static Result error(ResultEnum resultEnum) { // return new Result(resultEnum.getCode(), resultEnum.getMessage()); // } // }
import cn.niriqiang.blog.dto.Result; import cn.niriqiang.blog.enums.ResultEnum; import cn.niriqiang.blog.exception.ArticleException; import cn.niriqiang.blog.exception.CategoryException; import cn.niriqiang.blog.exception.LoginException; import cn.niriqiang.blog.exception.TagException; import cn.niriqiang.blog.util.ResultUtil; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.web.bind.annotation.ControllerAdvice; import org.springframework.web.bind.annotation.ExceptionHandler; import org.springframework.web.bind.annotation.ResponseBody;
package cn.niriqiang.blog.handle; /** * Created by fengyuwusong on 2017/9/24 23:17. */ @ControllerAdvice public class ExceptionHandle { private final static Logger logger = LoggerFactory.getLogger(ExceptionHandle.class); @ExceptionHandler(value = Exception.class) @ResponseBody public Result handle(Exception e) { if (e instanceof ArticleException) { logger.error("ArticleException:" + e.getMessage()); ArticleException exception = (ArticleException) e; return ResultUtil.error(exception.getCode(), exception.getMessage());
// Path: src/main/java/cn/niriqiang/blog/dto/Result.java // public class Result<T> { // // // private Integer code; // // private String message; // // private T data; // // @Override // public String toString() { // return "Result{" + // "code=" + code + // ", message='" + message + '\'' + // ", data=" + data + // '}'; // } // // public Result(Integer code, String message) { // this.code = code; // this.message = message; // } // // public Result(Integer code, String message, T data) { // this.code = code; // this.message = message; // this.data = data; // } // // public Integer getCode() { // return code; // } // // public void setCode(Integer code) { // this.code = code; // } // // public String getMessage() { // return message; // } // // public void setMessage(String message) { // this.message = message; // } // // public T getData() { // return data; // } // // public void setData(T data) { // this.data = data; // } // } // // Path: src/main/java/cn/niriqiang/blog/enums/ResultEnum.java // @ApiModel // public enum ResultEnum { // OK(200, "成功"), // NOT_BLANK(0, "不能为空"), // UNKNOW_ERROR(-1, "未知错误"), // NOT_FOUND(-2, "目标未找到"), // ADD_EXITS(-3, "目标已存在"), // DELETE_FALSE(-4, "不能删除相关文章还存在的分类"), // CURRENT_PAGE_NOT_NULL(-5, "页码不能为空"), // ERROR_NAME_PW(-6, "用户名密码错误"), // NOT_LOGIN(-7, "还没登陆!"); // // ResultEnum(Integer code, String message) { // this.code = code; // this.message = message; // } // // public Integer getCode() { // return code; // } // // public String getMessage() { // return message; // } // // @Override // public String toString() { // return "ResultEnum{" + // "code=" + code + // ", message='" + message + '\'' + // '}'; // } // // Integer code; // String message; // } // // Path: src/main/java/cn/niriqiang/blog/exception/ArticleException.java // public class ArticleException extends Exception { // // public ArticleException(ResultEnum resultEnum) { // super(resultEnum); // } // // public ArticleException(String message, Integer code) { // super(message, code); // } // // } // // Path: src/main/java/cn/niriqiang/blog/exception/CategoryException.java // public class CategoryException extends Exception { // public CategoryException(ResultEnum resultEnum) { // super(resultEnum); // } // // public CategoryException(String message, Integer code) { // super(message, code); // } // // } // // Path: src/main/java/cn/niriqiang/blog/exception/LoginException.java // public class LoginException extends Exception { // public LoginException(String message, Integer code) { // super(message, code); // } // // public LoginException(ResultEnum resultEnum) { // super(resultEnum); // } // } // // Path: src/main/java/cn/niriqiang/blog/exception/TagException.java // public class TagException extends Exception { // // public TagException(ResultEnum resultEnum) { // super(resultEnum); // } // // public TagException(String message, Integer code) { // super(message, code); // } // } // // Path: src/main/java/cn/niriqiang/blog/util/ResultUtil.java // public class ResultUtil { // public static <T> Result<T> success(ResultEnum resultEnum, T t) { // return new Result(resultEnum.getCode(), resultEnum.getMessage(), t); // } // // public static Result error(Integer code, String message) { // return new Result(code, message); // } // // public static Result error(ResultEnum resultEnum) { // return new Result(resultEnum.getCode(), resultEnum.getMessage()); // } // } // Path: src/main/java/cn/niriqiang/blog/handle/ExceptionHandle.java import cn.niriqiang.blog.dto.Result; import cn.niriqiang.blog.enums.ResultEnum; import cn.niriqiang.blog.exception.ArticleException; import cn.niriqiang.blog.exception.CategoryException; import cn.niriqiang.blog.exception.LoginException; import cn.niriqiang.blog.exception.TagException; import cn.niriqiang.blog.util.ResultUtil; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.web.bind.annotation.ControllerAdvice; import org.springframework.web.bind.annotation.ExceptionHandler; import org.springframework.web.bind.annotation.ResponseBody; package cn.niriqiang.blog.handle; /** * Created by fengyuwusong on 2017/9/24 23:17. */ @ControllerAdvice public class ExceptionHandle { private final static Logger logger = LoggerFactory.getLogger(ExceptionHandle.class); @ExceptionHandler(value = Exception.class) @ResponseBody public Result handle(Exception e) { if (e instanceof ArticleException) { logger.error("ArticleException:" + e.getMessage()); ArticleException exception = (ArticleException) e; return ResultUtil.error(exception.getCode(), exception.getMessage());
} else if (e instanceof CategoryException) {
fengyuwusong/blog
src/main/java/cn/niriqiang/blog/handle/ExceptionHandle.java
// Path: src/main/java/cn/niriqiang/blog/dto/Result.java // public class Result<T> { // // // private Integer code; // // private String message; // // private T data; // // @Override // public String toString() { // return "Result{" + // "code=" + code + // ", message='" + message + '\'' + // ", data=" + data + // '}'; // } // // public Result(Integer code, String message) { // this.code = code; // this.message = message; // } // // public Result(Integer code, String message, T data) { // this.code = code; // this.message = message; // this.data = data; // } // // public Integer getCode() { // return code; // } // // public void setCode(Integer code) { // this.code = code; // } // // public String getMessage() { // return message; // } // // public void setMessage(String message) { // this.message = message; // } // // public T getData() { // return data; // } // // public void setData(T data) { // this.data = data; // } // } // // Path: src/main/java/cn/niriqiang/blog/enums/ResultEnum.java // @ApiModel // public enum ResultEnum { // OK(200, "成功"), // NOT_BLANK(0, "不能为空"), // UNKNOW_ERROR(-1, "未知错误"), // NOT_FOUND(-2, "目标未找到"), // ADD_EXITS(-3, "目标已存在"), // DELETE_FALSE(-4, "不能删除相关文章还存在的分类"), // CURRENT_PAGE_NOT_NULL(-5, "页码不能为空"), // ERROR_NAME_PW(-6, "用户名密码错误"), // NOT_LOGIN(-7, "还没登陆!"); // // ResultEnum(Integer code, String message) { // this.code = code; // this.message = message; // } // // public Integer getCode() { // return code; // } // // public String getMessage() { // return message; // } // // @Override // public String toString() { // return "ResultEnum{" + // "code=" + code + // ", message='" + message + '\'' + // '}'; // } // // Integer code; // String message; // } // // Path: src/main/java/cn/niriqiang/blog/exception/ArticleException.java // public class ArticleException extends Exception { // // public ArticleException(ResultEnum resultEnum) { // super(resultEnum); // } // // public ArticleException(String message, Integer code) { // super(message, code); // } // // } // // Path: src/main/java/cn/niriqiang/blog/exception/CategoryException.java // public class CategoryException extends Exception { // public CategoryException(ResultEnum resultEnum) { // super(resultEnum); // } // // public CategoryException(String message, Integer code) { // super(message, code); // } // // } // // Path: src/main/java/cn/niriqiang/blog/exception/LoginException.java // public class LoginException extends Exception { // public LoginException(String message, Integer code) { // super(message, code); // } // // public LoginException(ResultEnum resultEnum) { // super(resultEnum); // } // } // // Path: src/main/java/cn/niriqiang/blog/exception/TagException.java // public class TagException extends Exception { // // public TagException(ResultEnum resultEnum) { // super(resultEnum); // } // // public TagException(String message, Integer code) { // super(message, code); // } // } // // Path: src/main/java/cn/niriqiang/blog/util/ResultUtil.java // public class ResultUtil { // public static <T> Result<T> success(ResultEnum resultEnum, T t) { // return new Result(resultEnum.getCode(), resultEnum.getMessage(), t); // } // // public static Result error(Integer code, String message) { // return new Result(code, message); // } // // public static Result error(ResultEnum resultEnum) { // return new Result(resultEnum.getCode(), resultEnum.getMessage()); // } // }
import cn.niriqiang.blog.dto.Result; import cn.niriqiang.blog.enums.ResultEnum; import cn.niriqiang.blog.exception.ArticleException; import cn.niriqiang.blog.exception.CategoryException; import cn.niriqiang.blog.exception.LoginException; import cn.niriqiang.blog.exception.TagException; import cn.niriqiang.blog.util.ResultUtil; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.web.bind.annotation.ControllerAdvice; import org.springframework.web.bind.annotation.ExceptionHandler; import org.springframework.web.bind.annotation.ResponseBody;
package cn.niriqiang.blog.handle; /** * Created by fengyuwusong on 2017/9/24 23:17. */ @ControllerAdvice public class ExceptionHandle { private final static Logger logger = LoggerFactory.getLogger(ExceptionHandle.class); @ExceptionHandler(value = Exception.class) @ResponseBody public Result handle(Exception e) { if (e instanceof ArticleException) { logger.error("ArticleException:" + e.getMessage()); ArticleException exception = (ArticleException) e; return ResultUtil.error(exception.getCode(), exception.getMessage()); } else if (e instanceof CategoryException) { logger.error("CategoryException:" + e.getMessage()); CategoryException exception = (CategoryException) e; return ResultUtil.error(exception.getCode(), exception.getMessage());
// Path: src/main/java/cn/niriqiang/blog/dto/Result.java // public class Result<T> { // // // private Integer code; // // private String message; // // private T data; // // @Override // public String toString() { // return "Result{" + // "code=" + code + // ", message='" + message + '\'' + // ", data=" + data + // '}'; // } // // public Result(Integer code, String message) { // this.code = code; // this.message = message; // } // // public Result(Integer code, String message, T data) { // this.code = code; // this.message = message; // this.data = data; // } // // public Integer getCode() { // return code; // } // // public void setCode(Integer code) { // this.code = code; // } // // public String getMessage() { // return message; // } // // public void setMessage(String message) { // this.message = message; // } // // public T getData() { // return data; // } // // public void setData(T data) { // this.data = data; // } // } // // Path: src/main/java/cn/niriqiang/blog/enums/ResultEnum.java // @ApiModel // public enum ResultEnum { // OK(200, "成功"), // NOT_BLANK(0, "不能为空"), // UNKNOW_ERROR(-1, "未知错误"), // NOT_FOUND(-2, "目标未找到"), // ADD_EXITS(-3, "目标已存在"), // DELETE_FALSE(-4, "不能删除相关文章还存在的分类"), // CURRENT_PAGE_NOT_NULL(-5, "页码不能为空"), // ERROR_NAME_PW(-6, "用户名密码错误"), // NOT_LOGIN(-7, "还没登陆!"); // // ResultEnum(Integer code, String message) { // this.code = code; // this.message = message; // } // // public Integer getCode() { // return code; // } // // public String getMessage() { // return message; // } // // @Override // public String toString() { // return "ResultEnum{" + // "code=" + code + // ", message='" + message + '\'' + // '}'; // } // // Integer code; // String message; // } // // Path: src/main/java/cn/niriqiang/blog/exception/ArticleException.java // public class ArticleException extends Exception { // // public ArticleException(ResultEnum resultEnum) { // super(resultEnum); // } // // public ArticleException(String message, Integer code) { // super(message, code); // } // // } // // Path: src/main/java/cn/niriqiang/blog/exception/CategoryException.java // public class CategoryException extends Exception { // public CategoryException(ResultEnum resultEnum) { // super(resultEnum); // } // // public CategoryException(String message, Integer code) { // super(message, code); // } // // } // // Path: src/main/java/cn/niriqiang/blog/exception/LoginException.java // public class LoginException extends Exception { // public LoginException(String message, Integer code) { // super(message, code); // } // // public LoginException(ResultEnum resultEnum) { // super(resultEnum); // } // } // // Path: src/main/java/cn/niriqiang/blog/exception/TagException.java // public class TagException extends Exception { // // public TagException(ResultEnum resultEnum) { // super(resultEnum); // } // // public TagException(String message, Integer code) { // super(message, code); // } // } // // Path: src/main/java/cn/niriqiang/blog/util/ResultUtil.java // public class ResultUtil { // public static <T> Result<T> success(ResultEnum resultEnum, T t) { // return new Result(resultEnum.getCode(), resultEnum.getMessage(), t); // } // // public static Result error(Integer code, String message) { // return new Result(code, message); // } // // public static Result error(ResultEnum resultEnum) { // return new Result(resultEnum.getCode(), resultEnum.getMessage()); // } // } // Path: src/main/java/cn/niriqiang/blog/handle/ExceptionHandle.java import cn.niriqiang.blog.dto.Result; import cn.niriqiang.blog.enums.ResultEnum; import cn.niriqiang.blog.exception.ArticleException; import cn.niriqiang.blog.exception.CategoryException; import cn.niriqiang.blog.exception.LoginException; import cn.niriqiang.blog.exception.TagException; import cn.niriqiang.blog.util.ResultUtil; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.web.bind.annotation.ControllerAdvice; import org.springframework.web.bind.annotation.ExceptionHandler; import org.springframework.web.bind.annotation.ResponseBody; package cn.niriqiang.blog.handle; /** * Created by fengyuwusong on 2017/9/24 23:17. */ @ControllerAdvice public class ExceptionHandle { private final static Logger logger = LoggerFactory.getLogger(ExceptionHandle.class); @ExceptionHandler(value = Exception.class) @ResponseBody public Result handle(Exception e) { if (e instanceof ArticleException) { logger.error("ArticleException:" + e.getMessage()); ArticleException exception = (ArticleException) e; return ResultUtil.error(exception.getCode(), exception.getMessage()); } else if (e instanceof CategoryException) { logger.error("CategoryException:" + e.getMessage()); CategoryException exception = (CategoryException) e; return ResultUtil.error(exception.getCode(), exception.getMessage());
} else if (e instanceof TagException) {
fengyuwusong/blog
src/main/java/cn/niriqiang/blog/handle/ExceptionHandle.java
// Path: src/main/java/cn/niriqiang/blog/dto/Result.java // public class Result<T> { // // // private Integer code; // // private String message; // // private T data; // // @Override // public String toString() { // return "Result{" + // "code=" + code + // ", message='" + message + '\'' + // ", data=" + data + // '}'; // } // // public Result(Integer code, String message) { // this.code = code; // this.message = message; // } // // public Result(Integer code, String message, T data) { // this.code = code; // this.message = message; // this.data = data; // } // // public Integer getCode() { // return code; // } // // public void setCode(Integer code) { // this.code = code; // } // // public String getMessage() { // return message; // } // // public void setMessage(String message) { // this.message = message; // } // // public T getData() { // return data; // } // // public void setData(T data) { // this.data = data; // } // } // // Path: src/main/java/cn/niriqiang/blog/enums/ResultEnum.java // @ApiModel // public enum ResultEnum { // OK(200, "成功"), // NOT_BLANK(0, "不能为空"), // UNKNOW_ERROR(-1, "未知错误"), // NOT_FOUND(-2, "目标未找到"), // ADD_EXITS(-3, "目标已存在"), // DELETE_FALSE(-4, "不能删除相关文章还存在的分类"), // CURRENT_PAGE_NOT_NULL(-5, "页码不能为空"), // ERROR_NAME_PW(-6, "用户名密码错误"), // NOT_LOGIN(-7, "还没登陆!"); // // ResultEnum(Integer code, String message) { // this.code = code; // this.message = message; // } // // public Integer getCode() { // return code; // } // // public String getMessage() { // return message; // } // // @Override // public String toString() { // return "ResultEnum{" + // "code=" + code + // ", message='" + message + '\'' + // '}'; // } // // Integer code; // String message; // } // // Path: src/main/java/cn/niriqiang/blog/exception/ArticleException.java // public class ArticleException extends Exception { // // public ArticleException(ResultEnum resultEnum) { // super(resultEnum); // } // // public ArticleException(String message, Integer code) { // super(message, code); // } // // } // // Path: src/main/java/cn/niriqiang/blog/exception/CategoryException.java // public class CategoryException extends Exception { // public CategoryException(ResultEnum resultEnum) { // super(resultEnum); // } // // public CategoryException(String message, Integer code) { // super(message, code); // } // // } // // Path: src/main/java/cn/niriqiang/blog/exception/LoginException.java // public class LoginException extends Exception { // public LoginException(String message, Integer code) { // super(message, code); // } // // public LoginException(ResultEnum resultEnum) { // super(resultEnum); // } // } // // Path: src/main/java/cn/niriqiang/blog/exception/TagException.java // public class TagException extends Exception { // // public TagException(ResultEnum resultEnum) { // super(resultEnum); // } // // public TagException(String message, Integer code) { // super(message, code); // } // } // // Path: src/main/java/cn/niriqiang/blog/util/ResultUtil.java // public class ResultUtil { // public static <T> Result<T> success(ResultEnum resultEnum, T t) { // return new Result(resultEnum.getCode(), resultEnum.getMessage(), t); // } // // public static Result error(Integer code, String message) { // return new Result(code, message); // } // // public static Result error(ResultEnum resultEnum) { // return new Result(resultEnum.getCode(), resultEnum.getMessage()); // } // }
import cn.niriqiang.blog.dto.Result; import cn.niriqiang.blog.enums.ResultEnum; import cn.niriqiang.blog.exception.ArticleException; import cn.niriqiang.blog.exception.CategoryException; import cn.niriqiang.blog.exception.LoginException; import cn.niriqiang.blog.exception.TagException; import cn.niriqiang.blog.util.ResultUtil; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.web.bind.annotation.ControllerAdvice; import org.springframework.web.bind.annotation.ExceptionHandler; import org.springframework.web.bind.annotation.ResponseBody;
package cn.niriqiang.blog.handle; /** * Created by fengyuwusong on 2017/9/24 23:17. */ @ControllerAdvice public class ExceptionHandle { private final static Logger logger = LoggerFactory.getLogger(ExceptionHandle.class); @ExceptionHandler(value = Exception.class) @ResponseBody public Result handle(Exception e) { if (e instanceof ArticleException) { logger.error("ArticleException:" + e.getMessage()); ArticleException exception = (ArticleException) e; return ResultUtil.error(exception.getCode(), exception.getMessage()); } else if (e instanceof CategoryException) { logger.error("CategoryException:" + e.getMessage()); CategoryException exception = (CategoryException) e; return ResultUtil.error(exception.getCode(), exception.getMessage()); } else if (e instanceof TagException) { logger.error("TagException:" + e.getMessage()); TagException exception = (TagException) e; return ResultUtil.error(exception.getCode(), exception.getMessage());
// Path: src/main/java/cn/niriqiang/blog/dto/Result.java // public class Result<T> { // // // private Integer code; // // private String message; // // private T data; // // @Override // public String toString() { // return "Result{" + // "code=" + code + // ", message='" + message + '\'' + // ", data=" + data + // '}'; // } // // public Result(Integer code, String message) { // this.code = code; // this.message = message; // } // // public Result(Integer code, String message, T data) { // this.code = code; // this.message = message; // this.data = data; // } // // public Integer getCode() { // return code; // } // // public void setCode(Integer code) { // this.code = code; // } // // public String getMessage() { // return message; // } // // public void setMessage(String message) { // this.message = message; // } // // public T getData() { // return data; // } // // public void setData(T data) { // this.data = data; // } // } // // Path: src/main/java/cn/niriqiang/blog/enums/ResultEnum.java // @ApiModel // public enum ResultEnum { // OK(200, "成功"), // NOT_BLANK(0, "不能为空"), // UNKNOW_ERROR(-1, "未知错误"), // NOT_FOUND(-2, "目标未找到"), // ADD_EXITS(-3, "目标已存在"), // DELETE_FALSE(-4, "不能删除相关文章还存在的分类"), // CURRENT_PAGE_NOT_NULL(-5, "页码不能为空"), // ERROR_NAME_PW(-6, "用户名密码错误"), // NOT_LOGIN(-7, "还没登陆!"); // // ResultEnum(Integer code, String message) { // this.code = code; // this.message = message; // } // // public Integer getCode() { // return code; // } // // public String getMessage() { // return message; // } // // @Override // public String toString() { // return "ResultEnum{" + // "code=" + code + // ", message='" + message + '\'' + // '}'; // } // // Integer code; // String message; // } // // Path: src/main/java/cn/niriqiang/blog/exception/ArticleException.java // public class ArticleException extends Exception { // // public ArticleException(ResultEnum resultEnum) { // super(resultEnum); // } // // public ArticleException(String message, Integer code) { // super(message, code); // } // // } // // Path: src/main/java/cn/niriqiang/blog/exception/CategoryException.java // public class CategoryException extends Exception { // public CategoryException(ResultEnum resultEnum) { // super(resultEnum); // } // // public CategoryException(String message, Integer code) { // super(message, code); // } // // } // // Path: src/main/java/cn/niriqiang/blog/exception/LoginException.java // public class LoginException extends Exception { // public LoginException(String message, Integer code) { // super(message, code); // } // // public LoginException(ResultEnum resultEnum) { // super(resultEnum); // } // } // // Path: src/main/java/cn/niriqiang/blog/exception/TagException.java // public class TagException extends Exception { // // public TagException(ResultEnum resultEnum) { // super(resultEnum); // } // // public TagException(String message, Integer code) { // super(message, code); // } // } // // Path: src/main/java/cn/niriqiang/blog/util/ResultUtil.java // public class ResultUtil { // public static <T> Result<T> success(ResultEnum resultEnum, T t) { // return new Result(resultEnum.getCode(), resultEnum.getMessage(), t); // } // // public static Result error(Integer code, String message) { // return new Result(code, message); // } // // public static Result error(ResultEnum resultEnum) { // return new Result(resultEnum.getCode(), resultEnum.getMessage()); // } // } // Path: src/main/java/cn/niriqiang/blog/handle/ExceptionHandle.java import cn.niriqiang.blog.dto.Result; import cn.niriqiang.blog.enums.ResultEnum; import cn.niriqiang.blog.exception.ArticleException; import cn.niriqiang.blog.exception.CategoryException; import cn.niriqiang.blog.exception.LoginException; import cn.niriqiang.blog.exception.TagException; import cn.niriqiang.blog.util.ResultUtil; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.web.bind.annotation.ControllerAdvice; import org.springframework.web.bind.annotation.ExceptionHandler; import org.springframework.web.bind.annotation.ResponseBody; package cn.niriqiang.blog.handle; /** * Created by fengyuwusong on 2017/9/24 23:17. */ @ControllerAdvice public class ExceptionHandle { private final static Logger logger = LoggerFactory.getLogger(ExceptionHandle.class); @ExceptionHandler(value = Exception.class) @ResponseBody public Result handle(Exception e) { if (e instanceof ArticleException) { logger.error("ArticleException:" + e.getMessage()); ArticleException exception = (ArticleException) e; return ResultUtil.error(exception.getCode(), exception.getMessage()); } else if (e instanceof CategoryException) { logger.error("CategoryException:" + e.getMessage()); CategoryException exception = (CategoryException) e; return ResultUtil.error(exception.getCode(), exception.getMessage()); } else if (e instanceof TagException) { logger.error("TagException:" + e.getMessage()); TagException exception = (TagException) e; return ResultUtil.error(exception.getCode(), exception.getMessage());
} else if (e instanceof LoginException) {
fengyuwusong/blog
src/test/java/cn/niriqiang/blog/service/CategoryServiceTest.java
// Path: src/test/java/cn/niriqiang/BlogApplicationTests.java // @RunWith(SpringRunner.class) // @SpringBootTest // public class BlogApplicationTests { // // @Test // public void contextLoads() { // } // // } // // Path: src/main/java/cn/niriqiang/blog/domain/Category.java // @ApiModel // @Data // public class Category { // @ApiModelProperty(value = "ID") // private Integer id; // @ApiModelProperty(value = "分类名") // @NotNull(message = "类型名称不能为空") // private String categoryName; // @ApiModelProperty(value = "分类描述") // @NotNull(message = "描述不能为空") // private String description; // }
import cn.niriqiang.BlogApplicationTests; import cn.niriqiang.blog.domain.Category; import org.junit.Test; import org.springframework.beans.factory.annotation.Autowired;
package cn.niriqiang.blog.service; /** * Created by fengyuwusong on 2017/9/27 0:53. */ public class CategoryServiceTest extends BlogApplicationTests { @Autowired private CategoryService categoryService; @Test public void insertCategory() throws Exception {
// Path: src/test/java/cn/niriqiang/BlogApplicationTests.java // @RunWith(SpringRunner.class) // @SpringBootTest // public class BlogApplicationTests { // // @Test // public void contextLoads() { // } // // } // // Path: src/main/java/cn/niriqiang/blog/domain/Category.java // @ApiModel // @Data // public class Category { // @ApiModelProperty(value = "ID") // private Integer id; // @ApiModelProperty(value = "分类名") // @NotNull(message = "类型名称不能为空") // private String categoryName; // @ApiModelProperty(value = "分类描述") // @NotNull(message = "描述不能为空") // private String description; // } // Path: src/test/java/cn/niriqiang/blog/service/CategoryServiceTest.java import cn.niriqiang.BlogApplicationTests; import cn.niriqiang.blog.domain.Category; import org.junit.Test; import org.springframework.beans.factory.annotation.Autowired; package cn.niriqiang.blog.service; /** * Created by fengyuwusong on 2017/9/27 0:53. */ public class CategoryServiceTest extends BlogApplicationTests { @Autowired private CategoryService categoryService; @Test public void insertCategory() throws Exception {
Category category = new Category();
fengyuwusong/blog
src/main/java/cn/niriqiang/blog/exception/Exception.java
// Path: src/main/java/cn/niriqiang/blog/enums/ResultEnum.java // @ApiModel // public enum ResultEnum { // OK(200, "成功"), // NOT_BLANK(0, "不能为空"), // UNKNOW_ERROR(-1, "未知错误"), // NOT_FOUND(-2, "目标未找到"), // ADD_EXITS(-3, "目标已存在"), // DELETE_FALSE(-4, "不能删除相关文章还存在的分类"), // CURRENT_PAGE_NOT_NULL(-5, "页码不能为空"), // ERROR_NAME_PW(-6, "用户名密码错误"), // NOT_LOGIN(-7, "还没登陆!"); // // ResultEnum(Integer code, String message) { // this.code = code; // this.message = message; // } // // public Integer getCode() { // return code; // } // // public String getMessage() { // return message; // } // // @Override // public String toString() { // return "ResultEnum{" + // "code=" + code + // ", message='" + message + '\'' + // '}'; // } // // Integer code; // String message; // }
import cn.niriqiang.blog.enums.ResultEnum;
package cn.niriqiang.blog.exception; /** * Created by fengyuwusong on 2017/10/2 23:47. */ public class Exception extends RuntimeException { public Integer code; public Integer getCode() { return code; } public void setCode(Integer code) { this.code = code; } public Exception(String message, Integer code) { super(message); this.code = code; }
// Path: src/main/java/cn/niriqiang/blog/enums/ResultEnum.java // @ApiModel // public enum ResultEnum { // OK(200, "成功"), // NOT_BLANK(0, "不能为空"), // UNKNOW_ERROR(-1, "未知错误"), // NOT_FOUND(-2, "目标未找到"), // ADD_EXITS(-3, "目标已存在"), // DELETE_FALSE(-4, "不能删除相关文章还存在的分类"), // CURRENT_PAGE_NOT_NULL(-5, "页码不能为空"), // ERROR_NAME_PW(-6, "用户名密码错误"), // NOT_LOGIN(-7, "还没登陆!"); // // ResultEnum(Integer code, String message) { // this.code = code; // this.message = message; // } // // public Integer getCode() { // return code; // } // // public String getMessage() { // return message; // } // // @Override // public String toString() { // return "ResultEnum{" + // "code=" + code + // ", message='" + message + '\'' + // '}'; // } // // Integer code; // String message; // } // Path: src/main/java/cn/niriqiang/blog/exception/Exception.java import cn.niriqiang.blog.enums.ResultEnum; package cn.niriqiang.blog.exception; /** * Created by fengyuwusong on 2017/10/2 23:47. */ public class Exception extends RuntimeException { public Integer code; public Integer getCode() { return code; } public void setCode(Integer code) { this.code = code; } public Exception(String message, Integer code) { super(message); this.code = code; }
public Exception(ResultEnum resultEnum) {
fengyuwusong/blog
src/main/java/cn/niriqiang/blog/exception/LoginException.java
// Path: src/main/java/cn/niriqiang/blog/enums/ResultEnum.java // @ApiModel // public enum ResultEnum { // OK(200, "成功"), // NOT_BLANK(0, "不能为空"), // UNKNOW_ERROR(-1, "未知错误"), // NOT_FOUND(-2, "目标未找到"), // ADD_EXITS(-3, "目标已存在"), // DELETE_FALSE(-4, "不能删除相关文章还存在的分类"), // CURRENT_PAGE_NOT_NULL(-5, "页码不能为空"), // ERROR_NAME_PW(-6, "用户名密码错误"), // NOT_LOGIN(-7, "还没登陆!"); // // ResultEnum(Integer code, String message) { // this.code = code; // this.message = message; // } // // public Integer getCode() { // return code; // } // // public String getMessage() { // return message; // } // // @Override // public String toString() { // return "ResultEnum{" + // "code=" + code + // ", message='" + message + '\'' + // '}'; // } // // Integer code; // String message; // }
import cn.niriqiang.blog.enums.ResultEnum;
package cn.niriqiang.blog.exception; /** * Created by fengyuwusong on 2017/10/4 16:01. */ public class LoginException extends Exception { public LoginException(String message, Integer code) { super(message, code); }
// Path: src/main/java/cn/niriqiang/blog/enums/ResultEnum.java // @ApiModel // public enum ResultEnum { // OK(200, "成功"), // NOT_BLANK(0, "不能为空"), // UNKNOW_ERROR(-1, "未知错误"), // NOT_FOUND(-2, "目标未找到"), // ADD_EXITS(-3, "目标已存在"), // DELETE_FALSE(-4, "不能删除相关文章还存在的分类"), // CURRENT_PAGE_NOT_NULL(-5, "页码不能为空"), // ERROR_NAME_PW(-6, "用户名密码错误"), // NOT_LOGIN(-7, "还没登陆!"); // // ResultEnum(Integer code, String message) { // this.code = code; // this.message = message; // } // // public Integer getCode() { // return code; // } // // public String getMessage() { // return message; // } // // @Override // public String toString() { // return "ResultEnum{" + // "code=" + code + // ", message='" + message + '\'' + // '}'; // } // // Integer code; // String message; // } // Path: src/main/java/cn/niriqiang/blog/exception/LoginException.java import cn.niriqiang.blog.enums.ResultEnum; package cn.niriqiang.blog.exception; /** * Created by fengyuwusong on 2017/10/4 16:01. */ public class LoginException extends Exception { public LoginException(String message, Integer code) { super(message, code); }
public LoginException(ResultEnum resultEnum) {
fengyuwusong/blog
src/main/java/cn/niriqiang/blog/controller/ConfigController.java
// Path: src/main/java/cn/niriqiang/blog/domain/Config.java // @Data // @ApiModel(value = "Config", description = "配置bean") // public class Config { // @ApiModelProperty(value = "ID") // private Integer id; // // @ApiModelProperty(value = "后台用户名") // private String adminName; // // @ApiModelProperty(value = "后台密码") // private String adminPw; // // @ApiModelProperty(value = "博客名") // private String blogName; // // @ApiModelProperty(value = "底栏") // private String footer; // // @ApiModelProperty(value = "博客头像") // private String blogPid; // // @ApiModelProperty(value = "博客标题") // private String title; // // @ApiModelProperty(value = "地址") // private String address; // // @ApiModelProperty(value = "git名称") // private String git; // // @ApiModelProperty(value = "gitUrl") // private String gitUrl; // // @ApiModelProperty(value = "nav1Name") // private String nav1Name; // @ApiModelProperty(value = "nav1Url") // private String nav1Url; // @ApiModelProperty(value = "nav2Name") // private String nav2Name; // @ApiModelProperty(value = "nav2Url") // private String nav2Url; // @ApiModelProperty(value = "nav3Name") // private String nav3Name; // @ApiModelProperty(value = "nav3Url") // private String nav3Url; // @ApiModelProperty(value = "nav4Name") // private String nav4Name; // @ApiModelProperty(value = "nav4Url") // private String nav4Url; // @ApiModelProperty(value = "nav5Name") // private String nav5Name; // @ApiModelProperty(value = "nav5Url") // private String nav5Url; // } // // Path: src/main/java/cn/niriqiang/blog/dto/Result.java // public class Result<T> { // // // private Integer code; // // private String message; // // private T data; // // @Override // public String toString() { // return "Result{" + // "code=" + code + // ", message='" + message + '\'' + // ", data=" + data + // '}'; // } // // public Result(Integer code, String message) { // this.code = code; // this.message = message; // } // // public Result(Integer code, String message, T data) { // this.code = code; // this.message = message; // this.data = data; // } // // public Integer getCode() { // return code; // } // // public void setCode(Integer code) { // this.code = code; // } // // public String getMessage() { // return message; // } // // public void setMessage(String message) { // this.message = message; // } // // public T getData() { // return data; // } // // public void setData(T data) { // this.data = data; // } // } // // Path: src/main/java/cn/niriqiang/blog/service/ConfigService.java // @Service // public class ConfigService { // @Autowired // private ConfigMapper mapper; // // public Result get() { // Config config = mapper.get(); // return ResultUtil.success(ResultEnum.OK, config); // } // // public Result adminGet() { // Config config = mapper.adminGet(); // return ResultUtil.success(ResultEnum.OK, config); // } // // public Result update(Config config) { // int res = mapper.update(config); // if (res == 1) { // return ResultUtil.success(ResultEnum.OK, config); // } // return ResultUtil.error(ResultEnum.UNKNOW_ERROR); // } // // public Result login(String adminName, String adminPw) { // Config config = new Config(); // config.setAdminName(adminName); // config.setAdminPw(adminPw); // int res = mapper.login(config); // if (res == 1) { // ServletRequestAttributes attributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes(); // HttpServletResponse response = attributes.getResponse(); // // 存储6小时 // CookieUtil.addCookie(response, "login", Md5Util.getMD5(adminPw), 60 * 60 * 6); // return ResultUtil.success(ResultEnum.OK, adminName); // } // throw new LoginException(ResultEnum.ERROR_NAME_PW); // } // // public Result click() { // if (mapper.click() == 1) { // return ResultUtil.success(ResultEnum.OK, null); // } // return ResultUtil.error(ResultEnum.UNKNOW_ERROR); // } // // @Admin // public Result isLogin() { // return ResultUtil.success(ResultEnum.OK, null); // } // // // }
import cn.niriqiang.blog.annotation.Admin; import cn.niriqiang.blog.domain.Config; import cn.niriqiang.blog.dto.Result; import cn.niriqiang.blog.service.ConfigService; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*;
package cn.niriqiang.blog.controller; /** * Created by fengyuwusong on 2017/10/3 15:09. */ @RestController @Api(value = "配置管理接口") @RequestMapping("/config") public class ConfigController { @Autowired
// Path: src/main/java/cn/niriqiang/blog/domain/Config.java // @Data // @ApiModel(value = "Config", description = "配置bean") // public class Config { // @ApiModelProperty(value = "ID") // private Integer id; // // @ApiModelProperty(value = "后台用户名") // private String adminName; // // @ApiModelProperty(value = "后台密码") // private String adminPw; // // @ApiModelProperty(value = "博客名") // private String blogName; // // @ApiModelProperty(value = "底栏") // private String footer; // // @ApiModelProperty(value = "博客头像") // private String blogPid; // // @ApiModelProperty(value = "博客标题") // private String title; // // @ApiModelProperty(value = "地址") // private String address; // // @ApiModelProperty(value = "git名称") // private String git; // // @ApiModelProperty(value = "gitUrl") // private String gitUrl; // // @ApiModelProperty(value = "nav1Name") // private String nav1Name; // @ApiModelProperty(value = "nav1Url") // private String nav1Url; // @ApiModelProperty(value = "nav2Name") // private String nav2Name; // @ApiModelProperty(value = "nav2Url") // private String nav2Url; // @ApiModelProperty(value = "nav3Name") // private String nav3Name; // @ApiModelProperty(value = "nav3Url") // private String nav3Url; // @ApiModelProperty(value = "nav4Name") // private String nav4Name; // @ApiModelProperty(value = "nav4Url") // private String nav4Url; // @ApiModelProperty(value = "nav5Name") // private String nav5Name; // @ApiModelProperty(value = "nav5Url") // private String nav5Url; // } // // Path: src/main/java/cn/niriqiang/blog/dto/Result.java // public class Result<T> { // // // private Integer code; // // private String message; // // private T data; // // @Override // public String toString() { // return "Result{" + // "code=" + code + // ", message='" + message + '\'' + // ", data=" + data + // '}'; // } // // public Result(Integer code, String message) { // this.code = code; // this.message = message; // } // // public Result(Integer code, String message, T data) { // this.code = code; // this.message = message; // this.data = data; // } // // public Integer getCode() { // return code; // } // // public void setCode(Integer code) { // this.code = code; // } // // public String getMessage() { // return message; // } // // public void setMessage(String message) { // this.message = message; // } // // public T getData() { // return data; // } // // public void setData(T data) { // this.data = data; // } // } // // Path: src/main/java/cn/niriqiang/blog/service/ConfigService.java // @Service // public class ConfigService { // @Autowired // private ConfigMapper mapper; // // public Result get() { // Config config = mapper.get(); // return ResultUtil.success(ResultEnum.OK, config); // } // // public Result adminGet() { // Config config = mapper.adminGet(); // return ResultUtil.success(ResultEnum.OK, config); // } // // public Result update(Config config) { // int res = mapper.update(config); // if (res == 1) { // return ResultUtil.success(ResultEnum.OK, config); // } // return ResultUtil.error(ResultEnum.UNKNOW_ERROR); // } // // public Result login(String adminName, String adminPw) { // Config config = new Config(); // config.setAdminName(adminName); // config.setAdminPw(adminPw); // int res = mapper.login(config); // if (res == 1) { // ServletRequestAttributes attributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes(); // HttpServletResponse response = attributes.getResponse(); // // 存储6小时 // CookieUtil.addCookie(response, "login", Md5Util.getMD5(adminPw), 60 * 60 * 6); // return ResultUtil.success(ResultEnum.OK, adminName); // } // throw new LoginException(ResultEnum.ERROR_NAME_PW); // } // // public Result click() { // if (mapper.click() == 1) { // return ResultUtil.success(ResultEnum.OK, null); // } // return ResultUtil.error(ResultEnum.UNKNOW_ERROR); // } // // @Admin // public Result isLogin() { // return ResultUtil.success(ResultEnum.OK, null); // } // // // } // Path: src/main/java/cn/niriqiang/blog/controller/ConfigController.java import cn.niriqiang.blog.annotation.Admin; import cn.niriqiang.blog.domain.Config; import cn.niriqiang.blog.dto.Result; import cn.niriqiang.blog.service.ConfigService; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; package cn.niriqiang.blog.controller; /** * Created by fengyuwusong on 2017/10/3 15:09. */ @RestController @Api(value = "配置管理接口") @RequestMapping("/config") public class ConfigController { @Autowired
private ConfigService configService;
fengyuwusong/blog
src/main/java/cn/niriqiang/blog/controller/ConfigController.java
// Path: src/main/java/cn/niriqiang/blog/domain/Config.java // @Data // @ApiModel(value = "Config", description = "配置bean") // public class Config { // @ApiModelProperty(value = "ID") // private Integer id; // // @ApiModelProperty(value = "后台用户名") // private String adminName; // // @ApiModelProperty(value = "后台密码") // private String adminPw; // // @ApiModelProperty(value = "博客名") // private String blogName; // // @ApiModelProperty(value = "底栏") // private String footer; // // @ApiModelProperty(value = "博客头像") // private String blogPid; // // @ApiModelProperty(value = "博客标题") // private String title; // // @ApiModelProperty(value = "地址") // private String address; // // @ApiModelProperty(value = "git名称") // private String git; // // @ApiModelProperty(value = "gitUrl") // private String gitUrl; // // @ApiModelProperty(value = "nav1Name") // private String nav1Name; // @ApiModelProperty(value = "nav1Url") // private String nav1Url; // @ApiModelProperty(value = "nav2Name") // private String nav2Name; // @ApiModelProperty(value = "nav2Url") // private String nav2Url; // @ApiModelProperty(value = "nav3Name") // private String nav3Name; // @ApiModelProperty(value = "nav3Url") // private String nav3Url; // @ApiModelProperty(value = "nav4Name") // private String nav4Name; // @ApiModelProperty(value = "nav4Url") // private String nav4Url; // @ApiModelProperty(value = "nav5Name") // private String nav5Name; // @ApiModelProperty(value = "nav5Url") // private String nav5Url; // } // // Path: src/main/java/cn/niriqiang/blog/dto/Result.java // public class Result<T> { // // // private Integer code; // // private String message; // // private T data; // // @Override // public String toString() { // return "Result{" + // "code=" + code + // ", message='" + message + '\'' + // ", data=" + data + // '}'; // } // // public Result(Integer code, String message) { // this.code = code; // this.message = message; // } // // public Result(Integer code, String message, T data) { // this.code = code; // this.message = message; // this.data = data; // } // // public Integer getCode() { // return code; // } // // public void setCode(Integer code) { // this.code = code; // } // // public String getMessage() { // return message; // } // // public void setMessage(String message) { // this.message = message; // } // // public T getData() { // return data; // } // // public void setData(T data) { // this.data = data; // } // } // // Path: src/main/java/cn/niriqiang/blog/service/ConfigService.java // @Service // public class ConfigService { // @Autowired // private ConfigMapper mapper; // // public Result get() { // Config config = mapper.get(); // return ResultUtil.success(ResultEnum.OK, config); // } // // public Result adminGet() { // Config config = mapper.adminGet(); // return ResultUtil.success(ResultEnum.OK, config); // } // // public Result update(Config config) { // int res = mapper.update(config); // if (res == 1) { // return ResultUtil.success(ResultEnum.OK, config); // } // return ResultUtil.error(ResultEnum.UNKNOW_ERROR); // } // // public Result login(String adminName, String adminPw) { // Config config = new Config(); // config.setAdminName(adminName); // config.setAdminPw(adminPw); // int res = mapper.login(config); // if (res == 1) { // ServletRequestAttributes attributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes(); // HttpServletResponse response = attributes.getResponse(); // // 存储6小时 // CookieUtil.addCookie(response, "login", Md5Util.getMD5(adminPw), 60 * 60 * 6); // return ResultUtil.success(ResultEnum.OK, adminName); // } // throw new LoginException(ResultEnum.ERROR_NAME_PW); // } // // public Result click() { // if (mapper.click() == 1) { // return ResultUtil.success(ResultEnum.OK, null); // } // return ResultUtil.error(ResultEnum.UNKNOW_ERROR); // } // // @Admin // public Result isLogin() { // return ResultUtil.success(ResultEnum.OK, null); // } // // // }
import cn.niriqiang.blog.annotation.Admin; import cn.niriqiang.blog.domain.Config; import cn.niriqiang.blog.dto.Result; import cn.niriqiang.blog.service.ConfigService; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*;
package cn.niriqiang.blog.controller; /** * Created by fengyuwusong on 2017/10/3 15:09. */ @RestController @Api(value = "配置管理接口") @RequestMapping("/config") public class ConfigController { @Autowired private ConfigService configService; @Admin @ApiOperation("更新配置信息") @PutMapping
// Path: src/main/java/cn/niriqiang/blog/domain/Config.java // @Data // @ApiModel(value = "Config", description = "配置bean") // public class Config { // @ApiModelProperty(value = "ID") // private Integer id; // // @ApiModelProperty(value = "后台用户名") // private String adminName; // // @ApiModelProperty(value = "后台密码") // private String adminPw; // // @ApiModelProperty(value = "博客名") // private String blogName; // // @ApiModelProperty(value = "底栏") // private String footer; // // @ApiModelProperty(value = "博客头像") // private String blogPid; // // @ApiModelProperty(value = "博客标题") // private String title; // // @ApiModelProperty(value = "地址") // private String address; // // @ApiModelProperty(value = "git名称") // private String git; // // @ApiModelProperty(value = "gitUrl") // private String gitUrl; // // @ApiModelProperty(value = "nav1Name") // private String nav1Name; // @ApiModelProperty(value = "nav1Url") // private String nav1Url; // @ApiModelProperty(value = "nav2Name") // private String nav2Name; // @ApiModelProperty(value = "nav2Url") // private String nav2Url; // @ApiModelProperty(value = "nav3Name") // private String nav3Name; // @ApiModelProperty(value = "nav3Url") // private String nav3Url; // @ApiModelProperty(value = "nav4Name") // private String nav4Name; // @ApiModelProperty(value = "nav4Url") // private String nav4Url; // @ApiModelProperty(value = "nav5Name") // private String nav5Name; // @ApiModelProperty(value = "nav5Url") // private String nav5Url; // } // // Path: src/main/java/cn/niriqiang/blog/dto/Result.java // public class Result<T> { // // // private Integer code; // // private String message; // // private T data; // // @Override // public String toString() { // return "Result{" + // "code=" + code + // ", message='" + message + '\'' + // ", data=" + data + // '}'; // } // // public Result(Integer code, String message) { // this.code = code; // this.message = message; // } // // public Result(Integer code, String message, T data) { // this.code = code; // this.message = message; // this.data = data; // } // // public Integer getCode() { // return code; // } // // public void setCode(Integer code) { // this.code = code; // } // // public String getMessage() { // return message; // } // // public void setMessage(String message) { // this.message = message; // } // // public T getData() { // return data; // } // // public void setData(T data) { // this.data = data; // } // } // // Path: src/main/java/cn/niriqiang/blog/service/ConfigService.java // @Service // public class ConfigService { // @Autowired // private ConfigMapper mapper; // // public Result get() { // Config config = mapper.get(); // return ResultUtil.success(ResultEnum.OK, config); // } // // public Result adminGet() { // Config config = mapper.adminGet(); // return ResultUtil.success(ResultEnum.OK, config); // } // // public Result update(Config config) { // int res = mapper.update(config); // if (res == 1) { // return ResultUtil.success(ResultEnum.OK, config); // } // return ResultUtil.error(ResultEnum.UNKNOW_ERROR); // } // // public Result login(String adminName, String adminPw) { // Config config = new Config(); // config.setAdminName(adminName); // config.setAdminPw(adminPw); // int res = mapper.login(config); // if (res == 1) { // ServletRequestAttributes attributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes(); // HttpServletResponse response = attributes.getResponse(); // // 存储6小时 // CookieUtil.addCookie(response, "login", Md5Util.getMD5(adminPw), 60 * 60 * 6); // return ResultUtil.success(ResultEnum.OK, adminName); // } // throw new LoginException(ResultEnum.ERROR_NAME_PW); // } // // public Result click() { // if (mapper.click() == 1) { // return ResultUtil.success(ResultEnum.OK, null); // } // return ResultUtil.error(ResultEnum.UNKNOW_ERROR); // } // // @Admin // public Result isLogin() { // return ResultUtil.success(ResultEnum.OK, null); // } // // // } // Path: src/main/java/cn/niriqiang/blog/controller/ConfigController.java import cn.niriqiang.blog.annotation.Admin; import cn.niriqiang.blog.domain.Config; import cn.niriqiang.blog.dto.Result; import cn.niriqiang.blog.service.ConfigService; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; package cn.niriqiang.blog.controller; /** * Created by fengyuwusong on 2017/10/3 15:09. */ @RestController @Api(value = "配置管理接口") @RequestMapping("/config") public class ConfigController { @Autowired private ConfigService configService; @Admin @ApiOperation("更新配置信息") @PutMapping
public Result update(@RequestBody Config config) {
fengyuwusong/blog
src/main/java/cn/niriqiang/blog/controller/ConfigController.java
// Path: src/main/java/cn/niriqiang/blog/domain/Config.java // @Data // @ApiModel(value = "Config", description = "配置bean") // public class Config { // @ApiModelProperty(value = "ID") // private Integer id; // // @ApiModelProperty(value = "后台用户名") // private String adminName; // // @ApiModelProperty(value = "后台密码") // private String adminPw; // // @ApiModelProperty(value = "博客名") // private String blogName; // // @ApiModelProperty(value = "底栏") // private String footer; // // @ApiModelProperty(value = "博客头像") // private String blogPid; // // @ApiModelProperty(value = "博客标题") // private String title; // // @ApiModelProperty(value = "地址") // private String address; // // @ApiModelProperty(value = "git名称") // private String git; // // @ApiModelProperty(value = "gitUrl") // private String gitUrl; // // @ApiModelProperty(value = "nav1Name") // private String nav1Name; // @ApiModelProperty(value = "nav1Url") // private String nav1Url; // @ApiModelProperty(value = "nav2Name") // private String nav2Name; // @ApiModelProperty(value = "nav2Url") // private String nav2Url; // @ApiModelProperty(value = "nav3Name") // private String nav3Name; // @ApiModelProperty(value = "nav3Url") // private String nav3Url; // @ApiModelProperty(value = "nav4Name") // private String nav4Name; // @ApiModelProperty(value = "nav4Url") // private String nav4Url; // @ApiModelProperty(value = "nav5Name") // private String nav5Name; // @ApiModelProperty(value = "nav5Url") // private String nav5Url; // } // // Path: src/main/java/cn/niriqiang/blog/dto/Result.java // public class Result<T> { // // // private Integer code; // // private String message; // // private T data; // // @Override // public String toString() { // return "Result{" + // "code=" + code + // ", message='" + message + '\'' + // ", data=" + data + // '}'; // } // // public Result(Integer code, String message) { // this.code = code; // this.message = message; // } // // public Result(Integer code, String message, T data) { // this.code = code; // this.message = message; // this.data = data; // } // // public Integer getCode() { // return code; // } // // public void setCode(Integer code) { // this.code = code; // } // // public String getMessage() { // return message; // } // // public void setMessage(String message) { // this.message = message; // } // // public T getData() { // return data; // } // // public void setData(T data) { // this.data = data; // } // } // // Path: src/main/java/cn/niriqiang/blog/service/ConfigService.java // @Service // public class ConfigService { // @Autowired // private ConfigMapper mapper; // // public Result get() { // Config config = mapper.get(); // return ResultUtil.success(ResultEnum.OK, config); // } // // public Result adminGet() { // Config config = mapper.adminGet(); // return ResultUtil.success(ResultEnum.OK, config); // } // // public Result update(Config config) { // int res = mapper.update(config); // if (res == 1) { // return ResultUtil.success(ResultEnum.OK, config); // } // return ResultUtil.error(ResultEnum.UNKNOW_ERROR); // } // // public Result login(String adminName, String adminPw) { // Config config = new Config(); // config.setAdminName(adminName); // config.setAdminPw(adminPw); // int res = mapper.login(config); // if (res == 1) { // ServletRequestAttributes attributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes(); // HttpServletResponse response = attributes.getResponse(); // // 存储6小时 // CookieUtil.addCookie(response, "login", Md5Util.getMD5(adminPw), 60 * 60 * 6); // return ResultUtil.success(ResultEnum.OK, adminName); // } // throw new LoginException(ResultEnum.ERROR_NAME_PW); // } // // public Result click() { // if (mapper.click() == 1) { // return ResultUtil.success(ResultEnum.OK, null); // } // return ResultUtil.error(ResultEnum.UNKNOW_ERROR); // } // // @Admin // public Result isLogin() { // return ResultUtil.success(ResultEnum.OK, null); // } // // // }
import cn.niriqiang.blog.annotation.Admin; import cn.niriqiang.blog.domain.Config; import cn.niriqiang.blog.dto.Result; import cn.niriqiang.blog.service.ConfigService; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*;
package cn.niriqiang.blog.controller; /** * Created by fengyuwusong on 2017/10/3 15:09. */ @RestController @Api(value = "配置管理接口") @RequestMapping("/config") public class ConfigController { @Autowired private ConfigService configService; @Admin @ApiOperation("更新配置信息") @PutMapping
// Path: src/main/java/cn/niriqiang/blog/domain/Config.java // @Data // @ApiModel(value = "Config", description = "配置bean") // public class Config { // @ApiModelProperty(value = "ID") // private Integer id; // // @ApiModelProperty(value = "后台用户名") // private String adminName; // // @ApiModelProperty(value = "后台密码") // private String adminPw; // // @ApiModelProperty(value = "博客名") // private String blogName; // // @ApiModelProperty(value = "底栏") // private String footer; // // @ApiModelProperty(value = "博客头像") // private String blogPid; // // @ApiModelProperty(value = "博客标题") // private String title; // // @ApiModelProperty(value = "地址") // private String address; // // @ApiModelProperty(value = "git名称") // private String git; // // @ApiModelProperty(value = "gitUrl") // private String gitUrl; // // @ApiModelProperty(value = "nav1Name") // private String nav1Name; // @ApiModelProperty(value = "nav1Url") // private String nav1Url; // @ApiModelProperty(value = "nav2Name") // private String nav2Name; // @ApiModelProperty(value = "nav2Url") // private String nav2Url; // @ApiModelProperty(value = "nav3Name") // private String nav3Name; // @ApiModelProperty(value = "nav3Url") // private String nav3Url; // @ApiModelProperty(value = "nav4Name") // private String nav4Name; // @ApiModelProperty(value = "nav4Url") // private String nav4Url; // @ApiModelProperty(value = "nav5Name") // private String nav5Name; // @ApiModelProperty(value = "nav5Url") // private String nav5Url; // } // // Path: src/main/java/cn/niriqiang/blog/dto/Result.java // public class Result<T> { // // // private Integer code; // // private String message; // // private T data; // // @Override // public String toString() { // return "Result{" + // "code=" + code + // ", message='" + message + '\'' + // ", data=" + data + // '}'; // } // // public Result(Integer code, String message) { // this.code = code; // this.message = message; // } // // public Result(Integer code, String message, T data) { // this.code = code; // this.message = message; // this.data = data; // } // // public Integer getCode() { // return code; // } // // public void setCode(Integer code) { // this.code = code; // } // // public String getMessage() { // return message; // } // // public void setMessage(String message) { // this.message = message; // } // // public T getData() { // return data; // } // // public void setData(T data) { // this.data = data; // } // } // // Path: src/main/java/cn/niriqiang/blog/service/ConfigService.java // @Service // public class ConfigService { // @Autowired // private ConfigMapper mapper; // // public Result get() { // Config config = mapper.get(); // return ResultUtil.success(ResultEnum.OK, config); // } // // public Result adminGet() { // Config config = mapper.adminGet(); // return ResultUtil.success(ResultEnum.OK, config); // } // // public Result update(Config config) { // int res = mapper.update(config); // if (res == 1) { // return ResultUtil.success(ResultEnum.OK, config); // } // return ResultUtil.error(ResultEnum.UNKNOW_ERROR); // } // // public Result login(String adminName, String adminPw) { // Config config = new Config(); // config.setAdminName(adminName); // config.setAdminPw(adminPw); // int res = mapper.login(config); // if (res == 1) { // ServletRequestAttributes attributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes(); // HttpServletResponse response = attributes.getResponse(); // // 存储6小时 // CookieUtil.addCookie(response, "login", Md5Util.getMD5(adminPw), 60 * 60 * 6); // return ResultUtil.success(ResultEnum.OK, adminName); // } // throw new LoginException(ResultEnum.ERROR_NAME_PW); // } // // public Result click() { // if (mapper.click() == 1) { // return ResultUtil.success(ResultEnum.OK, null); // } // return ResultUtil.error(ResultEnum.UNKNOW_ERROR); // } // // @Admin // public Result isLogin() { // return ResultUtil.success(ResultEnum.OK, null); // } // // // } // Path: src/main/java/cn/niriqiang/blog/controller/ConfigController.java import cn.niriqiang.blog.annotation.Admin; import cn.niriqiang.blog.domain.Config; import cn.niriqiang.blog.dto.Result; import cn.niriqiang.blog.service.ConfigService; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; package cn.niriqiang.blog.controller; /** * Created by fengyuwusong on 2017/10/3 15:09. */ @RestController @Api(value = "配置管理接口") @RequestMapping("/config") public class ConfigController { @Autowired private ConfigService configService; @Admin @ApiOperation("更新配置信息") @PutMapping
public Result update(@RequestBody Config config) {
zerofall/EZStorage
src/main/java/com/zerofall/ezstorage/block/BlockOutputPort.java
// Path: src/main/java/com/zerofall/ezstorage/tileentity/TileEntityOutputPort.java // public class TileEntityOutputPort extends TileEntity implements ITickable { // // public TileEntityStorageCore core; // // @Override // public void update() { // if (core != null && !worldObj.isRemote) { // boolean updateCore = false; // BlockPos location = getPos().offset(EnumFacing.UP); // TileEntity tileentity = worldObj.getTileEntity(location); // if (tileentity instanceof IInventory) { // IInventory inventory = (IInventory)tileentity; // // if (inventory != null) { // List<ItemGroup> inventoryList = core.inventory.inventory; // if (inventoryList != null && inventoryList.size() > 0) { // ItemGroup group = inventoryList.get(0); // if (group != null) { // ItemStack stack = group.itemStack; // stack.stackSize = (int) Math.min((long)stack.getMaxStackSize(), group.count); // int stackSize = stack.stackSize; // ItemStack leftOver = TileEntityHopper.putStackInInventoryAllSlots(inventory, stack, EnumFacing.DOWN); // if (leftOver != null) { // int remaining = stackSize - leftOver.stackSize; // if (remaining > 0) { // group.count -= remaining; // updateCore = true; // } // } else { // group.count -= stackSize; // updateCore = true; // } // if (group.count <= 0) { // core.inventory.inventory.remove(0); // } // } // } // } // } // if (updateCore) { // this.worldObj.markBlockForUpdate(core.getPos()); // core.markDirty(); // } // } // } // }
import com.zerofall.ezstorage.tileentity.TileEntityOutputPort; import net.minecraft.block.material.Material; import net.minecraft.block.state.IBlockState; import net.minecraft.tileentity.TileEntity; import net.minecraft.world.World;
package com.zerofall.ezstorage.block; public class BlockOutputPort extends EZBlockContainer { public BlockOutputPort() { super("output_port", Material.iron); } @Override public TileEntity createTileEntity(World world, IBlockState state) {
// Path: src/main/java/com/zerofall/ezstorage/tileentity/TileEntityOutputPort.java // public class TileEntityOutputPort extends TileEntity implements ITickable { // // public TileEntityStorageCore core; // // @Override // public void update() { // if (core != null && !worldObj.isRemote) { // boolean updateCore = false; // BlockPos location = getPos().offset(EnumFacing.UP); // TileEntity tileentity = worldObj.getTileEntity(location); // if (tileentity instanceof IInventory) { // IInventory inventory = (IInventory)tileentity; // // if (inventory != null) { // List<ItemGroup> inventoryList = core.inventory.inventory; // if (inventoryList != null && inventoryList.size() > 0) { // ItemGroup group = inventoryList.get(0); // if (group != null) { // ItemStack stack = group.itemStack; // stack.stackSize = (int) Math.min((long)stack.getMaxStackSize(), group.count); // int stackSize = stack.stackSize; // ItemStack leftOver = TileEntityHopper.putStackInInventoryAllSlots(inventory, stack, EnumFacing.DOWN); // if (leftOver != null) { // int remaining = stackSize - leftOver.stackSize; // if (remaining > 0) { // group.count -= remaining; // updateCore = true; // } // } else { // group.count -= stackSize; // updateCore = true; // } // if (group.count <= 0) { // core.inventory.inventory.remove(0); // } // } // } // } // } // if (updateCore) { // this.worldObj.markBlockForUpdate(core.getPos()); // core.markDirty(); // } // } // } // } // Path: src/main/java/com/zerofall/ezstorage/block/BlockOutputPort.java import com.zerofall.ezstorage.tileentity.TileEntityOutputPort; import net.minecraft.block.material.Material; import net.minecraft.block.state.IBlockState; import net.minecraft.tileentity.TileEntity; import net.minecraft.world.World; package com.zerofall.ezstorage.block; public class BlockOutputPort extends EZBlockContainer { public BlockOutputPort() { super("output_port", Material.iron); } @Override public TileEntity createTileEntity(World world, IBlockState state) {
return new TileEntityOutputPort();
zerofall/EZStorage
src/main/java/com/zerofall/ezstorage/tileentity/TileEntityOutputPort.java
// Path: src/main/java/com/zerofall/ezstorage/util/ItemGroup.java // public class ItemGroup { // public ItemStack itemStack; // public long count; // // public ItemGroup(ItemStack itemStack) { // this.itemStack = itemStack; // this.count = itemStack.stackSize; // } // // public ItemGroup(ItemStack itemStack, long count) { // this.itemStack = itemStack; // this.count = count; // } // // @Override // public String toString() { // return itemStack.getDisplayName() + ":" + count; // } // // public static class CountComparator implements Comparator<ItemGroup> { // // @Override // public int compare(ItemGroup o1, ItemGroup o2) { // Long l1 = (Long)o1.count; // Long l2 = (Long)o2.count; // return l2.compareTo(l1); // } // // } // }
import java.util.List; import com.zerofall.ezstorage.util.ItemGroup; import net.minecraft.inventory.IInventory; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntityHopper; import net.minecraft.util.BlockPos; import net.minecraft.util.EnumFacing; import net.minecraft.util.ITickable;
package com.zerofall.ezstorage.tileentity; public class TileEntityOutputPort extends TileEntity implements ITickable { public TileEntityStorageCore core; @Override public void update() { if (core != null && !worldObj.isRemote) { boolean updateCore = false; BlockPos location = getPos().offset(EnumFacing.UP); TileEntity tileentity = worldObj.getTileEntity(location); if (tileentity instanceof IInventory) { IInventory inventory = (IInventory)tileentity; if (inventory != null) {
// Path: src/main/java/com/zerofall/ezstorage/util/ItemGroup.java // public class ItemGroup { // public ItemStack itemStack; // public long count; // // public ItemGroup(ItemStack itemStack) { // this.itemStack = itemStack; // this.count = itemStack.stackSize; // } // // public ItemGroup(ItemStack itemStack, long count) { // this.itemStack = itemStack; // this.count = count; // } // // @Override // public String toString() { // return itemStack.getDisplayName() + ":" + count; // } // // public static class CountComparator implements Comparator<ItemGroup> { // // @Override // public int compare(ItemGroup o1, ItemGroup o2) { // Long l1 = (Long)o1.count; // Long l2 = (Long)o2.count; // return l2.compareTo(l1); // } // // } // } // Path: src/main/java/com/zerofall/ezstorage/tileentity/TileEntityOutputPort.java import java.util.List; import com.zerofall.ezstorage.util.ItemGroup; import net.minecraft.inventory.IInventory; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntityHopper; import net.minecraft.util.BlockPos; import net.minecraft.util.EnumFacing; import net.minecraft.util.ITickable; package com.zerofall.ezstorage.tileentity; public class TileEntityOutputPort extends TileEntity implements ITickable { public TileEntityStorageCore core; @Override public void update() { if (core != null && !worldObj.isRemote) { boolean updateCore = false; BlockPos location = getPos().offset(EnumFacing.UP); TileEntity tileentity = worldObj.getTileEntity(location); if (tileentity instanceof IInventory) { IInventory inventory = (IInventory)tileentity; if (inventory != null) {
List<ItemGroup> inventoryList = core.inventory.inventory;
zerofall/EZStorage
src/main/java/com/zerofall/ezstorage/block/BlockInputPort.java
// Path: src/main/java/com/zerofall/ezstorage/EZStorage.java // @Mod(modid = Reference.MOD_ID, name = Reference.MOD_NAME, version = Reference.VERSION, acceptedMinecraftVersions="[1.8.8]") // public class EZStorage // { // @Mod.Instance(Reference.MOD_ID) // public static EZStorage instance; // @SidedProxy(clientSide = Reference.CLIENT_PROXY_CLASS, serverSide = Reference.SERVER_PROXY_CLASS) // public static CommonProxy proxy; // public static SimpleNetworkWrapper networkWrapper; // public static Configuration config; // // public EZTab creativeTab; // // @EventHandler // public void preInit(FMLPreInitializationEvent event) { // config = new Configuration(event.getSuggestedConfigurationFile()); // EZConfiguration.syncConfig(); // this.creativeTab = new EZTab(); // EZBlocks.init(); // EZBlocks.register(); // NetworkRegistry.INSTANCE.registerGuiHandler(this, new GuiHandler()); // networkWrapper = NetworkRegistry.INSTANCE.newSimpleChannel("ezChannel"); // networkWrapper.registerMessage(PacketHandler.class, MyMessage.class, 0, Side.SERVER); // networkWrapper.registerMessage(RecipePacketHandler.class, RecipeMessage.class, 1, Side.SERVER); // MinecraftForge.EVENT_BUS.register(new XEventHandler()); // } // // @EventHandler // public void init(FMLInitializationEvent event) { // proxy.registerRenders(); // } // // } // // Path: src/main/java/com/zerofall/ezstorage/tileentity/TileEntityInputPort.java // public class TileEntityInputPort extends TileEntity implements IInventory, ITickable, ISidedInventory { // // private ItemStack[] inv = new ItemStack[1]; // public TileEntityStorageCore core; // // // @Override // // public String getName() { // // return "input_port"; // // } // // @Override // public boolean hasCustomName() { // return false; // } // // @Override // public IChatComponent getDisplayName() { // return new ChatComponentText("input_port"); // } // // @Override // public int getSizeInventory() { // return 1; // } // // @Override // public ItemStack getStackInSlot(int index) { // return inv[index]; // } // // @Override // public ItemStack decrStackSize(int index, int count) { // ItemStack stack = getStackInSlot(index); // if(stack != null) { // if(stack.stackSize <= count) { // setInventorySlotContents(index, null); // } else { // stack = stack.splitStack(count); // if(stack.stackSize == 0) { // setInventorySlotContents(index, null); // } // } // } // return stack; // } // // @Override // public void setInventorySlotContents(int index, ItemStack stack) { // inv[index] = stack; // if (stack != null && stack.stackSize > getInventoryStackLimit()) { // stack.stackSize = getInventoryStackLimit(); // } // } // // @Override // public int getInventoryStackLimit() { // return 64; // } // // @Override // public boolean isUseableByPlayer(EntityPlayer player) { // return true; // } // // @Override // public void openInventory(EntityPlayer player) { // // } // // @Override // public void closeInventory(EntityPlayer player) { // // } // // @Override // public boolean isItemValidForSlot(int index, ItemStack stack) { // return true; // } // // @Override // public int getField(int id) { // return 0; // } // // @Override // public void setField(int id, int value) { // // } // // @Override // public int getFieldCount() { // return 0; // } // // @Override // public void clear() { // for (int i = 0; i < inv.length; ++i) { // inv[i] = null; // } // } // // @Override // public int[] getSlotsForFace(EnumFacing side) { // int[] slots = new int[1]; // slots[0] = 0; // return slots; // } // // @Override // public boolean canInsertItem(int index, ItemStack itemStackIn, // EnumFacing direction) { // return true; // } // // @Override // public boolean canExtractItem(int index, ItemStack stack, // EnumFacing direction) { // return false; // } // // // @Override // public void update() { // // if (this.core != null) { // ItemStack stack = this.inv[0]; // if (stack != null && stack.stackSize > 0) { // if (this.core.isPartOfMultiblock(new BlockRef(this))) { // this.inv[0] = this.core.input(stack); // } else { // this.core = null; // } // } // } // } // // @Override // public String getName() { // return "input_port"; // } // // @Override // public ItemStack removeStackFromSlot(int index) { // return null; // } // }
import net.minecraft.block.material.Material; import net.minecraft.block.state.IBlockState; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.BlockPos; import net.minecraft.util.EnumFacing; import net.minecraft.world.World; import com.zerofall.ezstorage.EZStorage; import com.zerofall.ezstorage.tileentity.TileEntityInputPort;
package com.zerofall.ezstorage.block; public class BlockInputPort extends EZBlockContainer { public BlockInputPort() { super("input_port", Material.iron); } @Override public TileEntity createTileEntity(World world, IBlockState state) {
// Path: src/main/java/com/zerofall/ezstorage/EZStorage.java // @Mod(modid = Reference.MOD_ID, name = Reference.MOD_NAME, version = Reference.VERSION, acceptedMinecraftVersions="[1.8.8]") // public class EZStorage // { // @Mod.Instance(Reference.MOD_ID) // public static EZStorage instance; // @SidedProxy(clientSide = Reference.CLIENT_PROXY_CLASS, serverSide = Reference.SERVER_PROXY_CLASS) // public static CommonProxy proxy; // public static SimpleNetworkWrapper networkWrapper; // public static Configuration config; // // public EZTab creativeTab; // // @EventHandler // public void preInit(FMLPreInitializationEvent event) { // config = new Configuration(event.getSuggestedConfigurationFile()); // EZConfiguration.syncConfig(); // this.creativeTab = new EZTab(); // EZBlocks.init(); // EZBlocks.register(); // NetworkRegistry.INSTANCE.registerGuiHandler(this, new GuiHandler()); // networkWrapper = NetworkRegistry.INSTANCE.newSimpleChannel("ezChannel"); // networkWrapper.registerMessage(PacketHandler.class, MyMessage.class, 0, Side.SERVER); // networkWrapper.registerMessage(RecipePacketHandler.class, RecipeMessage.class, 1, Side.SERVER); // MinecraftForge.EVENT_BUS.register(new XEventHandler()); // } // // @EventHandler // public void init(FMLInitializationEvent event) { // proxy.registerRenders(); // } // // } // // Path: src/main/java/com/zerofall/ezstorage/tileentity/TileEntityInputPort.java // public class TileEntityInputPort extends TileEntity implements IInventory, ITickable, ISidedInventory { // // private ItemStack[] inv = new ItemStack[1]; // public TileEntityStorageCore core; // // // @Override // // public String getName() { // // return "input_port"; // // } // // @Override // public boolean hasCustomName() { // return false; // } // // @Override // public IChatComponent getDisplayName() { // return new ChatComponentText("input_port"); // } // // @Override // public int getSizeInventory() { // return 1; // } // // @Override // public ItemStack getStackInSlot(int index) { // return inv[index]; // } // // @Override // public ItemStack decrStackSize(int index, int count) { // ItemStack stack = getStackInSlot(index); // if(stack != null) { // if(stack.stackSize <= count) { // setInventorySlotContents(index, null); // } else { // stack = stack.splitStack(count); // if(stack.stackSize == 0) { // setInventorySlotContents(index, null); // } // } // } // return stack; // } // // @Override // public void setInventorySlotContents(int index, ItemStack stack) { // inv[index] = stack; // if (stack != null && stack.stackSize > getInventoryStackLimit()) { // stack.stackSize = getInventoryStackLimit(); // } // } // // @Override // public int getInventoryStackLimit() { // return 64; // } // // @Override // public boolean isUseableByPlayer(EntityPlayer player) { // return true; // } // // @Override // public void openInventory(EntityPlayer player) { // // } // // @Override // public void closeInventory(EntityPlayer player) { // // } // // @Override // public boolean isItemValidForSlot(int index, ItemStack stack) { // return true; // } // // @Override // public int getField(int id) { // return 0; // } // // @Override // public void setField(int id, int value) { // // } // // @Override // public int getFieldCount() { // return 0; // } // // @Override // public void clear() { // for (int i = 0; i < inv.length; ++i) { // inv[i] = null; // } // } // // @Override // public int[] getSlotsForFace(EnumFacing side) { // int[] slots = new int[1]; // slots[0] = 0; // return slots; // } // // @Override // public boolean canInsertItem(int index, ItemStack itemStackIn, // EnumFacing direction) { // return true; // } // // @Override // public boolean canExtractItem(int index, ItemStack stack, // EnumFacing direction) { // return false; // } // // // @Override // public void update() { // // if (this.core != null) { // ItemStack stack = this.inv[0]; // if (stack != null && stack.stackSize > 0) { // if (this.core.isPartOfMultiblock(new BlockRef(this))) { // this.inv[0] = this.core.input(stack); // } else { // this.core = null; // } // } // } // } // // @Override // public String getName() { // return "input_port"; // } // // @Override // public ItemStack removeStackFromSlot(int index) { // return null; // } // } // Path: src/main/java/com/zerofall/ezstorage/block/BlockInputPort.java import net.minecraft.block.material.Material; import net.minecraft.block.state.IBlockState; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.BlockPos; import net.minecraft.util.EnumFacing; import net.minecraft.world.World; import com.zerofall.ezstorage.EZStorage; import com.zerofall.ezstorage.tileentity.TileEntityInputPort; package com.zerofall.ezstorage.block; public class BlockInputPort extends EZBlockContainer { public BlockInputPort() { super("input_port", Material.iron); } @Override public TileEntity createTileEntity(World world, IBlockState state) {
return new TileEntityInputPort();
zerofall/EZStorage
src/main/java/com/zerofall/ezstorage/tileentity/TileEntityInputPort.java
// Path: src/main/java/com/zerofall/ezstorage/util/BlockRef.java // public class BlockRef { // // public BlockPos pos; // public Block block; // // public BlockRef(Block block, int x, int y, int z) { // this.block = block; // this.pos = new BlockPos(x, y, z); // } // // public BlockRef(TileEntity entity) { // this.block = entity.getBlockType(); // this.pos = entity.getPos(); // } // // @Override // public int hashCode() { // final int prime = 31; // int result = 1; // result = prime * result + ((block == null) ? 0 : block.hashCode()); // result = prime * result // + ((pos == null) ? 0 : pos.hashCode()); // return result; // } // // @Override // public boolean equals(Object obj) { // if (this == obj) // return true; // if (obj == null) // return false; // if (getClass() != obj.getClass()) // return false; // BlockRef other = (BlockRef) obj; // if (block == null) { // if (other.block != null) // return false; // } else if (!Block.isEqualTo(block, other.block)) // return false; // if (pos == null) { // if (other.pos != null) // return false; // } else if (!pos.equals(other.pos)) // return false; // return true; // } // // @Override // public String toString() { // return "BlockRef [pos=" + pos + ", block=" + block + "]"; // } // }
import com.zerofall.ezstorage.util.BlockRef; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.IInventory; import net.minecraft.inventory.ISidedInventory; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.ChatComponentText; import net.minecraft.util.EnumFacing; import net.minecraft.util.IChatComponent; import net.minecraft.util.ITickable;
inv[i] = null; } } @Override public int[] getSlotsForFace(EnumFacing side) { int[] slots = new int[1]; slots[0] = 0; return slots; } @Override public boolean canInsertItem(int index, ItemStack itemStackIn, EnumFacing direction) { return true; } @Override public boolean canExtractItem(int index, ItemStack stack, EnumFacing direction) { return false; } @Override public void update() { if (this.core != null) { ItemStack stack = this.inv[0]; if (stack != null && stack.stackSize > 0) {
// Path: src/main/java/com/zerofall/ezstorage/util/BlockRef.java // public class BlockRef { // // public BlockPos pos; // public Block block; // // public BlockRef(Block block, int x, int y, int z) { // this.block = block; // this.pos = new BlockPos(x, y, z); // } // // public BlockRef(TileEntity entity) { // this.block = entity.getBlockType(); // this.pos = entity.getPos(); // } // // @Override // public int hashCode() { // final int prime = 31; // int result = 1; // result = prime * result + ((block == null) ? 0 : block.hashCode()); // result = prime * result // + ((pos == null) ? 0 : pos.hashCode()); // return result; // } // // @Override // public boolean equals(Object obj) { // if (this == obj) // return true; // if (obj == null) // return false; // if (getClass() != obj.getClass()) // return false; // BlockRef other = (BlockRef) obj; // if (block == null) { // if (other.block != null) // return false; // } else if (!Block.isEqualTo(block, other.block)) // return false; // if (pos == null) { // if (other.pos != null) // return false; // } else if (!pos.equals(other.pos)) // return false; // return true; // } // // @Override // public String toString() { // return "BlockRef [pos=" + pos + ", block=" + block + "]"; // } // } // Path: src/main/java/com/zerofall/ezstorage/tileentity/TileEntityInputPort.java import com.zerofall.ezstorage.util.BlockRef; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.IInventory; import net.minecraft.inventory.ISidedInventory; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.ChatComponentText; import net.minecraft.util.EnumFacing; import net.minecraft.util.IChatComponent; import net.minecraft.util.ITickable; inv[i] = null; } } @Override public int[] getSlotsForFace(EnumFacing side) { int[] slots = new int[1]; slots[0] = 0; return slots; } @Override public boolean canInsertItem(int index, ItemStack itemStackIn, EnumFacing direction) { return true; } @Override public boolean canExtractItem(int index, ItemStack stack, EnumFacing direction) { return false; } @Override public void update() { if (this.core != null) { ItemStack stack = this.inv[0]; if (stack != null && stack.stackSize > 0) {
if (this.core.isPartOfMultiblock(new BlockRef(this))) {
zerofall/EZStorage
src/main/java/com/zerofall/ezstorage/block/EZBlock.java
// Path: src/main/java/com/zerofall/ezstorage/EZStorage.java // @Mod(modid = Reference.MOD_ID, name = Reference.MOD_NAME, version = Reference.VERSION, acceptedMinecraftVersions="[1.8.8]") // public class EZStorage // { // @Mod.Instance(Reference.MOD_ID) // public static EZStorage instance; // @SidedProxy(clientSide = Reference.CLIENT_PROXY_CLASS, serverSide = Reference.SERVER_PROXY_CLASS) // public static CommonProxy proxy; // public static SimpleNetworkWrapper networkWrapper; // public static Configuration config; // // public EZTab creativeTab; // // @EventHandler // public void preInit(FMLPreInitializationEvent event) { // config = new Configuration(event.getSuggestedConfigurationFile()); // EZConfiguration.syncConfig(); // this.creativeTab = new EZTab(); // EZBlocks.init(); // EZBlocks.register(); // NetworkRegistry.INSTANCE.registerGuiHandler(this, new GuiHandler()); // networkWrapper = NetworkRegistry.INSTANCE.newSimpleChannel("ezChannel"); // networkWrapper.registerMessage(PacketHandler.class, MyMessage.class, 0, Side.SERVER); // networkWrapper.registerMessage(RecipePacketHandler.class, RecipeMessage.class, 1, Side.SERVER); // MinecraftForge.EVENT_BUS.register(new XEventHandler()); // } // // @EventHandler // public void init(FMLInitializationEvent event) { // proxy.registerRenders(); // } // // }
import com.zerofall.ezstorage.EZStorage; import net.minecraft.block.Block; import net.minecraft.block.material.Material;
package com.zerofall.ezstorage.block; public class EZBlock extends Block { protected EZBlock(String name, Material materialIn) { super(materialIn); this.setUnlocalizedName(name);
// Path: src/main/java/com/zerofall/ezstorage/EZStorage.java // @Mod(modid = Reference.MOD_ID, name = Reference.MOD_NAME, version = Reference.VERSION, acceptedMinecraftVersions="[1.8.8]") // public class EZStorage // { // @Mod.Instance(Reference.MOD_ID) // public static EZStorage instance; // @SidedProxy(clientSide = Reference.CLIENT_PROXY_CLASS, serverSide = Reference.SERVER_PROXY_CLASS) // public static CommonProxy proxy; // public static SimpleNetworkWrapper networkWrapper; // public static Configuration config; // // public EZTab creativeTab; // // @EventHandler // public void preInit(FMLPreInitializationEvent event) { // config = new Configuration(event.getSuggestedConfigurationFile()); // EZConfiguration.syncConfig(); // this.creativeTab = new EZTab(); // EZBlocks.init(); // EZBlocks.register(); // NetworkRegistry.INSTANCE.registerGuiHandler(this, new GuiHandler()); // networkWrapper = NetworkRegistry.INSTANCE.newSimpleChannel("ezChannel"); // networkWrapper.registerMessage(PacketHandler.class, MyMessage.class, 0, Side.SERVER); // networkWrapper.registerMessage(RecipePacketHandler.class, RecipeMessage.class, 1, Side.SERVER); // MinecraftForge.EVENT_BUS.register(new XEventHandler()); // } // // @EventHandler // public void init(FMLInitializationEvent event) { // proxy.registerRenders(); // } // // } // Path: src/main/java/com/zerofall/ezstorage/block/EZBlock.java import com.zerofall.ezstorage.EZStorage; import net.minecraft.block.Block; import net.minecraft.block.material.Material; package com.zerofall.ezstorage.block; public class EZBlock extends Block { protected EZBlock(String name, Material materialIn) { super(materialIn); this.setUnlocalizedName(name);
this.setCreativeTab(EZStorage.instance.creativeTab);
zerofall/EZStorage
src/main/java/com/zerofall/ezstorage/item/EZItem.java
// Path: src/main/java/com/zerofall/ezstorage/EZStorage.java // @Mod(modid = Reference.MOD_ID, name = Reference.MOD_NAME, version = Reference.VERSION, acceptedMinecraftVersions="[1.8.8]") // public class EZStorage // { // @Mod.Instance(Reference.MOD_ID) // public static EZStorage instance; // @SidedProxy(clientSide = Reference.CLIENT_PROXY_CLASS, serverSide = Reference.SERVER_PROXY_CLASS) // public static CommonProxy proxy; // public static SimpleNetworkWrapper networkWrapper; // public static Configuration config; // // public EZTab creativeTab; // // @EventHandler // public void preInit(FMLPreInitializationEvent event) { // config = new Configuration(event.getSuggestedConfigurationFile()); // EZConfiguration.syncConfig(); // this.creativeTab = new EZTab(); // EZBlocks.init(); // EZBlocks.register(); // NetworkRegistry.INSTANCE.registerGuiHandler(this, new GuiHandler()); // networkWrapper = NetworkRegistry.INSTANCE.newSimpleChannel("ezChannel"); // networkWrapper.registerMessage(PacketHandler.class, MyMessage.class, 0, Side.SERVER); // networkWrapper.registerMessage(RecipePacketHandler.class, RecipeMessage.class, 1, Side.SERVER); // MinecraftForge.EVENT_BUS.register(new XEventHandler()); // } // // @EventHandler // public void init(FMLInitializationEvent event) { // proxy.registerRenders(); // } // // }
import net.minecraft.item.Item; import net.minecraftforge.fml.common.registry.GameRegistry; import com.zerofall.ezstorage.EZStorage;
package com.zerofall.ezstorage.item; public class EZItem extends Item { public EZItem(String name) { registerItem(name, this); } public static void registerItem(String name, Item item) {
// Path: src/main/java/com/zerofall/ezstorage/EZStorage.java // @Mod(modid = Reference.MOD_ID, name = Reference.MOD_NAME, version = Reference.VERSION, acceptedMinecraftVersions="[1.8.8]") // public class EZStorage // { // @Mod.Instance(Reference.MOD_ID) // public static EZStorage instance; // @SidedProxy(clientSide = Reference.CLIENT_PROXY_CLASS, serverSide = Reference.SERVER_PROXY_CLASS) // public static CommonProxy proxy; // public static SimpleNetworkWrapper networkWrapper; // public static Configuration config; // // public EZTab creativeTab; // // @EventHandler // public void preInit(FMLPreInitializationEvent event) { // config = new Configuration(event.getSuggestedConfigurationFile()); // EZConfiguration.syncConfig(); // this.creativeTab = new EZTab(); // EZBlocks.init(); // EZBlocks.register(); // NetworkRegistry.INSTANCE.registerGuiHandler(this, new GuiHandler()); // networkWrapper = NetworkRegistry.INSTANCE.newSimpleChannel("ezChannel"); // networkWrapper.registerMessage(PacketHandler.class, MyMessage.class, 0, Side.SERVER); // networkWrapper.registerMessage(RecipePacketHandler.class, RecipeMessage.class, 1, Side.SERVER); // MinecraftForge.EVENT_BUS.register(new XEventHandler()); // } // // @EventHandler // public void init(FMLInitializationEvent event) { // proxy.registerRenders(); // } // // } // Path: src/main/java/com/zerofall/ezstorage/item/EZItem.java import net.minecraft.item.Item; import net.minecraftforge.fml.common.registry.GameRegistry; import com.zerofall.ezstorage.EZStorage; package com.zerofall.ezstorage.item; public class EZItem extends Item { public EZItem(String name) { registerItem(name, this); } public static void registerItem(String name, Item item) {
item.setCreativeTab(EZStorage.instance.creativeTab);
zerofall/EZStorage
src/main/java/com/zerofall/ezstorage/proxy/ClientProxy.java
// Path: src/main/java/com/zerofall/ezstorage/init/EZBlocks.java // public class EZBlocks { // // public static Block storage_core; // public static Block storage_box; // public static Block condensed_storage_box; // public static Block hyper_storage_box; // public static Block input_port; // public static Block output_port; // public static Block crafting_box; // public static Block search_box; // // public static void init() // { // storage_core = new BlockStorageCore(); // storage_box = new BlockStorage(); // condensed_storage_box = new BlockCondensedStorage(); // hyper_storage_box = new BlockHyperStorage(); // input_port = new BlockInputPort(); // output_port = new BlockOutputPort(); // crafting_box = new BlockCraftingBox(); // search_box = new BlockSearchBox(); // } // // public static void register() // { // GameRegistry.registerBlock(storage_core, storage_core.getUnlocalizedName().substring(5)); // GameRegistry.registerTileEntity(TileEntityStorageCore.class, "TileEntityStorageCore"); // GameRegistry.registerBlock(storage_box, storage_box.getUnlocalizedName().substring(5)); // GameRegistry.registerBlock(condensed_storage_box, condensed_storage_box.getUnlocalizedName().substring(5)); // GameRegistry.registerBlock(hyper_storage_box, hyper_storage_box.getUnlocalizedName().substring(5)); // GameRegistry.registerBlock(input_port, input_port.getUnlocalizedName().substring(5)); // GameRegistry.registerTileEntity(TileEntityInputPort.class, "TileEntityInputPort"); // GameRegistry.registerBlock(output_port, output_port.getUnlocalizedName().substring(5)); // GameRegistry.registerTileEntity(TileEntityOutputPort.class, "TileEntityOutputPort"); // GameRegistry.registerBlock(crafting_box, crafting_box.getUnlocalizedName().substring(5)); // GameRegistry.registerBlock(search_box, search_box.getUnlocalizedName().substring(5)); // registerRecipes(); // } // // public static void registerRenders() // { // registerRender(storage_core); // registerRender(storage_box); // registerRender(condensed_storage_box); // registerRender(hyper_storage_box); // registerRender(input_port); // registerRender(output_port); // registerRender(crafting_box); // registerRender(search_box); // } // // public static void registerRender(Block block) // { // Item item = Item.getItemFromBlock(block); // Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register(item, 0, new ModelResourceLocation(Reference.MOD_ID + ":" + item.getUnlocalizedName().substring(5), "inventory")); // } // // public static void registerRecipes() { // GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(storage_core), // "ABA", // "BCB", // "ABA", // 'A', "logWood", 'B', "stickWood", 'C', Blocks.chest)); // GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(storage_box), // "ABA", // "B B", // "ABA", // 'A', "logWood", 'B', Blocks.chest)); // GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(condensed_storage_box), // "ACA", // "CBC", // "ACA", // 'A', "blockIron", 'B', storage_box, 'C', Blocks.iron_bars)); // GameRegistry.addRecipe(new ItemStack(hyper_storage_box), // "ABA", // "ACA", // "AAA", // 'A', Blocks.obsidian, 'B', Items.nether_star, 'C', condensed_storage_box); // GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(input_port), // "ABA", // "BCB", // "ABA", // 'A', Blocks.hopper, 'B', Blocks.piston, 'C', "blockQuartz")); // GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(output_port), // "A", // "B", // "A", // 'A', Blocks.piston, 'B', input_port)); // GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(crafting_box), // "ABA", // "BCB", // "ABA", // 'A', Items.ender_eye, 'B', Blocks.crafting_table, 'C', "gemDiamond")); // GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(search_box), // "ABA", // "BCB", // "ABA", // 'A', "blockIron", 'B', Items.enchanted_book, 'C', Items.compass)); // } // }
import com.zerofall.ezstorage.init.EZBlocks;
package com.zerofall.ezstorage.proxy; public class ClientProxy extends CommonProxy{ @Override public void registerRenders() {
// Path: src/main/java/com/zerofall/ezstorage/init/EZBlocks.java // public class EZBlocks { // // public static Block storage_core; // public static Block storage_box; // public static Block condensed_storage_box; // public static Block hyper_storage_box; // public static Block input_port; // public static Block output_port; // public static Block crafting_box; // public static Block search_box; // // public static void init() // { // storage_core = new BlockStorageCore(); // storage_box = new BlockStorage(); // condensed_storage_box = new BlockCondensedStorage(); // hyper_storage_box = new BlockHyperStorage(); // input_port = new BlockInputPort(); // output_port = new BlockOutputPort(); // crafting_box = new BlockCraftingBox(); // search_box = new BlockSearchBox(); // } // // public static void register() // { // GameRegistry.registerBlock(storage_core, storage_core.getUnlocalizedName().substring(5)); // GameRegistry.registerTileEntity(TileEntityStorageCore.class, "TileEntityStorageCore"); // GameRegistry.registerBlock(storage_box, storage_box.getUnlocalizedName().substring(5)); // GameRegistry.registerBlock(condensed_storage_box, condensed_storage_box.getUnlocalizedName().substring(5)); // GameRegistry.registerBlock(hyper_storage_box, hyper_storage_box.getUnlocalizedName().substring(5)); // GameRegistry.registerBlock(input_port, input_port.getUnlocalizedName().substring(5)); // GameRegistry.registerTileEntity(TileEntityInputPort.class, "TileEntityInputPort"); // GameRegistry.registerBlock(output_port, output_port.getUnlocalizedName().substring(5)); // GameRegistry.registerTileEntity(TileEntityOutputPort.class, "TileEntityOutputPort"); // GameRegistry.registerBlock(crafting_box, crafting_box.getUnlocalizedName().substring(5)); // GameRegistry.registerBlock(search_box, search_box.getUnlocalizedName().substring(5)); // registerRecipes(); // } // // public static void registerRenders() // { // registerRender(storage_core); // registerRender(storage_box); // registerRender(condensed_storage_box); // registerRender(hyper_storage_box); // registerRender(input_port); // registerRender(output_port); // registerRender(crafting_box); // registerRender(search_box); // } // // public static void registerRender(Block block) // { // Item item = Item.getItemFromBlock(block); // Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register(item, 0, new ModelResourceLocation(Reference.MOD_ID + ":" + item.getUnlocalizedName().substring(5), "inventory")); // } // // public static void registerRecipes() { // GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(storage_core), // "ABA", // "BCB", // "ABA", // 'A', "logWood", 'B', "stickWood", 'C', Blocks.chest)); // GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(storage_box), // "ABA", // "B B", // "ABA", // 'A', "logWood", 'B', Blocks.chest)); // GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(condensed_storage_box), // "ACA", // "CBC", // "ACA", // 'A', "blockIron", 'B', storage_box, 'C', Blocks.iron_bars)); // GameRegistry.addRecipe(new ItemStack(hyper_storage_box), // "ABA", // "ACA", // "AAA", // 'A', Blocks.obsidian, 'B', Items.nether_star, 'C', condensed_storage_box); // GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(input_port), // "ABA", // "BCB", // "ABA", // 'A', Blocks.hopper, 'B', Blocks.piston, 'C', "blockQuartz")); // GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(output_port), // "A", // "B", // "A", // 'A', Blocks.piston, 'B', input_port)); // GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(crafting_box), // "ABA", // "BCB", // "ABA", // 'A', Items.ender_eye, 'B', Blocks.crafting_table, 'C', "gemDiamond")); // GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(search_box), // "ABA", // "BCB", // "ABA", // 'A', "blockIron", 'B', Items.enchanted_book, 'C', Items.compass)); // } // } // Path: src/main/java/com/zerofall/ezstorage/proxy/ClientProxy.java import com.zerofall.ezstorage.init.EZBlocks; package com.zerofall.ezstorage.proxy; public class ClientProxy extends CommonProxy{ @Override public void registerRenders() {
EZBlocks.registerRenders();
zerofall/EZStorage
src/main/java/com/zerofall/ezstorage/configuration/EZConfiguration.java
// Path: src/main/java/com/zerofall/ezstorage/EZStorage.java // @Mod(modid = Reference.MOD_ID, name = Reference.MOD_NAME, version = Reference.VERSION, acceptedMinecraftVersions="[1.8.8]") // public class EZStorage // { // @Mod.Instance(Reference.MOD_ID) // public static EZStorage instance; // @SidedProxy(clientSide = Reference.CLIENT_PROXY_CLASS, serverSide = Reference.SERVER_PROXY_CLASS) // public static CommonProxy proxy; // public static SimpleNetworkWrapper networkWrapper; // public static Configuration config; // // public EZTab creativeTab; // // @EventHandler // public void preInit(FMLPreInitializationEvent event) { // config = new Configuration(event.getSuggestedConfigurationFile()); // EZConfiguration.syncConfig(); // this.creativeTab = new EZTab(); // EZBlocks.init(); // EZBlocks.register(); // NetworkRegistry.INSTANCE.registerGuiHandler(this, new GuiHandler()); // networkWrapper = NetworkRegistry.INSTANCE.newSimpleChannel("ezChannel"); // networkWrapper.registerMessage(PacketHandler.class, MyMessage.class, 0, Side.SERVER); // networkWrapper.registerMessage(RecipePacketHandler.class, RecipeMessage.class, 1, Side.SERVER); // MinecraftForge.EVENT_BUS.register(new XEventHandler()); // } // // @EventHandler // public void init(FMLInitializationEvent event) { // proxy.registerRenders(); // } // // }
import com.zerofall.ezstorage.EZStorage; import net.minecraftforge.common.config.Configuration;
package com.zerofall.ezstorage.configuration; public class EZConfiguration { public static int basicCapacity; public static int condensedCapacity; public static int hyperCapacity; public static void syncConfig() {
// Path: src/main/java/com/zerofall/ezstorage/EZStorage.java // @Mod(modid = Reference.MOD_ID, name = Reference.MOD_NAME, version = Reference.VERSION, acceptedMinecraftVersions="[1.8.8]") // public class EZStorage // { // @Mod.Instance(Reference.MOD_ID) // public static EZStorage instance; // @SidedProxy(clientSide = Reference.CLIENT_PROXY_CLASS, serverSide = Reference.SERVER_PROXY_CLASS) // public static CommonProxy proxy; // public static SimpleNetworkWrapper networkWrapper; // public static Configuration config; // // public EZTab creativeTab; // // @EventHandler // public void preInit(FMLPreInitializationEvent event) { // config = new Configuration(event.getSuggestedConfigurationFile()); // EZConfiguration.syncConfig(); // this.creativeTab = new EZTab(); // EZBlocks.init(); // EZBlocks.register(); // NetworkRegistry.INSTANCE.registerGuiHandler(this, new GuiHandler()); // networkWrapper = NetworkRegistry.INSTANCE.newSimpleChannel("ezChannel"); // networkWrapper.registerMessage(PacketHandler.class, MyMessage.class, 0, Side.SERVER); // networkWrapper.registerMessage(RecipePacketHandler.class, RecipeMessage.class, 1, Side.SERVER); // MinecraftForge.EVENT_BUS.register(new XEventHandler()); // } // // @EventHandler // public void init(FMLInitializationEvent event) { // proxy.registerRenders(); // } // // } // Path: src/main/java/com/zerofall/ezstorage/configuration/EZConfiguration.java import com.zerofall.ezstorage.EZStorage; import net.minecraftforge.common.config.Configuration; package com.zerofall.ezstorage.configuration; public class EZConfiguration { public static int basicCapacity; public static int condensedCapacity; public static int hyperCapacity; public static void syncConfig() {
final Configuration config = EZStorage.config;
zerofall/EZStorage
src/main/java/com/zerofall/ezstorage/block/BlockHyperStorage.java
// Path: src/main/java/com/zerofall/ezstorage/configuration/EZConfiguration.java // public class EZConfiguration { // // public static int basicCapacity; // public static int condensedCapacity; // public static int hyperCapacity; // // public static void syncConfig() { // final Configuration config = EZStorage.config; // config.load(); // // final String OPTIONS = config.CATEGORY_GENERAL + config.CATEGORY_SPLITTER + "options"; // // basicCapacity = config.getInt("Basic Storage Capacity", OPTIONS, 400, 100, 4000, "Basic"); // condensedCapacity = config.getInt("Condensed Storage Capacity", OPTIONS, 4000, 100, 40000, "Condensed"); // hyperCapacity = config.getInt("Hyper Storage Capacity", OPTIONS, 400000, 100, 4000000, "Hyper"); // if (config.hasChanged()) { // config.save(); // } // } // }
import com.zerofall.ezstorage.configuration.EZConfiguration; import net.minecraft.block.material.Material;
package com.zerofall.ezstorage.block; public class BlockHyperStorage extends BlockStorage { public BlockHyperStorage() { super("hyper_storage_box", Material.iron); } @Override public int getCapacity() {
// Path: src/main/java/com/zerofall/ezstorage/configuration/EZConfiguration.java // public class EZConfiguration { // // public static int basicCapacity; // public static int condensedCapacity; // public static int hyperCapacity; // // public static void syncConfig() { // final Configuration config = EZStorage.config; // config.load(); // // final String OPTIONS = config.CATEGORY_GENERAL + config.CATEGORY_SPLITTER + "options"; // // basicCapacity = config.getInt("Basic Storage Capacity", OPTIONS, 400, 100, 4000, "Basic"); // condensedCapacity = config.getInt("Condensed Storage Capacity", OPTIONS, 4000, 100, 40000, "Condensed"); // hyperCapacity = config.getInt("Hyper Storage Capacity", OPTIONS, 400000, 100, 4000000, "Hyper"); // if (config.hasChanged()) { // config.save(); // } // } // } // Path: src/main/java/com/zerofall/ezstorage/block/BlockHyperStorage.java import com.zerofall.ezstorage.configuration.EZConfiguration; import net.minecraft.block.material.Material; package com.zerofall.ezstorage.block; public class BlockHyperStorage extends BlockStorage { public BlockHyperStorage() { super("hyper_storage_box", Material.iron); } @Override public int getCapacity() {
return EZConfiguration.hyperCapacity;
zerofall/EZStorage
src/main/java/com/zerofall/ezstorage/EZTab.java
// Path: src/main/java/com/zerofall/ezstorage/init/EZBlocks.java // public class EZBlocks { // // public static Block storage_core; // public static Block storage_box; // public static Block condensed_storage_box; // public static Block hyper_storage_box; // public static Block input_port; // public static Block output_port; // public static Block crafting_box; // public static Block search_box; // // public static void init() // { // storage_core = new BlockStorageCore(); // storage_box = new BlockStorage(); // condensed_storage_box = new BlockCondensedStorage(); // hyper_storage_box = new BlockHyperStorage(); // input_port = new BlockInputPort(); // output_port = new BlockOutputPort(); // crafting_box = new BlockCraftingBox(); // search_box = new BlockSearchBox(); // } // // public static void register() // { // GameRegistry.registerBlock(storage_core, storage_core.getUnlocalizedName().substring(5)); // GameRegistry.registerTileEntity(TileEntityStorageCore.class, "TileEntityStorageCore"); // GameRegistry.registerBlock(storage_box, storage_box.getUnlocalizedName().substring(5)); // GameRegistry.registerBlock(condensed_storage_box, condensed_storage_box.getUnlocalizedName().substring(5)); // GameRegistry.registerBlock(hyper_storage_box, hyper_storage_box.getUnlocalizedName().substring(5)); // GameRegistry.registerBlock(input_port, input_port.getUnlocalizedName().substring(5)); // GameRegistry.registerTileEntity(TileEntityInputPort.class, "TileEntityInputPort"); // GameRegistry.registerBlock(output_port, output_port.getUnlocalizedName().substring(5)); // GameRegistry.registerTileEntity(TileEntityOutputPort.class, "TileEntityOutputPort"); // GameRegistry.registerBlock(crafting_box, crafting_box.getUnlocalizedName().substring(5)); // GameRegistry.registerBlock(search_box, search_box.getUnlocalizedName().substring(5)); // registerRecipes(); // } // // public static void registerRenders() // { // registerRender(storage_core); // registerRender(storage_box); // registerRender(condensed_storage_box); // registerRender(hyper_storage_box); // registerRender(input_port); // registerRender(output_port); // registerRender(crafting_box); // registerRender(search_box); // } // // public static void registerRender(Block block) // { // Item item = Item.getItemFromBlock(block); // Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register(item, 0, new ModelResourceLocation(Reference.MOD_ID + ":" + item.getUnlocalizedName().substring(5), "inventory")); // } // // public static void registerRecipes() { // GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(storage_core), // "ABA", // "BCB", // "ABA", // 'A', "logWood", 'B', "stickWood", 'C', Blocks.chest)); // GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(storage_box), // "ABA", // "B B", // "ABA", // 'A', "logWood", 'B', Blocks.chest)); // GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(condensed_storage_box), // "ACA", // "CBC", // "ACA", // 'A', "blockIron", 'B', storage_box, 'C', Blocks.iron_bars)); // GameRegistry.addRecipe(new ItemStack(hyper_storage_box), // "ABA", // "ACA", // "AAA", // 'A', Blocks.obsidian, 'B', Items.nether_star, 'C', condensed_storage_box); // GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(input_port), // "ABA", // "BCB", // "ABA", // 'A', Blocks.hopper, 'B', Blocks.piston, 'C', "blockQuartz")); // GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(output_port), // "A", // "B", // "A", // 'A', Blocks.piston, 'B', input_port)); // GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(crafting_box), // "ABA", // "BCB", // "ABA", // 'A', Items.ender_eye, 'B', Blocks.crafting_table, 'C', "gemDiamond")); // GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(search_box), // "ABA", // "BCB", // "ABA", // 'A', "blockIron", 'B', Items.enchanted_book, 'C', Items.compass)); // } // }
import com.zerofall.ezstorage.init.EZBlocks; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.init.Items; import net.minecraft.item.Item; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly;
package com.zerofall.ezstorage; public class EZTab extends CreativeTabs { public EZTab() { super("EZStorage"); } @Override @SideOnly(Side.CLIENT) public Item getTabIconItem() {
// Path: src/main/java/com/zerofall/ezstorage/init/EZBlocks.java // public class EZBlocks { // // public static Block storage_core; // public static Block storage_box; // public static Block condensed_storage_box; // public static Block hyper_storage_box; // public static Block input_port; // public static Block output_port; // public static Block crafting_box; // public static Block search_box; // // public static void init() // { // storage_core = new BlockStorageCore(); // storage_box = new BlockStorage(); // condensed_storage_box = new BlockCondensedStorage(); // hyper_storage_box = new BlockHyperStorage(); // input_port = new BlockInputPort(); // output_port = new BlockOutputPort(); // crafting_box = new BlockCraftingBox(); // search_box = new BlockSearchBox(); // } // // public static void register() // { // GameRegistry.registerBlock(storage_core, storage_core.getUnlocalizedName().substring(5)); // GameRegistry.registerTileEntity(TileEntityStorageCore.class, "TileEntityStorageCore"); // GameRegistry.registerBlock(storage_box, storage_box.getUnlocalizedName().substring(5)); // GameRegistry.registerBlock(condensed_storage_box, condensed_storage_box.getUnlocalizedName().substring(5)); // GameRegistry.registerBlock(hyper_storage_box, hyper_storage_box.getUnlocalizedName().substring(5)); // GameRegistry.registerBlock(input_port, input_port.getUnlocalizedName().substring(5)); // GameRegistry.registerTileEntity(TileEntityInputPort.class, "TileEntityInputPort"); // GameRegistry.registerBlock(output_port, output_port.getUnlocalizedName().substring(5)); // GameRegistry.registerTileEntity(TileEntityOutputPort.class, "TileEntityOutputPort"); // GameRegistry.registerBlock(crafting_box, crafting_box.getUnlocalizedName().substring(5)); // GameRegistry.registerBlock(search_box, search_box.getUnlocalizedName().substring(5)); // registerRecipes(); // } // // public static void registerRenders() // { // registerRender(storage_core); // registerRender(storage_box); // registerRender(condensed_storage_box); // registerRender(hyper_storage_box); // registerRender(input_port); // registerRender(output_port); // registerRender(crafting_box); // registerRender(search_box); // } // // public static void registerRender(Block block) // { // Item item = Item.getItemFromBlock(block); // Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register(item, 0, new ModelResourceLocation(Reference.MOD_ID + ":" + item.getUnlocalizedName().substring(5), "inventory")); // } // // public static void registerRecipes() { // GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(storage_core), // "ABA", // "BCB", // "ABA", // 'A', "logWood", 'B', "stickWood", 'C', Blocks.chest)); // GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(storage_box), // "ABA", // "B B", // "ABA", // 'A', "logWood", 'B', Blocks.chest)); // GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(condensed_storage_box), // "ACA", // "CBC", // "ACA", // 'A', "blockIron", 'B', storage_box, 'C', Blocks.iron_bars)); // GameRegistry.addRecipe(new ItemStack(hyper_storage_box), // "ABA", // "ACA", // "AAA", // 'A', Blocks.obsidian, 'B', Items.nether_star, 'C', condensed_storage_box); // GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(input_port), // "ABA", // "BCB", // "ABA", // 'A', Blocks.hopper, 'B', Blocks.piston, 'C', "blockQuartz")); // GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(output_port), // "A", // "B", // "A", // 'A', Blocks.piston, 'B', input_port)); // GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(crafting_box), // "ABA", // "BCB", // "ABA", // 'A', Items.ender_eye, 'B', Blocks.crafting_table, 'C', "gemDiamond")); // GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(search_box), // "ABA", // "BCB", // "ABA", // 'A', "blockIron", 'B', Items.enchanted_book, 'C', Items.compass)); // } // } // Path: src/main/java/com/zerofall/ezstorage/EZTab.java import com.zerofall.ezstorage.init.EZBlocks; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.init.Items; import net.minecraft.item.Item; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; package com.zerofall.ezstorage; public class EZTab extends CreativeTabs { public EZTab() { super("EZStorage"); } @Override @SideOnly(Side.CLIENT) public Item getTabIconItem() {
return Item.getItemFromBlock(EZBlocks.condensed_storage_box);
zerofall/EZStorage
src/main/java/com/zerofall/ezstorage/block/BlockCondensedStorage.java
// Path: src/main/java/com/zerofall/ezstorage/configuration/EZConfiguration.java // public class EZConfiguration { // // public static int basicCapacity; // public static int condensedCapacity; // public static int hyperCapacity; // // public static void syncConfig() { // final Configuration config = EZStorage.config; // config.load(); // // final String OPTIONS = config.CATEGORY_GENERAL + config.CATEGORY_SPLITTER + "options"; // // basicCapacity = config.getInt("Basic Storage Capacity", OPTIONS, 400, 100, 4000, "Basic"); // condensedCapacity = config.getInt("Condensed Storage Capacity", OPTIONS, 4000, 100, 40000, "Condensed"); // hyperCapacity = config.getInt("Hyper Storage Capacity", OPTIONS, 400000, 100, 4000000, "Hyper"); // if (config.hasChanged()) { // config.save(); // } // } // }
import com.zerofall.ezstorage.configuration.EZConfiguration; import net.minecraft.block.material.Material;
package com.zerofall.ezstorage.block; public class BlockCondensedStorage extends BlockStorage { public BlockCondensedStorage() { super("condensed_storage_box", Material.iron); } @Override public int getCapacity() {
// Path: src/main/java/com/zerofall/ezstorage/configuration/EZConfiguration.java // public class EZConfiguration { // // public static int basicCapacity; // public static int condensedCapacity; // public static int hyperCapacity; // // public static void syncConfig() { // final Configuration config = EZStorage.config; // config.load(); // // final String OPTIONS = config.CATEGORY_GENERAL + config.CATEGORY_SPLITTER + "options"; // // basicCapacity = config.getInt("Basic Storage Capacity", OPTIONS, 400, 100, 4000, "Basic"); // condensedCapacity = config.getInt("Condensed Storage Capacity", OPTIONS, 4000, 100, 40000, "Condensed"); // hyperCapacity = config.getInt("Hyper Storage Capacity", OPTIONS, 400000, 100, 4000000, "Hyper"); // if (config.hasChanged()) { // config.save(); // } // } // } // Path: src/main/java/com/zerofall/ezstorage/block/BlockCondensedStorage.java import com.zerofall.ezstorage.configuration.EZConfiguration; import net.minecraft.block.material.Material; package com.zerofall.ezstorage.block; public class BlockCondensedStorage extends BlockStorage { public BlockCondensedStorage() { super("condensed_storage_box", Material.iron); } @Override public int getCapacity() {
return EZConfiguration.condensedCapacity;
zerofall/EZStorage
src/main/java/com/zerofall/ezstorage/network/PacketHandler.java
// Path: src/main/java/com/zerofall/ezstorage/container/ContainerStorageCore.java // public class ContainerStorageCore extends Container { // // public TileEntityStorageCore tileEntity; // // public ContainerStorageCore(EntityPlayer player, World world, int x, int y, int z) { // this.tileEntity = ((TileEntityStorageCore)world.getTileEntity(new BlockPos(x, y, z))); // int startingY = 18; // int startingX = 8; // IInventory inventory = new InventoryBasic("title", false, this.rowCount()*9); // for (int i = 0; i < this.rowCount(); i++) { // for (int j = 0; j < 9; j++) { // int test1 = j + i * 9; // addSlotToContainer(new Slot(inventory, j + i * 9, startingX + j * 18, startingY + i * 18)); // } // } // // bindPlayerInventory(player.inventory); // } // // protected void bindPlayerInventory(InventoryPlayer inventoryPlayer) { // for (int i = 0; i < 3; i++) { // for (int j = 0; j < 9; j++) { // int test2 = (j + i * 9) + this.rowCount() * 9; // addSlotToContainer(new Slot(inventoryPlayer, (j + i * 9) + 9, // playerInventoryX() + j * 18, playerInventoryY() + i * 18)); // } // } // // for (int i = 0; i < 9; i++) { // addSlotToContainer(new Slot(inventoryPlayer, i, playerInventoryX() + i * 18, playerInventoryY() + 58)); // } // } // // @Override // public boolean canInteractWith(EntityPlayer playerIn) { // return true; // } // // //Shift clicking // @Override // public ItemStack transferStackInSlot(EntityPlayer playerIn, int index) { // ItemStack stack = null; // Slot slotObject = (Slot) inventorySlots.get(index); // if (slotObject != null && slotObject.getHasStack()) { // ItemStack stackInSlot = slotObject.getStack(); // slotObject.putStack(this.tileEntity.inventory.input(stackInSlot)); // } // return null; // } // // @Override // public ItemStack slotClick(int slotId, int clickedButton, int mode, // EntityPlayer playerIn) { // if (slotId < this.rowCount()*9 && slotId >= 0) { // return null; // } // return super.slotClick(slotId, clickedButton, mode, playerIn); // } // // public ItemStack customSlotClick(int slotId, int clickedButton, int mode, // EntityPlayer playerIn) { // int itemIndex = slotId; // ItemStack heldStack = playerIn.inventory.getItemStack(); // if (heldStack == null) { // int type = 0; // if (clickedButton == 1) { // type = 1; // } // ItemStack stack = this.tileEntity.inventory.getItemsAt(itemIndex, type); // if (stack == null) { // return null; // } // //Shift click // if (clickedButton == 0 && mode == 1) { // if (!this.mergeItemStack(stack, this.rowCount()*9, this.rowCount()*9+36, true)) { // this.tileEntity.inventory.input(stack); // } // } else { // playerIn.inventory.setItemStack(stack); // } // return stack; // } else { // playerIn.inventory.setItemStack(this.tileEntity.inventory.input(heldStack)); // } // return null; // } // // protected int playerInventoryX() { // return 8; // } // // protected int playerInventoryY() { // return 140; // } // // protected int rowCount() { // return 6; // } // // @Override // public void onContainerClosed(EntityPlayer playerIn) { // super.onContainerClosed(playerIn); // if (!playerIn.worldObj.isRemote) { // this.tileEntity.sortInventory(); // } // } // }
import com.zerofall.ezstorage.container.ContainerStorageCore; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.Container; import net.minecraft.util.BlockPos; import net.minecraftforge.fml.common.network.simpleimpl.IMessage; import net.minecraftforge.fml.common.network.simpleimpl.IMessageHandler; import net.minecraftforge.fml.common.network.simpleimpl.MessageContext;
package com.zerofall.ezstorage.network; public class PacketHandler implements IMessageHandler<MyMessage, IMessage> { @Override public IMessage onMessage(MyMessage message, MessageContext ctx) { EntityPlayer player = ctx.getServerHandler().playerEntity; Container container = player.openContainer;
// Path: src/main/java/com/zerofall/ezstorage/container/ContainerStorageCore.java // public class ContainerStorageCore extends Container { // // public TileEntityStorageCore tileEntity; // // public ContainerStorageCore(EntityPlayer player, World world, int x, int y, int z) { // this.tileEntity = ((TileEntityStorageCore)world.getTileEntity(new BlockPos(x, y, z))); // int startingY = 18; // int startingX = 8; // IInventory inventory = new InventoryBasic("title", false, this.rowCount()*9); // for (int i = 0; i < this.rowCount(); i++) { // for (int j = 0; j < 9; j++) { // int test1 = j + i * 9; // addSlotToContainer(new Slot(inventory, j + i * 9, startingX + j * 18, startingY + i * 18)); // } // } // // bindPlayerInventory(player.inventory); // } // // protected void bindPlayerInventory(InventoryPlayer inventoryPlayer) { // for (int i = 0; i < 3; i++) { // for (int j = 0; j < 9; j++) { // int test2 = (j + i * 9) + this.rowCount() * 9; // addSlotToContainer(new Slot(inventoryPlayer, (j + i * 9) + 9, // playerInventoryX() + j * 18, playerInventoryY() + i * 18)); // } // } // // for (int i = 0; i < 9; i++) { // addSlotToContainer(new Slot(inventoryPlayer, i, playerInventoryX() + i * 18, playerInventoryY() + 58)); // } // } // // @Override // public boolean canInteractWith(EntityPlayer playerIn) { // return true; // } // // //Shift clicking // @Override // public ItemStack transferStackInSlot(EntityPlayer playerIn, int index) { // ItemStack stack = null; // Slot slotObject = (Slot) inventorySlots.get(index); // if (slotObject != null && slotObject.getHasStack()) { // ItemStack stackInSlot = slotObject.getStack(); // slotObject.putStack(this.tileEntity.inventory.input(stackInSlot)); // } // return null; // } // // @Override // public ItemStack slotClick(int slotId, int clickedButton, int mode, // EntityPlayer playerIn) { // if (slotId < this.rowCount()*9 && slotId >= 0) { // return null; // } // return super.slotClick(slotId, clickedButton, mode, playerIn); // } // // public ItemStack customSlotClick(int slotId, int clickedButton, int mode, // EntityPlayer playerIn) { // int itemIndex = slotId; // ItemStack heldStack = playerIn.inventory.getItemStack(); // if (heldStack == null) { // int type = 0; // if (clickedButton == 1) { // type = 1; // } // ItemStack stack = this.tileEntity.inventory.getItemsAt(itemIndex, type); // if (stack == null) { // return null; // } // //Shift click // if (clickedButton == 0 && mode == 1) { // if (!this.mergeItemStack(stack, this.rowCount()*9, this.rowCount()*9+36, true)) { // this.tileEntity.inventory.input(stack); // } // } else { // playerIn.inventory.setItemStack(stack); // } // return stack; // } else { // playerIn.inventory.setItemStack(this.tileEntity.inventory.input(heldStack)); // } // return null; // } // // protected int playerInventoryX() { // return 8; // } // // protected int playerInventoryY() { // return 140; // } // // protected int rowCount() { // return 6; // } // // @Override // public void onContainerClosed(EntityPlayer playerIn) { // super.onContainerClosed(playerIn); // if (!playerIn.worldObj.isRemote) { // this.tileEntity.sortInventory(); // } // } // } // Path: src/main/java/com/zerofall/ezstorage/network/PacketHandler.java import com.zerofall.ezstorage.container.ContainerStorageCore; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.Container; import net.minecraft.util.BlockPos; import net.minecraftforge.fml.common.network.simpleimpl.IMessage; import net.minecraftforge.fml.common.network.simpleimpl.IMessageHandler; import net.minecraftforge.fml.common.network.simpleimpl.MessageContext; package com.zerofall.ezstorage.network; public class PacketHandler implements IMessageHandler<MyMessage, IMessage> { @Override public IMessage onMessage(MyMessage message, MessageContext ctx) { EntityPlayer player = ctx.getServerHandler().playerEntity; Container container = player.openContainer;
if (container != null && container instanceof ContainerStorageCore) {
zerofall/EZStorage
src/main/java/com/zerofall/ezstorage/block/BlockStorage.java
// Path: src/main/java/com/zerofall/ezstorage/configuration/EZConfiguration.java // public class EZConfiguration { // // public static int basicCapacity; // public static int condensedCapacity; // public static int hyperCapacity; // // public static void syncConfig() { // final Configuration config = EZStorage.config; // config.load(); // // final String OPTIONS = config.CATEGORY_GENERAL + config.CATEGORY_SPLITTER + "options"; // // basicCapacity = config.getInt("Basic Storage Capacity", OPTIONS, 400, 100, 4000, "Basic"); // condensedCapacity = config.getInt("Condensed Storage Capacity", OPTIONS, 4000, 100, 40000, "Condensed"); // hyperCapacity = config.getInt("Hyper Storage Capacity", OPTIONS, 400000, 100, 4000000, "Hyper"); // if (config.hasChanged()) { // config.save(); // } // } // }
import com.zerofall.ezstorage.configuration.EZConfiguration; import net.minecraft.block.material.Material;
package com.zerofall.ezstorage.block; public class BlockStorage extends StorageMultiblock { public BlockStorage() { super("storage_box", Material.wood); } public BlockStorage(String name, Material material) { super(name, material); } public int getCapacity() {
// Path: src/main/java/com/zerofall/ezstorage/configuration/EZConfiguration.java // public class EZConfiguration { // // public static int basicCapacity; // public static int condensedCapacity; // public static int hyperCapacity; // // public static void syncConfig() { // final Configuration config = EZStorage.config; // config.load(); // // final String OPTIONS = config.CATEGORY_GENERAL + config.CATEGORY_SPLITTER + "options"; // // basicCapacity = config.getInt("Basic Storage Capacity", OPTIONS, 400, 100, 4000, "Basic"); // condensedCapacity = config.getInt("Condensed Storage Capacity", OPTIONS, 4000, 100, 40000, "Condensed"); // hyperCapacity = config.getInt("Hyper Storage Capacity", OPTIONS, 400000, 100, 4000000, "Hyper"); // if (config.hasChanged()) { // config.save(); // } // } // } // Path: src/main/java/com/zerofall/ezstorage/block/BlockStorage.java import com.zerofall.ezstorage.configuration.EZConfiguration; import net.minecraft.block.material.Material; package com.zerofall.ezstorage.block; public class BlockStorage extends StorageMultiblock { public BlockStorage() { super("storage_box", Material.wood); } public BlockStorage(String name, Material material) { super(name, material); } public int getCapacity() {
return EZConfiguration.basicCapacity;
zerofall/EZStorage
src/main/java/com/zerofall/ezstorage/block/EZBlockContainer.java
// Path: src/main/java/com/zerofall/ezstorage/EZStorage.java // @Mod(modid = Reference.MOD_ID, name = Reference.MOD_NAME, version = Reference.VERSION, acceptedMinecraftVersions="[1.8.8]") // public class EZStorage // { // @Mod.Instance(Reference.MOD_ID) // public static EZStorage instance; // @SidedProxy(clientSide = Reference.CLIENT_PROXY_CLASS, serverSide = Reference.SERVER_PROXY_CLASS) // public static CommonProxy proxy; // public static SimpleNetworkWrapper networkWrapper; // public static Configuration config; // // public EZTab creativeTab; // // @EventHandler // public void preInit(FMLPreInitializationEvent event) { // config = new Configuration(event.getSuggestedConfigurationFile()); // EZConfiguration.syncConfig(); // this.creativeTab = new EZTab(); // EZBlocks.init(); // EZBlocks.register(); // NetworkRegistry.INSTANCE.registerGuiHandler(this, new GuiHandler()); // networkWrapper = NetworkRegistry.INSTANCE.newSimpleChannel("ezChannel"); // networkWrapper.registerMessage(PacketHandler.class, MyMessage.class, 0, Side.SERVER); // networkWrapper.registerMessage(RecipePacketHandler.class, RecipeMessage.class, 1, Side.SERVER); // MinecraftForge.EVENT_BUS.register(new XEventHandler()); // } // // @EventHandler // public void init(FMLInitializationEvent event) { // proxy.registerRenders(); // } // // }
import net.minecraft.block.ITileEntityProvider; import net.minecraft.block.material.Material; import net.minecraft.block.state.IBlockState; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.BlockPos; import net.minecraft.world.World; import com.zerofall.ezstorage.EZStorage;
package com.zerofall.ezstorage.block; public class EZBlockContainer extends StorageMultiblock implements ITileEntityProvider { protected EZBlockContainer(String name, Material materialIn) { super(name, materialIn); this.setUnlocalizedName(name);
// Path: src/main/java/com/zerofall/ezstorage/EZStorage.java // @Mod(modid = Reference.MOD_ID, name = Reference.MOD_NAME, version = Reference.VERSION, acceptedMinecraftVersions="[1.8.8]") // public class EZStorage // { // @Mod.Instance(Reference.MOD_ID) // public static EZStorage instance; // @SidedProxy(clientSide = Reference.CLIENT_PROXY_CLASS, serverSide = Reference.SERVER_PROXY_CLASS) // public static CommonProxy proxy; // public static SimpleNetworkWrapper networkWrapper; // public static Configuration config; // // public EZTab creativeTab; // // @EventHandler // public void preInit(FMLPreInitializationEvent event) { // config = new Configuration(event.getSuggestedConfigurationFile()); // EZConfiguration.syncConfig(); // this.creativeTab = new EZTab(); // EZBlocks.init(); // EZBlocks.register(); // NetworkRegistry.INSTANCE.registerGuiHandler(this, new GuiHandler()); // networkWrapper = NetworkRegistry.INSTANCE.newSimpleChannel("ezChannel"); // networkWrapper.registerMessage(PacketHandler.class, MyMessage.class, 0, Side.SERVER); // networkWrapper.registerMessage(RecipePacketHandler.class, RecipeMessage.class, 1, Side.SERVER); // MinecraftForge.EVENT_BUS.register(new XEventHandler()); // } // // @EventHandler // public void init(FMLInitializationEvent event) { // proxy.registerRenders(); // } // // } // Path: src/main/java/com/zerofall/ezstorage/block/EZBlockContainer.java import net.minecraft.block.ITileEntityProvider; import net.minecraft.block.material.Material; import net.minecraft.block.state.IBlockState; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.BlockPos; import net.minecraft.world.World; import com.zerofall.ezstorage.EZStorage; package com.zerofall.ezstorage.block; public class EZBlockContainer extends StorageMultiblock implements ITileEntityProvider { protected EZBlockContainer(String name, Material materialIn) { super(name, materialIn); this.setUnlocalizedName(name);
this.setCreativeTab(EZStorage.instance.creativeTab);
quemb/QMBForm
lib/QMBForm/src/main/java/com/quemb/qmbform/descriptor/RowDescriptor.java
// Path: lib/QMBForm/src/main/java/com/quemb/qmbform/annotation/FormDescriptorAnnotationFactory.java // public static ArrayList<FormOptionsObject> convertFormOptionsAnnotation(FormOptionsObjectElement[] options) { // ArrayList<FormOptionsObject> optionsArrayList = new ArrayList<FormOptionsObject>(); // for (FormOptionsObjectElement option : options) { // if (option.valueType() == FormOptionsObjectElement.ValueTypes.INT) { // optionsArrayList.add(FormOptionsObject.createFormOptionsObject(Integer.valueOf(option.value()), option.displayText())); // } else if (option.valueType() == FormOptionsObjectElement.ValueTypes.DOUBLE) { // optionsArrayList.add(FormOptionsObject.createFormOptionsObject(Double.valueOf(option.value()), option.displayText())); // } else { // optionsArrayList.add(FormOptionsObject.createFormOptionsObject(option.value(), option.displayText())); // } // } // return optionsArrayList; // }
import com.quemb.qmbform.R; import com.quemb.qmbform.annotation.FormElement; import com.quemb.qmbform.annotation.FormValidator; import android.content.Context; import java.lang.reflect.Field; import java.util.ArrayList; import java.util.List; import static com.quemb.qmbform.annotation.FormDescriptorAnnotationFactory.convertFormOptionsAnnotation;
public static RowDescriptor newInstance(String tag, String rowType, String title) { return RowDescriptor.newInstance(tag, rowType, title, null); } public static RowDescriptor newInstance(String tag, String rowType, String title, Value<?> value) { RowDescriptor descriptor = new RowDescriptor(); descriptor.mTitle = title; descriptor.mTag = tag; descriptor.mRowType = rowType; descriptor.setValue(value); descriptor.mValidators = new ArrayList<FormValidator>(); return descriptor; } public static RowDescriptor newInstanceFromAnnotatedField(Field field, Value value, Context context) { FormElement annotation = field.getAnnotation(FormElement.class); RowDescriptor rowDescriptor = RowDescriptor.newInstance( annotation.tag().length() > 0 ? annotation.tag() : field.getName(), annotation.rowDescriptorType(), context.getString(annotation.label()), value); rowDescriptor.setHint(annotation.hint()); rowDescriptor.setRequired(annotation.required()); rowDescriptor.setDisabled(annotation.disabled());
// Path: lib/QMBForm/src/main/java/com/quemb/qmbform/annotation/FormDescriptorAnnotationFactory.java // public static ArrayList<FormOptionsObject> convertFormOptionsAnnotation(FormOptionsObjectElement[] options) { // ArrayList<FormOptionsObject> optionsArrayList = new ArrayList<FormOptionsObject>(); // for (FormOptionsObjectElement option : options) { // if (option.valueType() == FormOptionsObjectElement.ValueTypes.INT) { // optionsArrayList.add(FormOptionsObject.createFormOptionsObject(Integer.valueOf(option.value()), option.displayText())); // } else if (option.valueType() == FormOptionsObjectElement.ValueTypes.DOUBLE) { // optionsArrayList.add(FormOptionsObject.createFormOptionsObject(Double.valueOf(option.value()), option.displayText())); // } else { // optionsArrayList.add(FormOptionsObject.createFormOptionsObject(option.value(), option.displayText())); // } // } // return optionsArrayList; // } // Path: lib/QMBForm/src/main/java/com/quemb/qmbform/descriptor/RowDescriptor.java import com.quemb.qmbform.R; import com.quemb.qmbform.annotation.FormElement; import com.quemb.qmbform.annotation.FormValidator; import android.content.Context; import java.lang.reflect.Field; import java.util.ArrayList; import java.util.List; import static com.quemb.qmbform.annotation.FormDescriptorAnnotationFactory.convertFormOptionsAnnotation; public static RowDescriptor newInstance(String tag, String rowType, String title) { return RowDescriptor.newInstance(tag, rowType, title, null); } public static RowDescriptor newInstance(String tag, String rowType, String title, Value<?> value) { RowDescriptor descriptor = new RowDescriptor(); descriptor.mTitle = title; descriptor.mTag = tag; descriptor.mRowType = rowType; descriptor.setValue(value); descriptor.mValidators = new ArrayList<FormValidator>(); return descriptor; } public static RowDescriptor newInstanceFromAnnotatedField(Field field, Value value, Context context) { FormElement annotation = field.getAnnotation(FormElement.class); RowDescriptor rowDescriptor = RowDescriptor.newInstance( annotation.tag().length() > 0 ? annotation.tag() : field.getName(), annotation.rowDescriptorType(), context.getString(annotation.label()), value); rowDescriptor.setHint(annotation.hint()); rowDescriptor.setRequired(annotation.required()); rowDescriptor.setDisabled(annotation.disabled());
rowDescriptor.setSelectorOptions(convertFormOptionsAnnotation(
bodar/yatspec
test/com/googlecode/yatspec/rendering/wiki/WikiResultRendererTest.java
// Path: src/com/googlecode/yatspec/state/TestResult.java // @SuppressWarnings({"unused"}) // public class TestResult implements Result { // private final Class<?> klass; // private List<TestMethod> testMethods; // // public TestResult(Class<?> klass) { // this.klass = klass; // } // // @Override // public Class<?> getTestClass() { // return klass; // } // // @Override // public List<TestMethod> getTestMethods() throws Exception { // if (testMethods == null) { // testMethods = TestParser.parseTestMethods(klass); // } // return testMethods; // } // // @Override // public Scenario getScenario(String name) throws Exception { // final Scenario testScenario = findScenario(name); // testScenario.hasRun(true); // return testScenario; // } // // @Override // public String getName() { // String className = getTestClass().getSimpleName(); // if (className.endsWith("Test")) { // className = removeTestFrom(className); // } // return wordify(className); // } // // @Override // public String getPackageName() { // return getTestClass().getPackage().getName(); // } // // private static String removeTestFrom(String className) { // final int index = className.lastIndexOf("Test"); // return className.substring(0, index); // } // // private Scenario findScenario(final String name) throws Exception { // return sequence(getTestMethods()).filter(hasScenario(name)).head().getScenario(name); // } // // private static Predicate<TestMethod> hasScenario(final String name) { // return new Predicate<TestMethod>() { // public boolean matches(TestMethod testMethod) { // return testMethod.hasScenario(name); // } // }; // } // // public List<Annotation> getAnnotations() { // return yatspecAnnotations(asList(getTestClass().getAnnotations())); // } // }
import com.googlecode.yatspec.state.TestResult; import org.junit.Test; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.containsString;
package com.googlecode.yatspec.rendering.wiki; public class WikiResultRendererTest { @Test public void preservesJavaFormatting() throws Exception {
// Path: src/com/googlecode/yatspec/state/TestResult.java // @SuppressWarnings({"unused"}) // public class TestResult implements Result { // private final Class<?> klass; // private List<TestMethod> testMethods; // // public TestResult(Class<?> klass) { // this.klass = klass; // } // // @Override // public Class<?> getTestClass() { // return klass; // } // // @Override // public List<TestMethod> getTestMethods() throws Exception { // if (testMethods == null) { // testMethods = TestParser.parseTestMethods(klass); // } // return testMethods; // } // // @Override // public Scenario getScenario(String name) throws Exception { // final Scenario testScenario = findScenario(name); // testScenario.hasRun(true); // return testScenario; // } // // @Override // public String getName() { // String className = getTestClass().getSimpleName(); // if (className.endsWith("Test")) { // className = removeTestFrom(className); // } // return wordify(className); // } // // @Override // public String getPackageName() { // return getTestClass().getPackage().getName(); // } // // private static String removeTestFrom(String className) { // final int index = className.lastIndexOf("Test"); // return className.substring(0, index); // } // // private Scenario findScenario(final String name) throws Exception { // return sequence(getTestMethods()).filter(hasScenario(name)).head().getScenario(name); // } // // private static Predicate<TestMethod> hasScenario(final String name) { // return new Predicate<TestMethod>() { // public boolean matches(TestMethod testMethod) { // return testMethod.hasScenario(name); // } // }; // } // // public List<Annotation> getAnnotations() { // return yatspecAnnotations(asList(getTestClass().getAnnotations())); // } // } // Path: test/com/googlecode/yatspec/rendering/wiki/WikiResultRendererTest.java import com.googlecode.yatspec.state.TestResult; import org.junit.Test; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.containsString; package com.googlecode.yatspec.rendering.wiki; public class WikiResultRendererTest { @Test public void preservesJavaFormatting() throws Exception {
String result = new WikiResultRenderer().render(new TestResult(getClass()));
bodar/yatspec
src/com/googlecode/yatspec/rendering/ScenarioTableHeaderRenderer.java
// Path: src/com/googlecode/yatspec/state/ScenarioTableHeader.java // public class ScenarioTableHeader implements Value<String> { // private final String header; // // public ScenarioTableHeader(String header) { // this.header = header; // } // // @Override // public String value() { // return header; // } // // public static Callable1<? super String, ScenarioTableHeader> toScenarioTableHeader() { // return new Callable1<String, ScenarioTableHeader>() { // @Override // public ScenarioTableHeader call(String value) throws Exception { // return new ScenarioTableHeader(value); // } // }; // } // // // } // // Path: src/com/googlecode/yatspec/parsing/Text.java // public static String wordify(String value) { // final String wordified = quotedStrings.findMatches(value).replace(wordifier, doNothing); // return Strings.capitalise(spaceRemover.matcher(wordified).replaceAll(" ").trim()); // }
import com.googlecode.yatspec.state.ScenarioTableHeader; import static com.googlecode.yatspec.parsing.Text.wordify;
package com.googlecode.yatspec.rendering; public class ScenarioTableHeaderRenderer implements Renderer<ScenarioTableHeader>{ @Override public String render(ScenarioTableHeader header) throws Exception {
// Path: src/com/googlecode/yatspec/state/ScenarioTableHeader.java // public class ScenarioTableHeader implements Value<String> { // private final String header; // // public ScenarioTableHeader(String header) { // this.header = header; // } // // @Override // public String value() { // return header; // } // // public static Callable1<? super String, ScenarioTableHeader> toScenarioTableHeader() { // return new Callable1<String, ScenarioTableHeader>() { // @Override // public ScenarioTableHeader call(String value) throws Exception { // return new ScenarioTableHeader(value); // } // }; // } // // // } // // Path: src/com/googlecode/yatspec/parsing/Text.java // public static String wordify(String value) { // final String wordified = quotedStrings.findMatches(value).replace(wordifier, doNothing); // return Strings.capitalise(spaceRemover.matcher(wordified).replaceAll(" ").trim()); // } // Path: src/com/googlecode/yatspec/rendering/ScenarioTableHeaderRenderer.java import com.googlecode.yatspec.state.ScenarioTableHeader; import static com.googlecode.yatspec.parsing.Text.wordify; package com.googlecode.yatspec.rendering; public class ScenarioTableHeaderRenderer implements Renderer<ScenarioTableHeader>{ @Override public String render(ScenarioTableHeader header) throws Exception {
return wordify(header.value());
bodar/yatspec
src/com/googlecode/yatspec/plugin/sequencediagram/SequenceDiagramGenerator.java
// Path: src/com/googlecode/yatspec/rendering/Content.java // public interface Content { // String toString(); // } // // Path: src/com/googlecode/yatspec/rendering/ContentAtUrl.java // public class ContentAtUrl implements Content { // private final URL url; // // public ContentAtUrl(URL url) { // this.url = url; // } // // @Override // public String toString() { // InputStream inputStream = null; // try { // inputStream = url.openStream(); // return Strings.toString(inputStream); // } catch (IOException e) { // return e.toString(); // } finally { // closeQuietly(inputStream); // } // } // // private static void closeQuietly(InputStream inputStream) { // if (inputStream != null) { // try { // inputStream.close(); // } catch (IOException e) { // throw new RuntimeException(e); // } // } // } // }
import com.googlecode.yatspec.rendering.Content; import com.googlecode.yatspec.rendering.ContentAtUrl; import net.sourceforge.plantuml.FileFormatOption; import net.sourceforge.plantuml.SourceStringReader; import org.jdom.Document; import org.jdom.JDOMException; import org.jdom.input.SAXBuilder; import org.jdom.output.Format; import org.jdom.output.XMLOutputter; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.StringReader; import java.io.StringWriter; import static com.googlecode.totallylazy.Sequences.sequence; import static net.sourceforge.plantuml.FileFormat.SVG;
throw new RuntimeException(e); } catch (IOException e) { throw new RuntimeException(e); } } public void logPlantUmlMarkupTo(StringBuffer plantUmlCollector) { this.optionalPlantUmlCollector = plantUmlCollector; } private void makePlantUmlAvailableToAnyRegisteredCollector(String plantUmlMarkup) { if (optionalPlantUmlCollector != null) { optionalPlantUmlCollector.append(plantUmlMarkup); } } private String createSvg(String plantUmlMarkup) { SourceStringReader reader = new SourceStringReader(plantUmlMarkup); final ByteArrayOutputStream os = new ByteArrayOutputStream(); try { reader.generateImage(os, new FileFormatOption(SVG)); os.close(); } catch (IOException e) { throw new RuntimeException(e); } return new String(os.toByteArray()); }
// Path: src/com/googlecode/yatspec/rendering/Content.java // public interface Content { // String toString(); // } // // Path: src/com/googlecode/yatspec/rendering/ContentAtUrl.java // public class ContentAtUrl implements Content { // private final URL url; // // public ContentAtUrl(URL url) { // this.url = url; // } // // @Override // public String toString() { // InputStream inputStream = null; // try { // inputStream = url.openStream(); // return Strings.toString(inputStream); // } catch (IOException e) { // return e.toString(); // } finally { // closeQuietly(inputStream); // } // } // // private static void closeQuietly(InputStream inputStream) { // if (inputStream != null) { // try { // inputStream.close(); // } catch (IOException e) { // throw new RuntimeException(e); // } // } // } // } // Path: src/com/googlecode/yatspec/plugin/sequencediagram/SequenceDiagramGenerator.java import com.googlecode.yatspec.rendering.Content; import com.googlecode.yatspec.rendering.ContentAtUrl; import net.sourceforge.plantuml.FileFormatOption; import net.sourceforge.plantuml.SourceStringReader; import org.jdom.Document; import org.jdom.JDOMException; import org.jdom.input.SAXBuilder; import org.jdom.output.Format; import org.jdom.output.XMLOutputter; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.StringReader; import java.io.StringWriter; import static com.googlecode.totallylazy.Sequences.sequence; import static net.sourceforge.plantuml.FileFormat.SVG; throw new RuntimeException(e); } catch (IOException e) { throw new RuntimeException(e); } } public void logPlantUmlMarkupTo(StringBuffer plantUmlCollector) { this.optionalPlantUmlCollector = plantUmlCollector; } private void makePlantUmlAvailableToAnyRegisteredCollector(String plantUmlMarkup) { if (optionalPlantUmlCollector != null) { optionalPlantUmlCollector.append(plantUmlMarkup); } } private String createSvg(String plantUmlMarkup) { SourceStringReader reader = new SourceStringReader(plantUmlMarkup); final ByteArrayOutputStream os = new ByteArrayOutputStream(); try { reader.generateImage(os, new FileFormatOption(SVG)); os.close(); } catch (IOException e) { throw new RuntimeException(e); } return new String(os.toByteArray()); }
public static Content getHeaderContentForModalWindows() {
bodar/yatspec
src/com/googlecode/yatspec/plugin/sequencediagram/SequenceDiagramGenerator.java
// Path: src/com/googlecode/yatspec/rendering/Content.java // public interface Content { // String toString(); // } // // Path: src/com/googlecode/yatspec/rendering/ContentAtUrl.java // public class ContentAtUrl implements Content { // private final URL url; // // public ContentAtUrl(URL url) { // this.url = url; // } // // @Override // public String toString() { // InputStream inputStream = null; // try { // inputStream = url.openStream(); // return Strings.toString(inputStream); // } catch (IOException e) { // return e.toString(); // } finally { // closeQuietly(inputStream); // } // } // // private static void closeQuietly(InputStream inputStream) { // if (inputStream != null) { // try { // inputStream.close(); // } catch (IOException e) { // throw new RuntimeException(e); // } // } // } // }
import com.googlecode.yatspec.rendering.Content; import com.googlecode.yatspec.rendering.ContentAtUrl; import net.sourceforge.plantuml.FileFormatOption; import net.sourceforge.plantuml.SourceStringReader; import org.jdom.Document; import org.jdom.JDOMException; import org.jdom.input.SAXBuilder; import org.jdom.output.Format; import org.jdom.output.XMLOutputter; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.StringReader; import java.io.StringWriter; import static com.googlecode.totallylazy.Sequences.sequence; import static net.sourceforge.plantuml.FileFormat.SVG;
} catch (IOException e) { throw new RuntimeException(e); } } public void logPlantUmlMarkupTo(StringBuffer plantUmlCollector) { this.optionalPlantUmlCollector = plantUmlCollector; } private void makePlantUmlAvailableToAnyRegisteredCollector(String plantUmlMarkup) { if (optionalPlantUmlCollector != null) { optionalPlantUmlCollector.append(plantUmlMarkup); } } private String createSvg(String plantUmlMarkup) { SourceStringReader reader = new SourceStringReader(plantUmlMarkup); final ByteArrayOutputStream os = new ByteArrayOutputStream(); try { reader.generateImage(os, new FileFormatOption(SVG)); os.close(); } catch (IOException e) { throw new RuntimeException(e); } return new String(os.toByteArray()); } public static Content getHeaderContentForModalWindows() {
// Path: src/com/googlecode/yatspec/rendering/Content.java // public interface Content { // String toString(); // } // // Path: src/com/googlecode/yatspec/rendering/ContentAtUrl.java // public class ContentAtUrl implements Content { // private final URL url; // // public ContentAtUrl(URL url) { // this.url = url; // } // // @Override // public String toString() { // InputStream inputStream = null; // try { // inputStream = url.openStream(); // return Strings.toString(inputStream); // } catch (IOException e) { // return e.toString(); // } finally { // closeQuietly(inputStream); // } // } // // private static void closeQuietly(InputStream inputStream) { // if (inputStream != null) { // try { // inputStream.close(); // } catch (IOException e) { // throw new RuntimeException(e); // } // } // } // } // Path: src/com/googlecode/yatspec/plugin/sequencediagram/SequenceDiagramGenerator.java import com.googlecode.yatspec.rendering.Content; import com.googlecode.yatspec.rendering.ContentAtUrl; import net.sourceforge.plantuml.FileFormatOption; import net.sourceforge.plantuml.SourceStringReader; import org.jdom.Document; import org.jdom.JDOMException; import org.jdom.input.SAXBuilder; import org.jdom.output.Format; import org.jdom.output.XMLOutputter; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.StringReader; import java.io.StringWriter; import static com.googlecode.totallylazy.Sequences.sequence; import static net.sourceforge.plantuml.FileFormat.SVG; } catch (IOException e) { throw new RuntimeException(e); } } public void logPlantUmlMarkupTo(StringBuffer plantUmlCollector) { this.optionalPlantUmlCollector = plantUmlCollector; } private void makePlantUmlAvailableToAnyRegisteredCollector(String plantUmlMarkup) { if (optionalPlantUmlCollector != null) { optionalPlantUmlCollector.append(plantUmlMarkup); } } private String createSvg(String plantUmlMarkup) { SourceStringReader reader = new SourceStringReader(plantUmlMarkup); final ByteArrayOutputStream os = new ByteArrayOutputStream(); try { reader.generateImage(os, new FileFormatOption(SVG)); os.close(); } catch (IOException e) { throw new RuntimeException(e); } return new String(os.toByteArray()); } public static Content getHeaderContentForModalWindows() {
return new ContentAtUrl(SequenceDiagramGenerator.class.getResource("dialogScriptHeaderContent.html"));
bodar/yatspec
src/com/googlecode/yatspec/rendering/junit/MavenSurefireScenarioNameRenderer.java
// Path: src/com/googlecode/yatspec/rendering/ScenarioNameRenderer.java // public interface ScenarioNameRenderer extends Renderer<ScenarioName> { // @Override // String render(ScenarioName scenarioName); // } // // Path: src/com/googlecode/yatspec/state/ScenarioName.java // public class ScenarioName { // private final String methodName; // private final List<String> row; // // public ScenarioName(String methodName, List<String> row) { // this.methodName = methodName; // this.row = row; // } // // public String getMethodName() { // return methodName; // } // // public List<String> getRow() { // return row; // } // // public boolean hasEmptyRow() { // return getRow().isEmpty(); // } // }
import com.googlecode.yatspec.rendering.ScenarioNameRenderer; import com.googlecode.yatspec.state.ScenarioName; import static com.googlecode.totallylazy.Sequences.sequence;
package com.googlecode.yatspec.rendering.junit; public class MavenSurefireScenarioNameRenderer implements ScenarioNameRenderer { @Override
// Path: src/com/googlecode/yatspec/rendering/ScenarioNameRenderer.java // public interface ScenarioNameRenderer extends Renderer<ScenarioName> { // @Override // String render(ScenarioName scenarioName); // } // // Path: src/com/googlecode/yatspec/state/ScenarioName.java // public class ScenarioName { // private final String methodName; // private final List<String> row; // // public ScenarioName(String methodName, List<String> row) { // this.methodName = methodName; // this.row = row; // } // // public String getMethodName() { // return methodName; // } // // public List<String> getRow() { // return row; // } // // public boolean hasEmptyRow() { // return getRow().isEmpty(); // } // } // Path: src/com/googlecode/yatspec/rendering/junit/MavenSurefireScenarioNameRenderer.java import com.googlecode.yatspec.rendering.ScenarioNameRenderer; import com.googlecode.yatspec.state.ScenarioName; import static com.googlecode.totallylazy.Sequences.sequence; package com.googlecode.yatspec.rendering.junit; public class MavenSurefireScenarioNameRenderer implements ScenarioNameRenderer { @Override
public String render(ScenarioName scenarioName) {
bodar/yatspec
test/com/googlecode/yatspec/state/StatusPriorityTest.java
// Path: src/com/googlecode/yatspec/state/StatusPriority.java // public static StatusPriority statusPriority(){ // return new StatusPriority(); // }
import org.junit.Test; import static com.googlecode.yatspec.state.StatusPriority.statusPriority; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.greaterThan; import static org.hamcrest.Matchers.is; import static org.hamcrest.Matchers.lessThan;
package com.googlecode.yatspec.state; public class StatusPriorityTest { @Test public void ordersStatusesAccordingToImportance() throws Exception {
// Path: src/com/googlecode/yatspec/state/StatusPriority.java // public static StatusPriority statusPriority(){ // return new StatusPriority(); // } // Path: test/com/googlecode/yatspec/state/StatusPriorityTest.java import org.junit.Test; import static com.googlecode.yatspec.state.StatusPriority.statusPriority; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.greaterThan; import static org.hamcrest.Matchers.is; import static org.hamcrest.Matchers.lessThan; package com.googlecode.yatspec.state; public class StatusPriorityTest { @Test public void ordersStatusesAccordingToImportance() throws Exception {
assertThat(statusPriority().compare(Status.Passed, Status.Passed), is(0));
bodar/yatspec
test/com/googlecode/yatspec/plugin/sequencediagram/PlantUmlMarkupGeneratorTest.java
// Path: src/com/googlecode/yatspec/state/givenwhenthen/CapturedInputAndOutputs.java // public class CapturedInputAndOutputs extends NiceMap<CapturedInputAndOutputs>{ // public CapturedInputAndOutputs(Object... instances) { // super(instances); // } // }
import com.googlecode.yatspec.state.givenwhenthen.CapturedInputAndOutputs; import org.hamcrest.Matcher; import org.junit.Test; import static com.googlecode.totallylazy.Sequences.sequence; import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.MatcherAssert.assertThat;
package com.googlecode.yatspec.plugin.sequencediagram; public class PlantUmlMarkupGeneratorTest { @Test public void generatesPlantUmlMarkup() { String markup = new PlantUmlMarkupGenerator().generateMarkup(sequence(new SequenceDiagramMessage("Bob", "Alice", "How are you Alice?", "message_id"))); assertThat(markup, is(markupContaining("Bob ->> Alice:<text class=sequence_diagram_clickable sequence_diagram_message_id=message_id>How are you Alice?</text>"))); } @Test public void doesGroups() throws Exception {
// Path: src/com/googlecode/yatspec/state/givenwhenthen/CapturedInputAndOutputs.java // public class CapturedInputAndOutputs extends NiceMap<CapturedInputAndOutputs>{ // public CapturedInputAndOutputs(Object... instances) { // super(instances); // } // } // Path: test/com/googlecode/yatspec/plugin/sequencediagram/PlantUmlMarkupGeneratorTest.java import com.googlecode.yatspec.state.givenwhenthen.CapturedInputAndOutputs; import org.hamcrest.Matcher; import org.junit.Test; import static com.googlecode.totallylazy.Sequences.sequence; import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.MatcherAssert.assertThat; package com.googlecode.yatspec.plugin.sequencediagram; public class PlantUmlMarkupGeneratorTest { @Test public void generatesPlantUmlMarkup() { String markup = new PlantUmlMarkupGenerator().generateMarkup(sequence(new SequenceDiagramMessage("Bob", "Alice", "How are you Alice?", "message_id"))); assertThat(markup, is(markupContaining("Bob ->> Alice:<text class=sequence_diagram_clickable sequence_diagram_message_id=message_id>How are you Alice?</text>"))); } @Test public void doesGroups() throws Exception {
CapturedInputAndOutputs capturedInputAndOutputs = new CapturedInputAndOutputs();
bodar/yatspec
src/com/googlecode/yatspec/state/Scenario.java
// Path: src/com/googlecode/yatspec/parsing/JavaSource.java // public class JavaSource implements Value<String> { // private static final String COMMA_OR_OPENING_BRACKET = "(\\s*[\\(\\,\"]\\s*)"; // private static final String COMMA_OR_CLOSING_BRACKET = "(\\s*[\\,\\)\"]\\s*)"; // private final String value; // // public JavaSource(String value) { // this.value = value; // } // // @Override // public String value() { // return value; // } // // public JavaSource replace(final List<String> oldValues, final List<String> newValues) { // String result = value(); // for (int i = 0; i < oldValues.size(); i++) { // String header = oldValues.get(i); // String value = newValues.get(i); // result = result.replaceAll(COMMA_OR_OPENING_BRACKET + header + COMMA_OR_CLOSING_BRACKET, "$1" + displayValue(value) + "$2"); // } // return new JavaSource(result); // } // // private static String displayValue(String value) { // if (value.matches("[A-Z0-9]*")) { // return value; // } // return "\"" + value + "\""; // } // // @Override // public String toString() { // return value(); // } // } // // Path: src/com/googlecode/yatspec/state/givenwhenthen/CapturedInputAndOutputs.java // public class CapturedInputAndOutputs extends NiceMap<CapturedInputAndOutputs>{ // public CapturedInputAndOutputs(Object... instances) { // super(instances); // } // } // // Path: src/com/googlecode/yatspec/state/givenwhenthen/InterestingGivens.java // public class InterestingGivens extends NiceMap<InterestingGivens>{ // public InterestingGivens(Object... instances) { // super(instances); // } // } // // Path: src/com/googlecode/yatspec/state/givenwhenthen/TestState.java // @SuppressWarnings("unused") // public class TestState implements TestLogger, WithTestState { // public InterestingGivens interestingGivens = new InterestingGivens(); // public CapturedInputAndOutputs capturedInputAndOutputs = new CapturedInputAndOutputs(); // // public TestState given(GivensBuilder builder) throws Exception { // interestingGivens = builder.build(interestingGivens); // return this; // } // // public TestState and(GivensBuilder builder) throws Exception { // return given(builder); // } // // public TestState when(ActionUnderTest actionUndertest) throws Exception { // capturedInputAndOutputs = actionUndertest.execute(interestingGivens, capturedInputAndOutputs); // return this; // } // // public <ItemOfInterest> TestState then(StateExtractor<ItemOfInterest> extractor, Matcher<? super ItemOfInterest> matcher) throws Exception { // assertThat(extractor.execute(capturedInputAndOutputs), matcher); // return this; // } // // public synchronized void log(String name, Object value) { // int count = 1; // String keyName = name; // while (capturedInputAndOutputs.contains(keyName)) { // keyName = name + count; // count++; // } // capturedInputAndOutputs.add(keyName, value); // } // // public TestState testState() { // return this; // } // }
import com.googlecode.yatspec.parsing.JavaSource; import com.googlecode.yatspec.state.givenwhenthen.CapturedInputAndOutputs; import com.googlecode.yatspec.state.givenwhenthen.InterestingGivens; import com.googlecode.yatspec.state.givenwhenthen.TestState; import java.util.LinkedHashMap; import java.util.List; import java.util.Map;
package com.googlecode.yatspec.state; @SuppressWarnings("unused") public class Scenario {
// Path: src/com/googlecode/yatspec/parsing/JavaSource.java // public class JavaSource implements Value<String> { // private static final String COMMA_OR_OPENING_BRACKET = "(\\s*[\\(\\,\"]\\s*)"; // private static final String COMMA_OR_CLOSING_BRACKET = "(\\s*[\\,\\)\"]\\s*)"; // private final String value; // // public JavaSource(String value) { // this.value = value; // } // // @Override // public String value() { // return value; // } // // public JavaSource replace(final List<String> oldValues, final List<String> newValues) { // String result = value(); // for (int i = 0; i < oldValues.size(); i++) { // String header = oldValues.get(i); // String value = newValues.get(i); // result = result.replaceAll(COMMA_OR_OPENING_BRACKET + header + COMMA_OR_CLOSING_BRACKET, "$1" + displayValue(value) + "$2"); // } // return new JavaSource(result); // } // // private static String displayValue(String value) { // if (value.matches("[A-Z0-9]*")) { // return value; // } // return "\"" + value + "\""; // } // // @Override // public String toString() { // return value(); // } // } // // Path: src/com/googlecode/yatspec/state/givenwhenthen/CapturedInputAndOutputs.java // public class CapturedInputAndOutputs extends NiceMap<CapturedInputAndOutputs>{ // public CapturedInputAndOutputs(Object... instances) { // super(instances); // } // } // // Path: src/com/googlecode/yatspec/state/givenwhenthen/InterestingGivens.java // public class InterestingGivens extends NiceMap<InterestingGivens>{ // public InterestingGivens(Object... instances) { // super(instances); // } // } // // Path: src/com/googlecode/yatspec/state/givenwhenthen/TestState.java // @SuppressWarnings("unused") // public class TestState implements TestLogger, WithTestState { // public InterestingGivens interestingGivens = new InterestingGivens(); // public CapturedInputAndOutputs capturedInputAndOutputs = new CapturedInputAndOutputs(); // // public TestState given(GivensBuilder builder) throws Exception { // interestingGivens = builder.build(interestingGivens); // return this; // } // // public TestState and(GivensBuilder builder) throws Exception { // return given(builder); // } // // public TestState when(ActionUnderTest actionUndertest) throws Exception { // capturedInputAndOutputs = actionUndertest.execute(interestingGivens, capturedInputAndOutputs); // return this; // } // // public <ItemOfInterest> TestState then(StateExtractor<ItemOfInterest> extractor, Matcher<? super ItemOfInterest> matcher) throws Exception { // assertThat(extractor.execute(capturedInputAndOutputs), matcher); // return this; // } // // public synchronized void log(String name, Object value) { // int count = 1; // String keyName = name; // while (capturedInputAndOutputs.contains(keyName)) { // keyName = name + count; // count++; // } // capturedInputAndOutputs.add(keyName, value); // } // // public TestState testState() { // return this; // } // } // Path: src/com/googlecode/yatspec/state/Scenario.java import com.googlecode.yatspec.parsing.JavaSource; import com.googlecode.yatspec.state.givenwhenthen.CapturedInputAndOutputs; import com.googlecode.yatspec.state.givenwhenthen.InterestingGivens; import com.googlecode.yatspec.state.givenwhenthen.TestState; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; package com.googlecode.yatspec.state; @SuppressWarnings("unused") public class Scenario {
private TestState testState = new TestState();
bodar/yatspec
src/com/googlecode/yatspec/state/Scenario.java
// Path: src/com/googlecode/yatspec/parsing/JavaSource.java // public class JavaSource implements Value<String> { // private static final String COMMA_OR_OPENING_BRACKET = "(\\s*[\\(\\,\"]\\s*)"; // private static final String COMMA_OR_CLOSING_BRACKET = "(\\s*[\\,\\)\"]\\s*)"; // private final String value; // // public JavaSource(String value) { // this.value = value; // } // // @Override // public String value() { // return value; // } // // public JavaSource replace(final List<String> oldValues, final List<String> newValues) { // String result = value(); // for (int i = 0; i < oldValues.size(); i++) { // String header = oldValues.get(i); // String value = newValues.get(i); // result = result.replaceAll(COMMA_OR_OPENING_BRACKET + header + COMMA_OR_CLOSING_BRACKET, "$1" + displayValue(value) + "$2"); // } // return new JavaSource(result); // } // // private static String displayValue(String value) { // if (value.matches("[A-Z0-9]*")) { // return value; // } // return "\"" + value + "\""; // } // // @Override // public String toString() { // return value(); // } // } // // Path: src/com/googlecode/yatspec/state/givenwhenthen/CapturedInputAndOutputs.java // public class CapturedInputAndOutputs extends NiceMap<CapturedInputAndOutputs>{ // public CapturedInputAndOutputs(Object... instances) { // super(instances); // } // } // // Path: src/com/googlecode/yatspec/state/givenwhenthen/InterestingGivens.java // public class InterestingGivens extends NiceMap<InterestingGivens>{ // public InterestingGivens(Object... instances) { // super(instances); // } // } // // Path: src/com/googlecode/yatspec/state/givenwhenthen/TestState.java // @SuppressWarnings("unused") // public class TestState implements TestLogger, WithTestState { // public InterestingGivens interestingGivens = new InterestingGivens(); // public CapturedInputAndOutputs capturedInputAndOutputs = new CapturedInputAndOutputs(); // // public TestState given(GivensBuilder builder) throws Exception { // interestingGivens = builder.build(interestingGivens); // return this; // } // // public TestState and(GivensBuilder builder) throws Exception { // return given(builder); // } // // public TestState when(ActionUnderTest actionUndertest) throws Exception { // capturedInputAndOutputs = actionUndertest.execute(interestingGivens, capturedInputAndOutputs); // return this; // } // // public <ItemOfInterest> TestState then(StateExtractor<ItemOfInterest> extractor, Matcher<? super ItemOfInterest> matcher) throws Exception { // assertThat(extractor.execute(capturedInputAndOutputs), matcher); // return this; // } // // public synchronized void log(String name, Object value) { // int count = 1; // String keyName = name; // while (capturedInputAndOutputs.contains(keyName)) { // keyName = name + count; // count++; // } // capturedInputAndOutputs.add(keyName, value); // } // // public TestState testState() { // return this; // } // }
import com.googlecode.yatspec.parsing.JavaSource; import com.googlecode.yatspec.state.givenwhenthen.CapturedInputAndOutputs; import com.googlecode.yatspec.state.givenwhenthen.InterestingGivens; import com.googlecode.yatspec.state.givenwhenthen.TestState; import java.util.LinkedHashMap; import java.util.List; import java.util.Map;
package com.googlecode.yatspec.state; @SuppressWarnings("unused") public class Scenario { private TestState testState = new TestState(); private final String name;
// Path: src/com/googlecode/yatspec/parsing/JavaSource.java // public class JavaSource implements Value<String> { // private static final String COMMA_OR_OPENING_BRACKET = "(\\s*[\\(\\,\"]\\s*)"; // private static final String COMMA_OR_CLOSING_BRACKET = "(\\s*[\\,\\)\"]\\s*)"; // private final String value; // // public JavaSource(String value) { // this.value = value; // } // // @Override // public String value() { // return value; // } // // public JavaSource replace(final List<String> oldValues, final List<String> newValues) { // String result = value(); // for (int i = 0; i < oldValues.size(); i++) { // String header = oldValues.get(i); // String value = newValues.get(i); // result = result.replaceAll(COMMA_OR_OPENING_BRACKET + header + COMMA_OR_CLOSING_BRACKET, "$1" + displayValue(value) + "$2"); // } // return new JavaSource(result); // } // // private static String displayValue(String value) { // if (value.matches("[A-Z0-9]*")) { // return value; // } // return "\"" + value + "\""; // } // // @Override // public String toString() { // return value(); // } // } // // Path: src/com/googlecode/yatspec/state/givenwhenthen/CapturedInputAndOutputs.java // public class CapturedInputAndOutputs extends NiceMap<CapturedInputAndOutputs>{ // public CapturedInputAndOutputs(Object... instances) { // super(instances); // } // } // // Path: src/com/googlecode/yatspec/state/givenwhenthen/InterestingGivens.java // public class InterestingGivens extends NiceMap<InterestingGivens>{ // public InterestingGivens(Object... instances) { // super(instances); // } // } // // Path: src/com/googlecode/yatspec/state/givenwhenthen/TestState.java // @SuppressWarnings("unused") // public class TestState implements TestLogger, WithTestState { // public InterestingGivens interestingGivens = new InterestingGivens(); // public CapturedInputAndOutputs capturedInputAndOutputs = new CapturedInputAndOutputs(); // // public TestState given(GivensBuilder builder) throws Exception { // interestingGivens = builder.build(interestingGivens); // return this; // } // // public TestState and(GivensBuilder builder) throws Exception { // return given(builder); // } // // public TestState when(ActionUnderTest actionUndertest) throws Exception { // capturedInputAndOutputs = actionUndertest.execute(interestingGivens, capturedInputAndOutputs); // return this; // } // // public <ItemOfInterest> TestState then(StateExtractor<ItemOfInterest> extractor, Matcher<? super ItemOfInterest> matcher) throws Exception { // assertThat(extractor.execute(capturedInputAndOutputs), matcher); // return this; // } // // public synchronized void log(String name, Object value) { // int count = 1; // String keyName = name; // while (capturedInputAndOutputs.contains(keyName)) { // keyName = name + count; // count++; // } // capturedInputAndOutputs.add(keyName, value); // } // // public TestState testState() { // return this; // } // } // Path: src/com/googlecode/yatspec/state/Scenario.java import com.googlecode.yatspec.parsing.JavaSource; import com.googlecode.yatspec.state.givenwhenthen.CapturedInputAndOutputs; import com.googlecode.yatspec.state.givenwhenthen.InterestingGivens; import com.googlecode.yatspec.state.givenwhenthen.TestState; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; package com.googlecode.yatspec.state; @SuppressWarnings("unused") public class Scenario { private TestState testState = new TestState(); private final String name;
private final JavaSource specification;
bodar/yatspec
src/com/googlecode/yatspec/rendering/ScenarioNameRendererFactory.java
// Path: src/com/googlecode/yatspec/junit/SpecRunner.java // public class SpecRunner extends TableRunner { // public static final String OUTPUT_DIR = "yatspec.output.dir"; // private final Result testResult; // private Map<String, Scenario> currentScenario = new HashMap<String, Scenario>(); // // public SpecRunner(Class<?> klass) throws org.junit.runners.model.InitializationError { // super(klass); // testResult = new TestResult(klass); // } // // @Override // protected List<FrameworkMethod> computeTestMethods() { // return sequence(super.computeTestMethods()).filter(isNotEvaluateMethod()).toList(); // } // // private static Predicate<FrameworkMethod> isNotEvaluateMethod() { // return new Predicate<FrameworkMethod>() { // public boolean matches(FrameworkMethod method) { // return !method.getName().equals("evaluate"); // } // }; // } // // private WithCustomResultListeners listeners = new DefaultResultListeners(); // // @Override // protected Object createTest() throws Exception { // Object instance = super.createTest(); // if (instance instanceof WithCustomResultListeners) { // listeners = (WithCustomResultListeners) instance; // } else { // listeners = new DefaultResultListeners(); // } // return instance; // } // // @Override // public void run(RunNotifier notifier) { // final SpecListener listener = new SpecListener(); // notifier.addListener(listener); // super.run(notifier); // notifier.removeListener(listener); // try { // for (SpecResultListener resultListener : listeners.getResultListeners()) { // resultListener.complete(outputDirectory(), testResult); // } // } catch (Exception e) { // System.out.println("Error while writing yatspec output"); // e.printStackTrace(System.out); // } // } // // public static File outputDirectory() { // return new File(getProperty(OUTPUT_DIR, getProperty("java.io.tmpdir"))); // } // // @Override // protected Statement methodInvoker(final FrameworkMethod method, final Object test) { // final Statement statement = super.methodInvoker(method, test); // return new Statement() { // @Override // public void evaluate() throws Throwable { // final String fullyQualifiedTestMethod = test.getClass().getCanonicalName() + "." + method.getName(); // final Scenario scenario = testResult.getScenario(method.getName()); // currentScenario.put(fullyQualifiedTestMethod, scenario); // // if (test instanceof WithTestState) { // TestState testState = ((WithTestState) test).testState(); // currentScenario.get(fullyQualifiedTestMethod).setTestState(testState); // } // statement.evaluate(); // } // }; // } // // private final class SpecListener extends RunListener { // @Override // public void testFailure(Failure failure) throws Exception { // String fullyQualifiedTestMethod = failure.getDescription().getClassName() + "." + failure.getDescription().getMethodName(); // if (currentScenario.get(fullyQualifiedTestMethod) != null) currentScenario.get(fullyQualifiedTestMethod).setException(failure.getException()); // } // } // } // // Path: src/com/googlecode/yatspec/rendering/junit/HumanReadableScenarioNameRenderer.java // public class HumanReadableScenarioNameRenderer implements ScenarioNameRenderer { // // @Override // public String render(ScenarioName scenarioName) { // return scenarioName.getMethodName() + "(" + sequence(scenarioName.getRow()).toString(", ") + ")"; // } // } // // Path: src/com/googlecode/yatspec/state/ScenarioName.java // public class ScenarioName { // private final String methodName; // private final List<String> row; // // public ScenarioName(String methodName, List<String> row) { // this.methodName = methodName; // this.row = row; // } // // public String getMethodName() { // return methodName; // } // // public List<String> getRow() { // return row; // } // // public boolean hasEmptyRow() { // return getRow().isEmpty(); // } // } // // Path: src/com/googlecode/yatspec/Creator.java // public static <T> T create(Class<?> aClass) throws InstantiationException, IllegalAccessException, InvocationTargetException { // Constructor<?>[] constructors = aClass.getConstructors(); // return (T) constructors[0].newInstance(); // }
import com.googlecode.yatspec.junit.SpecRunner; import com.googlecode.yatspec.rendering.junit.HumanReadableScenarioNameRenderer; import com.googlecode.yatspec.state.ScenarioName; import static com.googlecode.yatspec.Creator.create; import static java.lang.Class.forName; import static java.lang.System.getProperty;
package com.googlecode.yatspec.rendering; public class ScenarioNameRendererFactory { public static final String SCENARIO_NAME_RENDERER = "yatspec.scenario.name.renderer"; public static void setScenarioNameRenderer(Class<? extends ScenarioNameRenderer> aClass) { System.setProperty(SCENARIO_NAME_RENDERER, aClass.getName()); } public static ScenarioNameRenderer renderer() { ScenarioNameRenderer renderer; try {
// Path: src/com/googlecode/yatspec/junit/SpecRunner.java // public class SpecRunner extends TableRunner { // public static final String OUTPUT_DIR = "yatspec.output.dir"; // private final Result testResult; // private Map<String, Scenario> currentScenario = new HashMap<String, Scenario>(); // // public SpecRunner(Class<?> klass) throws org.junit.runners.model.InitializationError { // super(klass); // testResult = new TestResult(klass); // } // // @Override // protected List<FrameworkMethod> computeTestMethods() { // return sequence(super.computeTestMethods()).filter(isNotEvaluateMethod()).toList(); // } // // private static Predicate<FrameworkMethod> isNotEvaluateMethod() { // return new Predicate<FrameworkMethod>() { // public boolean matches(FrameworkMethod method) { // return !method.getName().equals("evaluate"); // } // }; // } // // private WithCustomResultListeners listeners = new DefaultResultListeners(); // // @Override // protected Object createTest() throws Exception { // Object instance = super.createTest(); // if (instance instanceof WithCustomResultListeners) { // listeners = (WithCustomResultListeners) instance; // } else { // listeners = new DefaultResultListeners(); // } // return instance; // } // // @Override // public void run(RunNotifier notifier) { // final SpecListener listener = new SpecListener(); // notifier.addListener(listener); // super.run(notifier); // notifier.removeListener(listener); // try { // for (SpecResultListener resultListener : listeners.getResultListeners()) { // resultListener.complete(outputDirectory(), testResult); // } // } catch (Exception e) { // System.out.println("Error while writing yatspec output"); // e.printStackTrace(System.out); // } // } // // public static File outputDirectory() { // return new File(getProperty(OUTPUT_DIR, getProperty("java.io.tmpdir"))); // } // // @Override // protected Statement methodInvoker(final FrameworkMethod method, final Object test) { // final Statement statement = super.methodInvoker(method, test); // return new Statement() { // @Override // public void evaluate() throws Throwable { // final String fullyQualifiedTestMethod = test.getClass().getCanonicalName() + "." + method.getName(); // final Scenario scenario = testResult.getScenario(method.getName()); // currentScenario.put(fullyQualifiedTestMethod, scenario); // // if (test instanceof WithTestState) { // TestState testState = ((WithTestState) test).testState(); // currentScenario.get(fullyQualifiedTestMethod).setTestState(testState); // } // statement.evaluate(); // } // }; // } // // private final class SpecListener extends RunListener { // @Override // public void testFailure(Failure failure) throws Exception { // String fullyQualifiedTestMethod = failure.getDescription().getClassName() + "." + failure.getDescription().getMethodName(); // if (currentScenario.get(fullyQualifiedTestMethod) != null) currentScenario.get(fullyQualifiedTestMethod).setException(failure.getException()); // } // } // } // // Path: src/com/googlecode/yatspec/rendering/junit/HumanReadableScenarioNameRenderer.java // public class HumanReadableScenarioNameRenderer implements ScenarioNameRenderer { // // @Override // public String render(ScenarioName scenarioName) { // return scenarioName.getMethodName() + "(" + sequence(scenarioName.getRow()).toString(", ") + ")"; // } // } // // Path: src/com/googlecode/yatspec/state/ScenarioName.java // public class ScenarioName { // private final String methodName; // private final List<String> row; // // public ScenarioName(String methodName, List<String> row) { // this.methodName = methodName; // this.row = row; // } // // public String getMethodName() { // return methodName; // } // // public List<String> getRow() { // return row; // } // // public boolean hasEmptyRow() { // return getRow().isEmpty(); // } // } // // Path: src/com/googlecode/yatspec/Creator.java // public static <T> T create(Class<?> aClass) throws InstantiationException, IllegalAccessException, InvocationTargetException { // Constructor<?>[] constructors = aClass.getConstructors(); // return (T) constructors[0].newInstance(); // } // Path: src/com/googlecode/yatspec/rendering/ScenarioNameRendererFactory.java import com.googlecode.yatspec.junit.SpecRunner; import com.googlecode.yatspec.rendering.junit.HumanReadableScenarioNameRenderer; import com.googlecode.yatspec.state.ScenarioName; import static com.googlecode.yatspec.Creator.create; import static java.lang.Class.forName; import static java.lang.System.getProperty; package com.googlecode.yatspec.rendering; public class ScenarioNameRendererFactory { public static final String SCENARIO_NAME_RENDERER = "yatspec.scenario.name.renderer"; public static void setScenarioNameRenderer(Class<? extends ScenarioNameRenderer> aClass) { System.setProperty(SCENARIO_NAME_RENDERER, aClass.getName()); } public static ScenarioNameRenderer renderer() { ScenarioNameRenderer renderer; try {
renderer = create(forName(getProperty(SCENARIO_NAME_RENDERER, HumanReadableScenarioNameRenderer.class.getName())));
bodar/yatspec
src/com/googlecode/yatspec/rendering/ScenarioNameRendererFactory.java
// Path: src/com/googlecode/yatspec/junit/SpecRunner.java // public class SpecRunner extends TableRunner { // public static final String OUTPUT_DIR = "yatspec.output.dir"; // private final Result testResult; // private Map<String, Scenario> currentScenario = new HashMap<String, Scenario>(); // // public SpecRunner(Class<?> klass) throws org.junit.runners.model.InitializationError { // super(klass); // testResult = new TestResult(klass); // } // // @Override // protected List<FrameworkMethod> computeTestMethods() { // return sequence(super.computeTestMethods()).filter(isNotEvaluateMethod()).toList(); // } // // private static Predicate<FrameworkMethod> isNotEvaluateMethod() { // return new Predicate<FrameworkMethod>() { // public boolean matches(FrameworkMethod method) { // return !method.getName().equals("evaluate"); // } // }; // } // // private WithCustomResultListeners listeners = new DefaultResultListeners(); // // @Override // protected Object createTest() throws Exception { // Object instance = super.createTest(); // if (instance instanceof WithCustomResultListeners) { // listeners = (WithCustomResultListeners) instance; // } else { // listeners = new DefaultResultListeners(); // } // return instance; // } // // @Override // public void run(RunNotifier notifier) { // final SpecListener listener = new SpecListener(); // notifier.addListener(listener); // super.run(notifier); // notifier.removeListener(listener); // try { // for (SpecResultListener resultListener : listeners.getResultListeners()) { // resultListener.complete(outputDirectory(), testResult); // } // } catch (Exception e) { // System.out.println("Error while writing yatspec output"); // e.printStackTrace(System.out); // } // } // // public static File outputDirectory() { // return new File(getProperty(OUTPUT_DIR, getProperty("java.io.tmpdir"))); // } // // @Override // protected Statement methodInvoker(final FrameworkMethod method, final Object test) { // final Statement statement = super.methodInvoker(method, test); // return new Statement() { // @Override // public void evaluate() throws Throwable { // final String fullyQualifiedTestMethod = test.getClass().getCanonicalName() + "." + method.getName(); // final Scenario scenario = testResult.getScenario(method.getName()); // currentScenario.put(fullyQualifiedTestMethod, scenario); // // if (test instanceof WithTestState) { // TestState testState = ((WithTestState) test).testState(); // currentScenario.get(fullyQualifiedTestMethod).setTestState(testState); // } // statement.evaluate(); // } // }; // } // // private final class SpecListener extends RunListener { // @Override // public void testFailure(Failure failure) throws Exception { // String fullyQualifiedTestMethod = failure.getDescription().getClassName() + "." + failure.getDescription().getMethodName(); // if (currentScenario.get(fullyQualifiedTestMethod) != null) currentScenario.get(fullyQualifiedTestMethod).setException(failure.getException()); // } // } // } // // Path: src/com/googlecode/yatspec/rendering/junit/HumanReadableScenarioNameRenderer.java // public class HumanReadableScenarioNameRenderer implements ScenarioNameRenderer { // // @Override // public String render(ScenarioName scenarioName) { // return scenarioName.getMethodName() + "(" + sequence(scenarioName.getRow()).toString(", ") + ")"; // } // } // // Path: src/com/googlecode/yatspec/state/ScenarioName.java // public class ScenarioName { // private final String methodName; // private final List<String> row; // // public ScenarioName(String methodName, List<String> row) { // this.methodName = methodName; // this.row = row; // } // // public String getMethodName() { // return methodName; // } // // public List<String> getRow() { // return row; // } // // public boolean hasEmptyRow() { // return getRow().isEmpty(); // } // } // // Path: src/com/googlecode/yatspec/Creator.java // public static <T> T create(Class<?> aClass) throws InstantiationException, IllegalAccessException, InvocationTargetException { // Constructor<?>[] constructors = aClass.getConstructors(); // return (T) constructors[0].newInstance(); // }
import com.googlecode.yatspec.junit.SpecRunner; import com.googlecode.yatspec.rendering.junit.HumanReadableScenarioNameRenderer; import com.googlecode.yatspec.state.ScenarioName; import static com.googlecode.yatspec.Creator.create; import static java.lang.Class.forName; import static java.lang.System.getProperty;
package com.googlecode.yatspec.rendering; public class ScenarioNameRendererFactory { public static final String SCENARIO_NAME_RENDERER = "yatspec.scenario.name.renderer"; public static void setScenarioNameRenderer(Class<? extends ScenarioNameRenderer> aClass) { System.setProperty(SCENARIO_NAME_RENDERER, aClass.getName()); } public static ScenarioNameRenderer renderer() { ScenarioNameRenderer renderer; try {
// Path: src/com/googlecode/yatspec/junit/SpecRunner.java // public class SpecRunner extends TableRunner { // public static final String OUTPUT_DIR = "yatspec.output.dir"; // private final Result testResult; // private Map<String, Scenario> currentScenario = new HashMap<String, Scenario>(); // // public SpecRunner(Class<?> klass) throws org.junit.runners.model.InitializationError { // super(klass); // testResult = new TestResult(klass); // } // // @Override // protected List<FrameworkMethod> computeTestMethods() { // return sequence(super.computeTestMethods()).filter(isNotEvaluateMethod()).toList(); // } // // private static Predicate<FrameworkMethod> isNotEvaluateMethod() { // return new Predicate<FrameworkMethod>() { // public boolean matches(FrameworkMethod method) { // return !method.getName().equals("evaluate"); // } // }; // } // // private WithCustomResultListeners listeners = new DefaultResultListeners(); // // @Override // protected Object createTest() throws Exception { // Object instance = super.createTest(); // if (instance instanceof WithCustomResultListeners) { // listeners = (WithCustomResultListeners) instance; // } else { // listeners = new DefaultResultListeners(); // } // return instance; // } // // @Override // public void run(RunNotifier notifier) { // final SpecListener listener = new SpecListener(); // notifier.addListener(listener); // super.run(notifier); // notifier.removeListener(listener); // try { // for (SpecResultListener resultListener : listeners.getResultListeners()) { // resultListener.complete(outputDirectory(), testResult); // } // } catch (Exception e) { // System.out.println("Error while writing yatspec output"); // e.printStackTrace(System.out); // } // } // // public static File outputDirectory() { // return new File(getProperty(OUTPUT_DIR, getProperty("java.io.tmpdir"))); // } // // @Override // protected Statement methodInvoker(final FrameworkMethod method, final Object test) { // final Statement statement = super.methodInvoker(method, test); // return new Statement() { // @Override // public void evaluate() throws Throwable { // final String fullyQualifiedTestMethod = test.getClass().getCanonicalName() + "." + method.getName(); // final Scenario scenario = testResult.getScenario(method.getName()); // currentScenario.put(fullyQualifiedTestMethod, scenario); // // if (test instanceof WithTestState) { // TestState testState = ((WithTestState) test).testState(); // currentScenario.get(fullyQualifiedTestMethod).setTestState(testState); // } // statement.evaluate(); // } // }; // } // // private final class SpecListener extends RunListener { // @Override // public void testFailure(Failure failure) throws Exception { // String fullyQualifiedTestMethod = failure.getDescription().getClassName() + "." + failure.getDescription().getMethodName(); // if (currentScenario.get(fullyQualifiedTestMethod) != null) currentScenario.get(fullyQualifiedTestMethod).setException(failure.getException()); // } // } // } // // Path: src/com/googlecode/yatspec/rendering/junit/HumanReadableScenarioNameRenderer.java // public class HumanReadableScenarioNameRenderer implements ScenarioNameRenderer { // // @Override // public String render(ScenarioName scenarioName) { // return scenarioName.getMethodName() + "(" + sequence(scenarioName.getRow()).toString(", ") + ")"; // } // } // // Path: src/com/googlecode/yatspec/state/ScenarioName.java // public class ScenarioName { // private final String methodName; // private final List<String> row; // // public ScenarioName(String methodName, List<String> row) { // this.methodName = methodName; // this.row = row; // } // // public String getMethodName() { // return methodName; // } // // public List<String> getRow() { // return row; // } // // public boolean hasEmptyRow() { // return getRow().isEmpty(); // } // } // // Path: src/com/googlecode/yatspec/Creator.java // public static <T> T create(Class<?> aClass) throws InstantiationException, IllegalAccessException, InvocationTargetException { // Constructor<?>[] constructors = aClass.getConstructors(); // return (T) constructors[0].newInstance(); // } // Path: src/com/googlecode/yatspec/rendering/ScenarioNameRendererFactory.java import com.googlecode.yatspec.junit.SpecRunner; import com.googlecode.yatspec.rendering.junit.HumanReadableScenarioNameRenderer; import com.googlecode.yatspec.state.ScenarioName; import static com.googlecode.yatspec.Creator.create; import static java.lang.Class.forName; import static java.lang.System.getProperty; package com.googlecode.yatspec.rendering; public class ScenarioNameRendererFactory { public static final String SCENARIO_NAME_RENDERER = "yatspec.scenario.name.renderer"; public static void setScenarioNameRenderer(Class<? extends ScenarioNameRenderer> aClass) { System.setProperty(SCENARIO_NAME_RENDERER, aClass.getName()); } public static ScenarioNameRenderer renderer() { ScenarioNameRenderer renderer; try {
renderer = create(forName(getProperty(SCENARIO_NAME_RENDERER, HumanReadableScenarioNameRenderer.class.getName())));
bodar/yatspec
src/com/googlecode/yatspec/state/ScenarioTable.java
// Path: src/com/googlecode/yatspec/state/ScenarioTableHeader.java // public static Callable1<? super String, ScenarioTableHeader> toScenarioTableHeader() { // return new Callable1<String, ScenarioTableHeader>() { // @Override // public ScenarioTableHeader call(String value) throws Exception { // return new ScenarioTableHeader(value); // } // }; // }
import com.googlecode.totallylazy.Callable1; import java.util.ArrayList; import java.util.List; import static com.googlecode.totallylazy.Sequences.sequence; import static com.googlecode.yatspec.state.ScenarioTableHeader.toScenarioTableHeader;
package com.googlecode.yatspec.state; @SuppressWarnings("unused") public class ScenarioTable { private List<ScenarioTableHeader> headers = new ArrayList<ScenarioTableHeader>(); private List<List<String>> rows = new ArrayList<List<String>>(); public List<ScenarioTableHeader> getHeaders() { return headers; } public void setHeaders(List<String> headers) { if(headers != null)
// Path: src/com/googlecode/yatspec/state/ScenarioTableHeader.java // public static Callable1<? super String, ScenarioTableHeader> toScenarioTableHeader() { // return new Callable1<String, ScenarioTableHeader>() { // @Override // public ScenarioTableHeader call(String value) throws Exception { // return new ScenarioTableHeader(value); // } // }; // } // Path: src/com/googlecode/yatspec/state/ScenarioTable.java import com.googlecode.totallylazy.Callable1; import java.util.ArrayList; import java.util.List; import static com.googlecode.totallylazy.Sequences.sequence; import static com.googlecode.yatspec.state.ScenarioTableHeader.toScenarioTableHeader; package com.googlecode.yatspec.state; @SuppressWarnings("unused") public class ScenarioTable { private List<ScenarioTableHeader> headers = new ArrayList<ScenarioTableHeader>(); private List<List<String>> rows = new ArrayList<List<String>>(); public List<ScenarioTableHeader> getHeaders() { return headers; } public void setHeaders(List<String> headers) { if(headers != null)
this.headers = sequence(headers).map(toScenarioTableHeader()).toList();
bodar/yatspec
test/com/googlecode/yatspec/plugin/sequencediagram/ByNamingConventionMessageProducerTest.java
// Path: src/com/googlecode/yatspec/state/givenwhenthen/CapturedInputAndOutputs.java // public class CapturedInputAndOutputs extends NiceMap<CapturedInputAndOutputs>{ // public CapturedInputAndOutputs(Object... instances) { // super(instances); // } // }
import com.googlecode.totallylazy.Sequence; import com.googlecode.yatspec.state.givenwhenthen.CapturedInputAndOutputs; import org.junit.Test; import static com.googlecode.totallylazy.Sequences.sequence; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.Matchers.is;
package com.googlecode.yatspec.plugin.sequencediagram; public class ByNamingConventionMessageProducerTest { @Test public void ignoresValuesWithoutNamingConvention() {
// Path: src/com/googlecode/yatspec/state/givenwhenthen/CapturedInputAndOutputs.java // public class CapturedInputAndOutputs extends NiceMap<CapturedInputAndOutputs>{ // public CapturedInputAndOutputs(Object... instances) { // super(instances); // } // } // Path: test/com/googlecode/yatspec/plugin/sequencediagram/ByNamingConventionMessageProducerTest.java import com.googlecode.totallylazy.Sequence; import com.googlecode.yatspec.state.givenwhenthen.CapturedInputAndOutputs; import org.junit.Test; import static com.googlecode.totallylazy.Sequences.sequence; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.Matchers.is; package com.googlecode.yatspec.plugin.sequencediagram; public class ByNamingConventionMessageProducerTest { @Test public void ignoresValuesWithoutNamingConvention() {
CapturedInputAndOutputs inputAndOutputs = new CapturedInputAndOutputs().add("Shopping Basket", new Object());
bodar/yatspec
src/com/googlecode/yatspec/rendering/html/tagindex/NotesTagFinder.java
// Path: src/com/googlecode/yatspec/state/TestMethod.java // @SuppressWarnings({"unused"}) // public class TestMethod { // private final Class testClass; // private final Method method; // private final String methodName; // private final ScenarioTable scenarioTable; // private final JavaSource specification; // private final Map<String, Scenario> scenarioResults = new LinkedHashMap<String, Scenario>(); // // public TestMethod(Class testClass, Method method, String methodName, JavaSource methodBody, ScenarioTable scenarioTable) { // this.testClass = testClass; // this.method = method; // this.methodName = methodName; // this.scenarioTable = scenarioTable; // this.specification = methodBody; // buildUpScenarios(); // } // // private void buildUpScenarios() { // if (scenarioTable.isEmpty()) { // scenarioResults.put(methodName, new Scenario("", specification)); // } else { // for (List<String> row : scenarioTable.getRows()) { // ScenarioName scenarioName = new ScenarioName(methodName, row); // String name = ScenarioNameRendererFactory.renderer().render(scenarioName); // final List<String> oldValues = sequence(scenarioTable.getHeaders()).map(value(String.class)).toList(); // scenarioResults.put(name, new Scenario(name, // specification.replace(oldValues, createPossiblyVarargValueFrom(row, oldValues)))); // } // } // } // // private List<String> createPossiblyVarargValueFrom(List<String> newValues, List<String> oldValues) { // Sequence<String> actualValues = sequence(newValues); // if (oldValues.size() > newValues.size()) { // actualValues = sequence(newValues).join(sequence("[]").cycle()).take(oldValues.size()); // } else if (newValues.size() > oldValues.size()) { // actualValues = actualValues.take(oldValues.size() - 1).append(actualValues.drop(oldValues.size() - 1).toString("[", ", ", "]")); // } // return actualValues.toList(); // } // // private static <T> Callable1<? super Value<T>, T> value(Class<T> aClass) { // return new Callable1<Value<T>, T>() { // @Override // public T call(Value<T> instance) throws Exception { // return instance.value(); // } // }; // } // // public String getName() { // return methodName; // } // // public String getDisplayName() { // return Text.wordify(methodName); // } // // public String getDisplayLinkName() { // return getDisplayName().replace(' ', '_'); // } // // public Status getStatus() { // return calculateStatus(sequence(getScenarios()).map(new Callable1<Scenario, Status>() { // public Status call(Scenario scenario) { // return scenario.getStatus(); // } // })); // } // // public static Status calculateStatus(final Sequence<Status> statuses) { // if (statuses.contains(Status.Failed)) { // return Status.Failed; // } // if (statuses.contains(Status.NotRun)) { // return Status.NotRun; // } // return Status.Passed; // } // // public JavaSource getSpecification() { // return specification; // } // // @Override // public String toString() { // return getName() + lineSeparator() + getSpecification(); // } // // public ScenarioTable getScenarioTable() { // return scenarioTable; // } // // public Scenario getScenario(String fullName) { // return scenarioResults.get(fullName); // } // // public List<Scenario> getScenarios() { // return new ArrayList<Scenario>(scenarioResults.values()); // } // // public boolean hasScenario(String name) { // return scenarioResults.get(name) != null; // } // // public List<Annotation> getAnnotations() { // return yatspecAnnotations(sequence(method.getAnnotations())); // } // // public String getUid() { // return Integer.toString(hashCode()); // } // // public String getPackageName() { // return testClass.getPackage().getName(); // } // // public Class getTestClass() { // return testClass; // } // }
import com.googlecode.totallylazy.Function1; import com.googlecode.totallylazy.Sequences; import com.googlecode.totallylazy.regex.Regex; import com.googlecode.yatspec.junit.Notes; import com.googlecode.yatspec.state.TestMethod; import java.util.regex.MatchResult; import static com.googlecode.totallylazy.regex.Regex.regex; import static com.googlecode.yatspec.junit.Notes.methods.notes;
package com.googlecode.yatspec.rendering.html.tagindex; public class NotesTagFinder implements TagFinder { private Regex regex; public NotesTagFinder() { this("#[^\\s]+"); } public NotesTagFinder(String regex) { this.regex = regex(regex); }
// Path: src/com/googlecode/yatspec/state/TestMethod.java // @SuppressWarnings({"unused"}) // public class TestMethod { // private final Class testClass; // private final Method method; // private final String methodName; // private final ScenarioTable scenarioTable; // private final JavaSource specification; // private final Map<String, Scenario> scenarioResults = new LinkedHashMap<String, Scenario>(); // // public TestMethod(Class testClass, Method method, String methodName, JavaSource methodBody, ScenarioTable scenarioTable) { // this.testClass = testClass; // this.method = method; // this.methodName = methodName; // this.scenarioTable = scenarioTable; // this.specification = methodBody; // buildUpScenarios(); // } // // private void buildUpScenarios() { // if (scenarioTable.isEmpty()) { // scenarioResults.put(methodName, new Scenario("", specification)); // } else { // for (List<String> row : scenarioTable.getRows()) { // ScenarioName scenarioName = new ScenarioName(methodName, row); // String name = ScenarioNameRendererFactory.renderer().render(scenarioName); // final List<String> oldValues = sequence(scenarioTable.getHeaders()).map(value(String.class)).toList(); // scenarioResults.put(name, new Scenario(name, // specification.replace(oldValues, createPossiblyVarargValueFrom(row, oldValues)))); // } // } // } // // private List<String> createPossiblyVarargValueFrom(List<String> newValues, List<String> oldValues) { // Sequence<String> actualValues = sequence(newValues); // if (oldValues.size() > newValues.size()) { // actualValues = sequence(newValues).join(sequence("[]").cycle()).take(oldValues.size()); // } else if (newValues.size() > oldValues.size()) { // actualValues = actualValues.take(oldValues.size() - 1).append(actualValues.drop(oldValues.size() - 1).toString("[", ", ", "]")); // } // return actualValues.toList(); // } // // private static <T> Callable1<? super Value<T>, T> value(Class<T> aClass) { // return new Callable1<Value<T>, T>() { // @Override // public T call(Value<T> instance) throws Exception { // return instance.value(); // } // }; // } // // public String getName() { // return methodName; // } // // public String getDisplayName() { // return Text.wordify(methodName); // } // // public String getDisplayLinkName() { // return getDisplayName().replace(' ', '_'); // } // // public Status getStatus() { // return calculateStatus(sequence(getScenarios()).map(new Callable1<Scenario, Status>() { // public Status call(Scenario scenario) { // return scenario.getStatus(); // } // })); // } // // public static Status calculateStatus(final Sequence<Status> statuses) { // if (statuses.contains(Status.Failed)) { // return Status.Failed; // } // if (statuses.contains(Status.NotRun)) { // return Status.NotRun; // } // return Status.Passed; // } // // public JavaSource getSpecification() { // return specification; // } // // @Override // public String toString() { // return getName() + lineSeparator() + getSpecification(); // } // // public ScenarioTable getScenarioTable() { // return scenarioTable; // } // // public Scenario getScenario(String fullName) { // return scenarioResults.get(fullName); // } // // public List<Scenario> getScenarios() { // return new ArrayList<Scenario>(scenarioResults.values()); // } // // public boolean hasScenario(String name) { // return scenarioResults.get(name) != null; // } // // public List<Annotation> getAnnotations() { // return yatspecAnnotations(sequence(method.getAnnotations())); // } // // public String getUid() { // return Integer.toString(hashCode()); // } // // public String getPackageName() { // return testClass.getPackage().getName(); // } // // public Class getTestClass() { // return testClass; // } // } // Path: src/com/googlecode/yatspec/rendering/html/tagindex/NotesTagFinder.java import com.googlecode.totallylazy.Function1; import com.googlecode.totallylazy.Sequences; import com.googlecode.totallylazy.regex.Regex; import com.googlecode.yatspec.junit.Notes; import com.googlecode.yatspec.state.TestMethod; import java.util.regex.MatchResult; import static com.googlecode.totallylazy.regex.Regex.regex; import static com.googlecode.yatspec.junit.Notes.methods.notes; package com.googlecode.yatspec.rendering.html.tagindex; public class NotesTagFinder implements TagFinder { private Regex regex; public NotesTagFinder() { this("#[^\\s]+"); } public NotesTagFinder(String regex) { this.regex = regex(regex); }
public Iterable<String> tags(TestMethod testMethod) {
bodar/yatspec
test/com/googlecode/yatspec/junit/DecoratingFrameworkMethodVarargsTest.java
// Path: test/com/googlecode/yatspec/fixture/VarargFixture.java // @SuppressWarnings("unused") // public class VarargFixture { // // public Map<String, Object> arrayOnly(String[] lotsOfParams) { // Map<String, Object> recordedParams = new HashMap<String, Object>(); // recordedParams.put("lotsOfParams", lotsOfParams); // return recordedParams; // } // // public Map<String, Object> varargsOnly(String... lotsOfParams) { // Map<String, Object> recordedParams = new HashMap<String, Object>(); // recordedParams.put("lotsOfParams", lotsOfParams); // return recordedParams; // } // // public Map<String, Object> oneParamAndVarargs(String someParam, String... lotsOfParams) { // Map<String, Object> recordedParams = new HashMap<String, Object>(); // recordedParams.put("someParam", someParam); // recordedParams.put("lotsOfParams", lotsOfParams); // return recordedParams; // } // // public Map<String, Object> someParamsAndVarargs(String someParam, String anotherParam, String... lotsOfParams) { // Map<String, Object> recordedParams = new HashMap<String, Object>(); // recordedParams.put("someParam", someParam); // recordedParams.put("anotherParam", anotherParam); // recordedParams.put("lotsOfParams", lotsOfParams); // return recordedParams; // } // } // // Path: test/com/googlecode/yatspec/junit/DecoratingFrameworkMethodTest.java // static Row row(final List<String> args) { // return new Row() { // @Override // public String[] value() { // return args.toArray(new String[0]); // } // // @Override // public Class<? extends Annotation> annotationType() { // throw new UnsupportedOperationException("Not yet implemented"); // } // }; // }
import com.googlecode.totallylazy.Mapper; import com.googlecode.totallylazy.Predicates; import com.googlecode.yatspec.fixture.VarargFixture; import org.junit.Test; import org.junit.runners.model.FrameworkMethod; import java.lang.reflect.Method; import java.util.ArrayList; import java.util.List; import java.util.Map; import static com.googlecode.totallylazy.Sequences.sequence; import static com.googlecode.yatspec.junit.DecoratingFrameworkMethodTest.row; import static java.util.Arrays.asList; import static java.util.Collections.singletonList; import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.arrayContaining;
package com.googlecode.yatspec.junit; public class DecoratingFrameworkMethodVarargsTest { @Test public void shouldSupportMultipleParamsAndVarArgs() throws Throwable { testFixtureMethodCalled("someParamsAndVarargs"); } @Test public void shouldSupportOneParamAndVarArgs() throws Throwable { testFixtureMethodCalled("oneParamAndVarargs"); } @Test public void shouldSupportVarArgsOnly() throws Throwable { testFixtureMethodCalled("varargsOnly"); } @Test(expected = IllegalArgumentException.class) public void shouldFailIfLastArgumentIsAnArray() throws Throwable { checkNonVarargs(getMethod("arrayOnly"), singletonList("someParam")); } @Test(expected = IllegalArgumentException.class) public void shouldFailOnMissingParams() throws Throwable { checkNonVarargs(getMethod("someParamsAndVarargs"), singletonList("someParam")); } private void testFixtureMethodCalled(String methodName) throws Throwable { final Method methodUnderTest = getMethod(methodName); testVarargsForMethod(methodUnderTest); } private Method getMethod(String methodName) {
// Path: test/com/googlecode/yatspec/fixture/VarargFixture.java // @SuppressWarnings("unused") // public class VarargFixture { // // public Map<String, Object> arrayOnly(String[] lotsOfParams) { // Map<String, Object> recordedParams = new HashMap<String, Object>(); // recordedParams.put("lotsOfParams", lotsOfParams); // return recordedParams; // } // // public Map<String, Object> varargsOnly(String... lotsOfParams) { // Map<String, Object> recordedParams = new HashMap<String, Object>(); // recordedParams.put("lotsOfParams", lotsOfParams); // return recordedParams; // } // // public Map<String, Object> oneParamAndVarargs(String someParam, String... lotsOfParams) { // Map<String, Object> recordedParams = new HashMap<String, Object>(); // recordedParams.put("someParam", someParam); // recordedParams.put("lotsOfParams", lotsOfParams); // return recordedParams; // } // // public Map<String, Object> someParamsAndVarargs(String someParam, String anotherParam, String... lotsOfParams) { // Map<String, Object> recordedParams = new HashMap<String, Object>(); // recordedParams.put("someParam", someParam); // recordedParams.put("anotherParam", anotherParam); // recordedParams.put("lotsOfParams", lotsOfParams); // return recordedParams; // } // } // // Path: test/com/googlecode/yatspec/junit/DecoratingFrameworkMethodTest.java // static Row row(final List<String> args) { // return new Row() { // @Override // public String[] value() { // return args.toArray(new String[0]); // } // // @Override // public Class<? extends Annotation> annotationType() { // throw new UnsupportedOperationException("Not yet implemented"); // } // }; // } // Path: test/com/googlecode/yatspec/junit/DecoratingFrameworkMethodVarargsTest.java import com.googlecode.totallylazy.Mapper; import com.googlecode.totallylazy.Predicates; import com.googlecode.yatspec.fixture.VarargFixture; import org.junit.Test; import org.junit.runners.model.FrameworkMethod; import java.lang.reflect.Method; import java.util.ArrayList; import java.util.List; import java.util.Map; import static com.googlecode.totallylazy.Sequences.sequence; import static com.googlecode.yatspec.junit.DecoratingFrameworkMethodTest.row; import static java.util.Arrays.asList; import static java.util.Collections.singletonList; import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.arrayContaining; package com.googlecode.yatspec.junit; public class DecoratingFrameworkMethodVarargsTest { @Test public void shouldSupportMultipleParamsAndVarArgs() throws Throwable { testFixtureMethodCalled("someParamsAndVarargs"); } @Test public void shouldSupportOneParamAndVarArgs() throws Throwable { testFixtureMethodCalled("oneParamAndVarargs"); } @Test public void shouldSupportVarArgsOnly() throws Throwable { testFixtureMethodCalled("varargsOnly"); } @Test(expected = IllegalArgumentException.class) public void shouldFailIfLastArgumentIsAnArray() throws Throwable { checkNonVarargs(getMethod("arrayOnly"), singletonList("someParam")); } @Test(expected = IllegalArgumentException.class) public void shouldFailOnMissingParams() throws Throwable { checkNonVarargs(getMethod("someParamsAndVarargs"), singletonList("someParam")); } private void testFixtureMethodCalled(String methodName) throws Throwable { final Method methodUnderTest = getMethod(methodName); testVarargsForMethod(methodUnderTest); } private Method getMethod(String methodName) {
return sequence(VarargFixture.class.getDeclaredMethods()).filter(Predicates.where(new Mapper<Method, String>() {
bodar/yatspec
test/com/googlecode/yatspec/junit/DecoratingFrameworkMethodVarargsTest.java
// Path: test/com/googlecode/yatspec/fixture/VarargFixture.java // @SuppressWarnings("unused") // public class VarargFixture { // // public Map<String, Object> arrayOnly(String[] lotsOfParams) { // Map<String, Object> recordedParams = new HashMap<String, Object>(); // recordedParams.put("lotsOfParams", lotsOfParams); // return recordedParams; // } // // public Map<String, Object> varargsOnly(String... lotsOfParams) { // Map<String, Object> recordedParams = new HashMap<String, Object>(); // recordedParams.put("lotsOfParams", lotsOfParams); // return recordedParams; // } // // public Map<String, Object> oneParamAndVarargs(String someParam, String... lotsOfParams) { // Map<String, Object> recordedParams = new HashMap<String, Object>(); // recordedParams.put("someParam", someParam); // recordedParams.put("lotsOfParams", lotsOfParams); // return recordedParams; // } // // public Map<String, Object> someParamsAndVarargs(String someParam, String anotherParam, String... lotsOfParams) { // Map<String, Object> recordedParams = new HashMap<String, Object>(); // recordedParams.put("someParam", someParam); // recordedParams.put("anotherParam", anotherParam); // recordedParams.put("lotsOfParams", lotsOfParams); // return recordedParams; // } // } // // Path: test/com/googlecode/yatspec/junit/DecoratingFrameworkMethodTest.java // static Row row(final List<String> args) { // return new Row() { // @Override // public String[] value() { // return args.toArray(new String[0]); // } // // @Override // public Class<? extends Annotation> annotationType() { // throw new UnsupportedOperationException("Not yet implemented"); // } // }; // }
import com.googlecode.totallylazy.Mapper; import com.googlecode.totallylazy.Predicates; import com.googlecode.yatspec.fixture.VarargFixture; import org.junit.Test; import org.junit.runners.model.FrameworkMethod; import java.lang.reflect.Method; import java.util.ArrayList; import java.util.List; import java.util.Map; import static com.googlecode.totallylazy.Sequences.sequence; import static com.googlecode.yatspec.junit.DecoratingFrameworkMethodTest.row; import static java.util.Arrays.asList; import static java.util.Collections.singletonList; import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.arrayContaining;
return method.getName(); } }, Predicates.is(methodName))).headOption().getOrThrow(new RuntimeException("Couldn't find method called " + methodName)); } public void testVarargsForMethod(Method underTest) throws Throwable { final List<String> varArgs = asList("a", "b", "c"); final List<String> params = new ArrayList<String>(); if (underTest.getParameterTypes().length > 1) { params.add("someParam"); } if (underTest.getParameterTypes().length > 2) { params.add("anotherParam"); } checkVarargs(underTest, asList("a"), params); checkVarargs(underTest, varArgs, params); checkNonVarargs(underTest, params); } private void checkVarargs(Method underTest, List<String> varArgs, List<String> params) throws Throwable { final List<String> paramsToUse = sequence(params).join(varArgs).toList(); final Map<String, Object> result = checkNonVarargs(underTest, paramsToUse); assertThat((String[])result.get("lotsOfParams"), arrayContaining(varArgs.toArray())); } private Map<String, Object> checkNonVarargs(Method underTest, List<String> params) throws Throwable {
// Path: test/com/googlecode/yatspec/fixture/VarargFixture.java // @SuppressWarnings("unused") // public class VarargFixture { // // public Map<String, Object> arrayOnly(String[] lotsOfParams) { // Map<String, Object> recordedParams = new HashMap<String, Object>(); // recordedParams.put("lotsOfParams", lotsOfParams); // return recordedParams; // } // // public Map<String, Object> varargsOnly(String... lotsOfParams) { // Map<String, Object> recordedParams = new HashMap<String, Object>(); // recordedParams.put("lotsOfParams", lotsOfParams); // return recordedParams; // } // // public Map<String, Object> oneParamAndVarargs(String someParam, String... lotsOfParams) { // Map<String, Object> recordedParams = new HashMap<String, Object>(); // recordedParams.put("someParam", someParam); // recordedParams.put("lotsOfParams", lotsOfParams); // return recordedParams; // } // // public Map<String, Object> someParamsAndVarargs(String someParam, String anotherParam, String... lotsOfParams) { // Map<String, Object> recordedParams = new HashMap<String, Object>(); // recordedParams.put("someParam", someParam); // recordedParams.put("anotherParam", anotherParam); // recordedParams.put("lotsOfParams", lotsOfParams); // return recordedParams; // } // } // // Path: test/com/googlecode/yatspec/junit/DecoratingFrameworkMethodTest.java // static Row row(final List<String> args) { // return new Row() { // @Override // public String[] value() { // return args.toArray(new String[0]); // } // // @Override // public Class<? extends Annotation> annotationType() { // throw new UnsupportedOperationException("Not yet implemented"); // } // }; // } // Path: test/com/googlecode/yatspec/junit/DecoratingFrameworkMethodVarargsTest.java import com.googlecode.totallylazy.Mapper; import com.googlecode.totallylazy.Predicates; import com.googlecode.yatspec.fixture.VarargFixture; import org.junit.Test; import org.junit.runners.model.FrameworkMethod; import java.lang.reflect.Method; import java.util.ArrayList; import java.util.List; import java.util.Map; import static com.googlecode.totallylazy.Sequences.sequence; import static com.googlecode.yatspec.junit.DecoratingFrameworkMethodTest.row; import static java.util.Arrays.asList; import static java.util.Collections.singletonList; import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.arrayContaining; return method.getName(); } }, Predicates.is(methodName))).headOption().getOrThrow(new RuntimeException("Couldn't find method called " + methodName)); } public void testVarargsForMethod(Method underTest) throws Throwable { final List<String> varArgs = asList("a", "b", "c"); final List<String> params = new ArrayList<String>(); if (underTest.getParameterTypes().length > 1) { params.add("someParam"); } if (underTest.getParameterTypes().length > 2) { params.add("anotherParam"); } checkVarargs(underTest, asList("a"), params); checkVarargs(underTest, varArgs, params); checkNonVarargs(underTest, params); } private void checkVarargs(Method underTest, List<String> varArgs, List<String> params) throws Throwable { final List<String> paramsToUse = sequence(params).join(varArgs).toList(); final Map<String, Object> result = checkNonVarargs(underTest, paramsToUse); assertThat((String[])result.get("lotsOfParams"), arrayContaining(varArgs.toArray())); } private Map<String, Object> checkNonVarargs(Method underTest, List<String> params) throws Throwable {
DecoratingFrameworkMethod decoratingFrameworkMethod = new DecoratingFrameworkMethod(new FrameworkMethod(underTest), row(params));
bodar/yatspec
src/com/googlecode/yatspec/rendering/html/DontHighlightRenderer.java
// Path: src/com/googlecode/yatspec/rendering/Renderer.java // public interface Renderer<T> { // String render(T t) throws Exception; // } // // Path: src/com/googlecode/yatspec/rendering/ToStringRenderer.java // public class ToStringRenderer<T> implements Renderer<T> { // public String render(T instance) throws Exception { // return instance != null ? instance.toString() : ""; // } // }
import com.googlecode.yatspec.rendering.Renderer; import com.googlecode.yatspec.rendering.ToStringRenderer;
package com.googlecode.yatspec.rendering.html; public class DontHighlightRenderer<T> implements Renderer<T> { public String render(T instance) throws Exception {
// Path: src/com/googlecode/yatspec/rendering/Renderer.java // public interface Renderer<T> { // String render(T t) throws Exception; // } // // Path: src/com/googlecode/yatspec/rendering/ToStringRenderer.java // public class ToStringRenderer<T> implements Renderer<T> { // public String render(T instance) throws Exception { // return instance != null ? instance.toString() : ""; // } // } // Path: src/com/googlecode/yatspec/rendering/html/DontHighlightRenderer.java import com.googlecode.yatspec.rendering.Renderer; import com.googlecode.yatspec.rendering.ToStringRenderer; package com.googlecode.yatspec.rendering.html; public class DontHighlightRenderer<T> implements Renderer<T> { public String render(T instance) throws Exception {
return "<div class='nohighlight'>" + new ToStringRenderer().render(instance) + "</div>";
bodar/yatspec
src/com/googlecode/yatspec/rendering/Renderers.java
// Path: src/com/googlecode/yatspec/rendering/html/HtmlResultRenderer.java // public class HtmlResultRenderer implements SpecResultListener { // private final List<Pair<Predicate, Renderer>> customRenderers = new ArrayList<Pair<Predicate, Renderer>>(); // // private List<Content> customScripts = Collections.emptyList(); // private List<Content> customHeaderContents = Collections.emptyList(); // // @Override // public void complete(File yatspecOutputDir, Result result) throws Exception { // overwrite(htmlResultFile(yatspecOutputDir, result.getTestClass()), render(result)); // } // // public String render(Result result) throws Exception { // final EnhancedStringTemplateGroup group = new EnhancedStringTemplateGroup(getClass()); // group.registerRenderer(always().and(not(instanceOf(Number.class))), Xml.escape()); // group.registerRenderer(instanceOf(ScenarioTableHeader.class), callable(new ScenarioTableHeaderRenderer())); // group.registerRenderer(instanceOf(JavaSource.class), callable(new JavaSourceRenderer())); // group.registerRenderer(instanceOf(Notes.class), callable(new NotesRenderer())); // group.registerRenderer(instanceOf(LinkingNote.class), callable(new LinkingNoteRenderer(result.getTestClass()))); // group.registerRenderer(instanceOf(ContentAtUrl.class), asString()); // sequence(customRenderers).fold(group, registerRenderer()); // for (Class document : Creator.optionalClass("org.jdom.Document")) { // group.registerRenderer(instanceOf(document), callable(Creator.<Renderer>create(Class.forName("com.googlecode.yatspec.plugin.jdom.DocumentRenderer")))); // } // // final StringTemplate template = group.getInstanceOf("yatspec"); // template.setAttribute("script", loadContent("xregexp.js")); // template.setAttribute("script", loadContent("yatspec.js")); // for (Content customScript : customScripts) { // template.setAttribute("script", customScript); // } // for (Content customHeaderContent : customHeaderContents) { // template.setAttribute("customHeaderContent", customHeaderContent); // } // template.setAttribute("stylesheet", loadContent("yatspec.css")); // template.setAttribute("cssClass", getCssMap()); // template.setAttribute("testResult", result); // StringWriter writer = new StringWriter(); // template.write(new NoIndentWriter(writer)); // return writer.toString(); // } // // public <T> HtmlResultRenderer withCustomRenderer(Class<T> klazz, Renderer<T> renderer) { // return withCustomRenderer((Predicate) instanceOf(klazz), renderer); // } // // public <T> HtmlResultRenderer withCustomRenderer(Predicate<T> predicate, Renderer<T> renderer) { // customRenderers.add(Pair.<Predicate, Renderer>pair(predicate, renderer)); // return this; // } // // public static <T> Callable1<T, String> callable(final Renderer<T> value) { // return new Callable1<T, String>() { // @Override // public String call(T o) throws Exception { // return value.render(o); // } // }; // } // // public static Content loadContent(final String resource) throws IOException { // return new ContentAtUrl(HtmlResultRenderer.class.getResource(resource)); // } // // public static Map<Status, String> getCssMap() { // return new HashMap<Status, String>() {{ // put(Status.Passed, "test-passed"); // put(Status.Failed, "test-failed"); // put(Status.NotRun, "test-not-run"); // }}; // } // // public static String htmlResultRelativePath(Class resultClass) { // return Files.toPath(resultClass) + ".html"; // } // // public static File htmlResultFile(File outputDirectory, Class resultClass) { // return new File(outputDirectory, htmlResultRelativePath(resultClass)); // } // // public static String testMethodRelativePath(TestMethod testMethod) { // return format("%s#%s", // htmlResultRelativePath(testMethod.getTestClass()), // testMethod.getName()); // } // // public HtmlResultRenderer withCustomHeaderContent(Content... content) { // this.customHeaderContents = Arrays.asList(content); // return this; // } // // public HtmlResultRenderer withCustomScripts(Content... scripts) { // this.customScripts = Arrays.asList(scripts); // return this; // } // }
import com.googlecode.funclate.stringtemplate.EnhancedStringTemplateGroup; import com.googlecode.totallylazy.Callable2; import com.googlecode.totallylazy.Pair; import com.googlecode.totallylazy.Predicate; import com.googlecode.totallylazy.Predicates; import com.googlecode.yatspec.rendering.html.HtmlResultRenderer; import java.util.Map;
package com.googlecode.yatspec.rendering; public class Renderers { public static Callable2<EnhancedStringTemplateGroup, Pair<Predicate, Renderer>, EnhancedStringTemplateGroup> registerRenderer() { return new Callable2<EnhancedStringTemplateGroup, Pair<Predicate, Renderer>, EnhancedStringTemplateGroup>() { @Override public EnhancedStringTemplateGroup call(EnhancedStringTemplateGroup group, Pair<Predicate, Renderer> entry) throws Exception {
// Path: src/com/googlecode/yatspec/rendering/html/HtmlResultRenderer.java // public class HtmlResultRenderer implements SpecResultListener { // private final List<Pair<Predicate, Renderer>> customRenderers = new ArrayList<Pair<Predicate, Renderer>>(); // // private List<Content> customScripts = Collections.emptyList(); // private List<Content> customHeaderContents = Collections.emptyList(); // // @Override // public void complete(File yatspecOutputDir, Result result) throws Exception { // overwrite(htmlResultFile(yatspecOutputDir, result.getTestClass()), render(result)); // } // // public String render(Result result) throws Exception { // final EnhancedStringTemplateGroup group = new EnhancedStringTemplateGroup(getClass()); // group.registerRenderer(always().and(not(instanceOf(Number.class))), Xml.escape()); // group.registerRenderer(instanceOf(ScenarioTableHeader.class), callable(new ScenarioTableHeaderRenderer())); // group.registerRenderer(instanceOf(JavaSource.class), callable(new JavaSourceRenderer())); // group.registerRenderer(instanceOf(Notes.class), callable(new NotesRenderer())); // group.registerRenderer(instanceOf(LinkingNote.class), callable(new LinkingNoteRenderer(result.getTestClass()))); // group.registerRenderer(instanceOf(ContentAtUrl.class), asString()); // sequence(customRenderers).fold(group, registerRenderer()); // for (Class document : Creator.optionalClass("org.jdom.Document")) { // group.registerRenderer(instanceOf(document), callable(Creator.<Renderer>create(Class.forName("com.googlecode.yatspec.plugin.jdom.DocumentRenderer")))); // } // // final StringTemplate template = group.getInstanceOf("yatspec"); // template.setAttribute("script", loadContent("xregexp.js")); // template.setAttribute("script", loadContent("yatspec.js")); // for (Content customScript : customScripts) { // template.setAttribute("script", customScript); // } // for (Content customHeaderContent : customHeaderContents) { // template.setAttribute("customHeaderContent", customHeaderContent); // } // template.setAttribute("stylesheet", loadContent("yatspec.css")); // template.setAttribute("cssClass", getCssMap()); // template.setAttribute("testResult", result); // StringWriter writer = new StringWriter(); // template.write(new NoIndentWriter(writer)); // return writer.toString(); // } // // public <T> HtmlResultRenderer withCustomRenderer(Class<T> klazz, Renderer<T> renderer) { // return withCustomRenderer((Predicate) instanceOf(klazz), renderer); // } // // public <T> HtmlResultRenderer withCustomRenderer(Predicate<T> predicate, Renderer<T> renderer) { // customRenderers.add(Pair.<Predicate, Renderer>pair(predicate, renderer)); // return this; // } // // public static <T> Callable1<T, String> callable(final Renderer<T> value) { // return new Callable1<T, String>() { // @Override // public String call(T o) throws Exception { // return value.render(o); // } // }; // } // // public static Content loadContent(final String resource) throws IOException { // return new ContentAtUrl(HtmlResultRenderer.class.getResource(resource)); // } // // public static Map<Status, String> getCssMap() { // return new HashMap<Status, String>() {{ // put(Status.Passed, "test-passed"); // put(Status.Failed, "test-failed"); // put(Status.NotRun, "test-not-run"); // }}; // } // // public static String htmlResultRelativePath(Class resultClass) { // return Files.toPath(resultClass) + ".html"; // } // // public static File htmlResultFile(File outputDirectory, Class resultClass) { // return new File(outputDirectory, htmlResultRelativePath(resultClass)); // } // // public static String testMethodRelativePath(TestMethod testMethod) { // return format("%s#%s", // htmlResultRelativePath(testMethod.getTestClass()), // testMethod.getName()); // } // // public HtmlResultRenderer withCustomHeaderContent(Content... content) { // this.customHeaderContents = Arrays.asList(content); // return this; // } // // public HtmlResultRenderer withCustomScripts(Content... scripts) { // this.customScripts = Arrays.asList(scripts); // return this; // } // } // Path: src/com/googlecode/yatspec/rendering/Renderers.java import com.googlecode.funclate.stringtemplate.EnhancedStringTemplateGroup; import com.googlecode.totallylazy.Callable2; import com.googlecode.totallylazy.Pair; import com.googlecode.totallylazy.Predicate; import com.googlecode.totallylazy.Predicates; import com.googlecode.yatspec.rendering.html.HtmlResultRenderer; import java.util.Map; package com.googlecode.yatspec.rendering; public class Renderers { public static Callable2<EnhancedStringTemplateGroup, Pair<Predicate, Renderer>, EnhancedStringTemplateGroup> registerRenderer() { return new Callable2<EnhancedStringTemplateGroup, Pair<Predicate, Renderer>, EnhancedStringTemplateGroup>() { @Override public EnhancedStringTemplateGroup call(EnhancedStringTemplateGroup group, Pair<Predicate, Renderer> entry) throws Exception {
return group.registerRenderer(entry.first(), HtmlResultRenderer.callable(entry.second()));
bodar/yatspec
test/com/googlecode/yatspec/state/givenwhenthen/InterestingGivensTypeLoaderTest.java
// Path: src/com/googlecode/yatspec/state/givenwhenthen/InterestingGivensTypeLoader.java // public static <T> Callable<T> interestingGivensType(InterestingGivens interestingGivens, Class<T> klazz) { // return new InterestingGivensTypeLoader<T>(interestingGivens, null, klazz); // }
import org.junit.Before; import org.junit.Test; import static com.googlecode.yatspec.state.givenwhenthen.InterestingGivensTypeLoader.interestingGivensType; import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.MatcherAssert.assertThat;
package com.googlecode.yatspec.state.givenwhenthen; public class InterestingGivensTypeLoaderTest { private InterestingGivens interestingGivens; private static final String KEY = "key"; private static final String VALUE = "value"; private static final Class<String> CLASS = String.class; @Before public void setUp() { interestingGivens = new InterestingGivens(); interestingGivens.add(KEY, VALUE); interestingGivens.add(VALUE); } @Test public void shouldGetTypeByClass() throws Exception {
// Path: src/com/googlecode/yatspec/state/givenwhenthen/InterestingGivensTypeLoader.java // public static <T> Callable<T> interestingGivensType(InterestingGivens interestingGivens, Class<T> klazz) { // return new InterestingGivensTypeLoader<T>(interestingGivens, null, klazz); // } // Path: test/com/googlecode/yatspec/state/givenwhenthen/InterestingGivensTypeLoaderTest.java import org.junit.Before; import org.junit.Test; import static com.googlecode.yatspec.state.givenwhenthen.InterestingGivensTypeLoader.interestingGivensType; import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.MatcherAssert.assertThat; package com.googlecode.yatspec.state.givenwhenthen; public class InterestingGivensTypeLoaderTest { private InterestingGivens interestingGivens; private static final String KEY = "key"; private static final String VALUE = "value"; private static final Class<String> CLASS = String.class; @Before public void setUp() { interestingGivens = new InterestingGivens(); interestingGivens.add(KEY, VALUE); interestingGivens.add(VALUE); } @Test public void shouldGetTypeByClass() throws Exception {
assertThat(interestingGivensType(interestingGivens, CLASS).call(), is(VALUE));
bodar/yatspec
test/com/googlecode/yatspec/plugin/jdom/HasXPathTest.java
// Path: src/com/googlecode/yatspec/plugin/jdom/HasXPath.java // @Factory // public static Matcher<Document> hasXPath(String xpathExpression, Namespace... namespaces) { // return new HasXPath(xpathExpression, namespaces); // }
import org.jdom.Document; import org.jdom.Namespace; import org.jdom.input.SAXBuilder; import org.junit.Test; import java.io.ByteArrayInputStream; import static com.googlecode.yatspec.plugin.jdom.HasXPath.hasXPath; import static java.lang.String.format; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.is; import static org.jdom.Namespace.getNamespace;
public void shouldNotMatchAttribute() throws Exception { assertMatches(format("not(//ChildElement[@attribute='%s'])", "provide"), NO_NAMESPACE_XML, false); } @Test public void shouldNotMatchElement() throws Exception { assertMatches("not(//ChildElement)", NO_NAMESPACE_XML, false); } @Test public void shouldNotMatchNonExistentAttribute() throws Exception { assertMatches("/ParentElement/@doesNotExist", NO_NAMESPACE_XML, false); } @Test public void shouldNotMatchNonExistentElement() throws Exception { assertMatches("//ChildElement/doesNotExist", NO_NAMESPACE_XML, false); } @Test public void shouldMatchFunction() throws Exception { assertMatches("count(//ChildElement) = 1", NO_NAMESPACE_XML, true); } @Test public void shouldNotMatchFunction() throws Exception { assertMatches("count(//ChildElement) = 2", NO_NAMESPACE_XML, false); } private static void assertMatches(String xpathQuery, String xml, boolean expected, Namespace... namespaces) throws Exception {
// Path: src/com/googlecode/yatspec/plugin/jdom/HasXPath.java // @Factory // public static Matcher<Document> hasXPath(String xpathExpression, Namespace... namespaces) { // return new HasXPath(xpathExpression, namespaces); // } // Path: test/com/googlecode/yatspec/plugin/jdom/HasXPathTest.java import org.jdom.Document; import org.jdom.Namespace; import org.jdom.input.SAXBuilder; import org.junit.Test; import java.io.ByteArrayInputStream; import static com.googlecode.yatspec.plugin.jdom.HasXPath.hasXPath; import static java.lang.String.format; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.is; import static org.jdom.Namespace.getNamespace; public void shouldNotMatchAttribute() throws Exception { assertMatches(format("not(//ChildElement[@attribute='%s'])", "provide"), NO_NAMESPACE_XML, false); } @Test public void shouldNotMatchElement() throws Exception { assertMatches("not(//ChildElement)", NO_NAMESPACE_XML, false); } @Test public void shouldNotMatchNonExistentAttribute() throws Exception { assertMatches("/ParentElement/@doesNotExist", NO_NAMESPACE_XML, false); } @Test public void shouldNotMatchNonExistentElement() throws Exception { assertMatches("//ChildElement/doesNotExist", NO_NAMESPACE_XML, false); } @Test public void shouldMatchFunction() throws Exception { assertMatches("count(//ChildElement) = 1", NO_NAMESPACE_XML, true); } @Test public void shouldNotMatchFunction() throws Exception { assertMatches("count(//ChildElement) = 2", NO_NAMESPACE_XML, false); } private static void assertMatches(String xpathQuery, String xml, boolean expected, Namespace... namespaces) throws Exception {
assertThat(hasXPath(xpathQuery, namespaces).matches(toDocument(xml)), is(expected));
bodar/yatspec
src/com/googlecode/yatspec/rendering/LinkingNoteRenderer.java
// Path: src/com/googlecode/yatspec/rendering/Renderer.java // public interface Renderer<T> { // String render(T t) throws Exception; // } // // Path: src/com/googlecode/yatspec/parsing/Text.java // public static String wordify(String value) { // final String wordified = quotedStrings.findMatches(value).replace(wordifier, doNothing); // return Strings.capitalise(spaceRemover.matcher(wordified).replaceAll(" ").trim()); // } // // Path: src/com/googlecode/yatspec/rendering/html/HtmlResultRenderer.java // public static String htmlResultRelativePath(Class resultClass) { // return Files.toPath(resultClass) + ".html"; // }
import com.googlecode.totallylazy.Callable1; import com.googlecode.yatspec.junit.LinkingNote; import com.googlecode.yatspec.rendering.Renderer; import java.io.File; import static com.googlecode.totallylazy.Sequences.sequence; import static com.googlecode.yatspec.parsing.Text.wordify; import static com.googlecode.yatspec.rendering.html.HtmlResultRenderer.htmlResultRelativePath; import static java.lang.String.format;
package com.googlecode.yatspec.rendering; public class LinkingNoteRenderer implements Renderer<LinkingNote> { private final Class<?> source; public LinkingNoteRenderer(Class<?> source) { this.source = source; } @Override public String render(LinkingNote linkingNoteNotes) throws Exception { return format(linkingNoteNotes.message(), (Object[])sequence(linkingNoteNotes.links()).map(link()).toArray(String.class)); } private Callable1<Class, String> link() { return new Callable1<Class, String>() { @Override public String call(Class targetClass) throws Exception {
// Path: src/com/googlecode/yatspec/rendering/Renderer.java // public interface Renderer<T> { // String render(T t) throws Exception; // } // // Path: src/com/googlecode/yatspec/parsing/Text.java // public static String wordify(String value) { // final String wordified = quotedStrings.findMatches(value).replace(wordifier, doNothing); // return Strings.capitalise(spaceRemover.matcher(wordified).replaceAll(" ").trim()); // } // // Path: src/com/googlecode/yatspec/rendering/html/HtmlResultRenderer.java // public static String htmlResultRelativePath(Class resultClass) { // return Files.toPath(resultClass) + ".html"; // } // Path: src/com/googlecode/yatspec/rendering/LinkingNoteRenderer.java import com.googlecode.totallylazy.Callable1; import com.googlecode.yatspec.junit.LinkingNote; import com.googlecode.yatspec.rendering.Renderer; import java.io.File; import static com.googlecode.totallylazy.Sequences.sequence; import static com.googlecode.yatspec.parsing.Text.wordify; import static com.googlecode.yatspec.rendering.html.HtmlResultRenderer.htmlResultRelativePath; import static java.lang.String.format; package com.googlecode.yatspec.rendering; public class LinkingNoteRenderer implements Renderer<LinkingNote> { private final Class<?> source; public LinkingNoteRenderer(Class<?> source) { this.source = source; } @Override public String render(LinkingNote linkingNoteNotes) throws Exception { return format(linkingNoteNotes.message(), (Object[])sequence(linkingNoteNotes.links()).map(link()).toArray(String.class)); } private Callable1<Class, String> link() { return new Callable1<Class, String>() { @Override public String call(Class targetClass) throws Exception {
return format("<a href='%s'>%s</a>", htmlResultFile(targetClass, source), wordify(targetClass.getSimpleName()));
bodar/yatspec
src/com/googlecode/yatspec/rendering/LinkingNoteRenderer.java
// Path: src/com/googlecode/yatspec/rendering/Renderer.java // public interface Renderer<T> { // String render(T t) throws Exception; // } // // Path: src/com/googlecode/yatspec/parsing/Text.java // public static String wordify(String value) { // final String wordified = quotedStrings.findMatches(value).replace(wordifier, doNothing); // return Strings.capitalise(spaceRemover.matcher(wordified).replaceAll(" ").trim()); // } // // Path: src/com/googlecode/yatspec/rendering/html/HtmlResultRenderer.java // public static String htmlResultRelativePath(Class resultClass) { // return Files.toPath(resultClass) + ".html"; // }
import com.googlecode.totallylazy.Callable1; import com.googlecode.yatspec.junit.LinkingNote; import com.googlecode.yatspec.rendering.Renderer; import java.io.File; import static com.googlecode.totallylazy.Sequences.sequence; import static com.googlecode.yatspec.parsing.Text.wordify; import static com.googlecode.yatspec.rendering.html.HtmlResultRenderer.htmlResultRelativePath; import static java.lang.String.format;
package com.googlecode.yatspec.rendering; public class LinkingNoteRenderer implements Renderer<LinkingNote> { private final Class<?> source; public LinkingNoteRenderer(Class<?> source) { this.source = source; } @Override public String render(LinkingNote linkingNoteNotes) throws Exception { return format(linkingNoteNotes.message(), (Object[])sequence(linkingNoteNotes.links()).map(link()).toArray(String.class)); } private Callable1<Class, String> link() { return new Callable1<Class, String>() { @Override public String call(Class targetClass) throws Exception { return format("<a href='%s'>%s</a>", htmlResultFile(targetClass, source), wordify(targetClass.getSimpleName())); } }; } private File htmlResultFile(Class resultClass, Class sourceClass) {
// Path: src/com/googlecode/yatspec/rendering/Renderer.java // public interface Renderer<T> { // String render(T t) throws Exception; // } // // Path: src/com/googlecode/yatspec/parsing/Text.java // public static String wordify(String value) { // final String wordified = quotedStrings.findMatches(value).replace(wordifier, doNothing); // return Strings.capitalise(spaceRemover.matcher(wordified).replaceAll(" ").trim()); // } // // Path: src/com/googlecode/yatspec/rendering/html/HtmlResultRenderer.java // public static String htmlResultRelativePath(Class resultClass) { // return Files.toPath(resultClass) + ".html"; // } // Path: src/com/googlecode/yatspec/rendering/LinkingNoteRenderer.java import com.googlecode.totallylazy.Callable1; import com.googlecode.yatspec.junit.LinkingNote; import com.googlecode.yatspec.rendering.Renderer; import java.io.File; import static com.googlecode.totallylazy.Sequences.sequence; import static com.googlecode.yatspec.parsing.Text.wordify; import static com.googlecode.yatspec.rendering.html.HtmlResultRenderer.htmlResultRelativePath; import static java.lang.String.format; package com.googlecode.yatspec.rendering; public class LinkingNoteRenderer implements Renderer<LinkingNote> { private final Class<?> source; public LinkingNoteRenderer(Class<?> source) { this.source = source; } @Override public String render(LinkingNote linkingNoteNotes) throws Exception { return format(linkingNoteNotes.message(), (Object[])sequence(linkingNoteNotes.links()).map(link()).toArray(String.class)); } private Callable1<Class, String> link() { return new Callable1<Class, String>() { @Override public String call(Class targetClass) throws Exception { return format("<a href='%s'>%s</a>", htmlResultFile(targetClass, source), wordify(targetClass.getSimpleName())); } }; } private File htmlResultFile(Class resultClass, Class sourceClass) {
return new File(getRootDirectoryPath(sourceClass) + htmlResultRelativePath(resultClass));
bodar/yatspec
src/com/googlecode/yatspec/plugin/jdom/StateExtractors.java
// Path: src/com/googlecode/yatspec/state/givenwhenthen/CapturedInputAndOutputs.java // public class CapturedInputAndOutputs extends NiceMap<CapturedInputAndOutputs>{ // public CapturedInputAndOutputs(Object... instances) { // super(instances); // } // } // // Path: src/com/googlecode/yatspec/state/givenwhenthen/StateExtractor.java // public interface StateExtractor<ItemOfInterest> { // ItemOfInterest execute(CapturedInputAndOutputs inputAndOutputs) throws Exception; // }
import com.googlecode.totallylazy.Callable1; import com.googlecode.yatspec.state.givenwhenthen.CapturedInputAndOutputs; import com.googlecode.yatspec.state.givenwhenthen.StateExtractor; import org.jdom.Attribute; import org.jdom.Document; import org.jdom.Element; import java.util.List; import static com.googlecode.totallylazy.Sequences.sequence; import static org.jdom.xpath.XPath.newInstance;
package com.googlecode.yatspec.plugin.jdom; public class StateExtractors { private StateExtractors() { }
// Path: src/com/googlecode/yatspec/state/givenwhenthen/CapturedInputAndOutputs.java // public class CapturedInputAndOutputs extends NiceMap<CapturedInputAndOutputs>{ // public CapturedInputAndOutputs(Object... instances) { // super(instances); // } // } // // Path: src/com/googlecode/yatspec/state/givenwhenthen/StateExtractor.java // public interface StateExtractor<ItemOfInterest> { // ItemOfInterest execute(CapturedInputAndOutputs inputAndOutputs) throws Exception; // } // Path: src/com/googlecode/yatspec/plugin/jdom/StateExtractors.java import com.googlecode.totallylazy.Callable1; import com.googlecode.yatspec.state.givenwhenthen.CapturedInputAndOutputs; import com.googlecode.yatspec.state.givenwhenthen.StateExtractor; import org.jdom.Attribute; import org.jdom.Document; import org.jdom.Element; import java.util.List; import static com.googlecode.totallylazy.Sequences.sequence; import static org.jdom.xpath.XPath.newInstance; package com.googlecode.yatspec.plugin.jdom; public class StateExtractors { private StateExtractors() { }
public static <T> StateExtractor<T> getValue(final String key, final Class<T> klazz) {
bodar/yatspec
src/com/googlecode/yatspec/plugin/jdom/StateExtractors.java
// Path: src/com/googlecode/yatspec/state/givenwhenthen/CapturedInputAndOutputs.java // public class CapturedInputAndOutputs extends NiceMap<CapturedInputAndOutputs>{ // public CapturedInputAndOutputs(Object... instances) { // super(instances); // } // } // // Path: src/com/googlecode/yatspec/state/givenwhenthen/StateExtractor.java // public interface StateExtractor<ItemOfInterest> { // ItemOfInterest execute(CapturedInputAndOutputs inputAndOutputs) throws Exception; // }
import com.googlecode.totallylazy.Callable1; import com.googlecode.yatspec.state.givenwhenthen.CapturedInputAndOutputs; import com.googlecode.yatspec.state.givenwhenthen.StateExtractor; import org.jdom.Attribute; import org.jdom.Document; import org.jdom.Element; import java.util.List; import static com.googlecode.totallylazy.Sequences.sequence; import static org.jdom.xpath.XPath.newInstance;
package com.googlecode.yatspec.plugin.jdom; public class StateExtractors { private StateExtractors() { } public static <T> StateExtractor<T> getValue(final String key, final Class<T> klazz) { return new StateExtractor<T>() {
// Path: src/com/googlecode/yatspec/state/givenwhenthen/CapturedInputAndOutputs.java // public class CapturedInputAndOutputs extends NiceMap<CapturedInputAndOutputs>{ // public CapturedInputAndOutputs(Object... instances) { // super(instances); // } // } // // Path: src/com/googlecode/yatspec/state/givenwhenthen/StateExtractor.java // public interface StateExtractor<ItemOfInterest> { // ItemOfInterest execute(CapturedInputAndOutputs inputAndOutputs) throws Exception; // } // Path: src/com/googlecode/yatspec/plugin/jdom/StateExtractors.java import com.googlecode.totallylazy.Callable1; import com.googlecode.yatspec.state.givenwhenthen.CapturedInputAndOutputs; import com.googlecode.yatspec.state.givenwhenthen.StateExtractor; import org.jdom.Attribute; import org.jdom.Document; import org.jdom.Element; import java.util.List; import static com.googlecode.totallylazy.Sequences.sequence; import static org.jdom.xpath.XPath.newInstance; package com.googlecode.yatspec.plugin.jdom; public class StateExtractors { private StateExtractors() { } public static <T> StateExtractor<T> getValue(final String key, final Class<T> klazz) { return new StateExtractor<T>() {
public T execute(CapturedInputAndOutputs capturedInputAndOutputs) throws Exception {
bodar/yatspec
src/com/googlecode/yatspec/rendering/wiki/JavaSourceRenderer.java
// Path: src/com/googlecode/yatspec/parsing/JavaSource.java // public class JavaSource implements Value<String> { // private static final String COMMA_OR_OPENING_BRACKET = "(\\s*[\\(\\,\"]\\s*)"; // private static final String COMMA_OR_CLOSING_BRACKET = "(\\s*[\\,\\)\"]\\s*)"; // private final String value; // // public JavaSource(String value) { // this.value = value; // } // // @Override // public String value() { // return value; // } // // public JavaSource replace(final List<String> oldValues, final List<String> newValues) { // String result = value(); // for (int i = 0; i < oldValues.size(); i++) { // String header = oldValues.get(i); // String value = newValues.get(i); // result = result.replaceAll(COMMA_OR_OPENING_BRACKET + header + COMMA_OR_CLOSING_BRACKET, "$1" + displayValue(value) + "$2"); // } // return new JavaSource(result); // } // // private static String displayValue(String value) { // if (value.matches("[A-Z0-9]*")) { // return value; // } // return "\"" + value + "\""; // } // // @Override // public String toString() { // return value(); // } // } // // Path: src/com/googlecode/yatspec/rendering/Renderer.java // public interface Renderer<T> { // String render(T t) throws Exception; // } // // Path: src/com/googlecode/yatspec/rendering/html/JavaSourceRenderer.java // public static Sequence<String> lines(final String sourceCode) { // return sequence(sourceCode.split(lineSeparator())); // }
import com.googlecode.totallylazy.Callable1; import com.googlecode.totallylazy.Predicate; import com.googlecode.totallylazy.Sequence; import com.googlecode.totallylazy.regex.Regex; import com.googlecode.yatspec.parsing.JavaSource; import com.googlecode.yatspec.rendering.Renderer; import static com.googlecode.totallylazy.Predicates.not; import static com.googlecode.totallylazy.Strings.EMPTY; import static com.googlecode.yatspec.rendering.html.JavaSourceRenderer.lines; import static java.lang.System.lineSeparator;
package com.googlecode.yatspec.rendering.wiki; public class JavaSourceRenderer implements Renderer<JavaSource> { @Override public String render(JavaSource javaSource) throws Exception { return removeBlankLines(removeIndentation(javaSource.value())); } private String removeBlankLines(String value) { return value.replaceAll("^\\s+|\\s+$", EMPTY); } private String removeIndentation(String value) {
// Path: src/com/googlecode/yatspec/parsing/JavaSource.java // public class JavaSource implements Value<String> { // private static final String COMMA_OR_OPENING_BRACKET = "(\\s*[\\(\\,\"]\\s*)"; // private static final String COMMA_OR_CLOSING_BRACKET = "(\\s*[\\,\\)\"]\\s*)"; // private final String value; // // public JavaSource(String value) { // this.value = value; // } // // @Override // public String value() { // return value; // } // // public JavaSource replace(final List<String> oldValues, final List<String> newValues) { // String result = value(); // for (int i = 0; i < oldValues.size(); i++) { // String header = oldValues.get(i); // String value = newValues.get(i); // result = result.replaceAll(COMMA_OR_OPENING_BRACKET + header + COMMA_OR_CLOSING_BRACKET, "$1" + displayValue(value) + "$2"); // } // return new JavaSource(result); // } // // private static String displayValue(String value) { // if (value.matches("[A-Z0-9]*")) { // return value; // } // return "\"" + value + "\""; // } // // @Override // public String toString() { // return value(); // } // } // // Path: src/com/googlecode/yatspec/rendering/Renderer.java // public interface Renderer<T> { // String render(T t) throws Exception; // } // // Path: src/com/googlecode/yatspec/rendering/html/JavaSourceRenderer.java // public static Sequence<String> lines(final String sourceCode) { // return sequence(sourceCode.split(lineSeparator())); // } // Path: src/com/googlecode/yatspec/rendering/wiki/JavaSourceRenderer.java import com.googlecode.totallylazy.Callable1; import com.googlecode.totallylazy.Predicate; import com.googlecode.totallylazy.Sequence; import com.googlecode.totallylazy.regex.Regex; import com.googlecode.yatspec.parsing.JavaSource; import com.googlecode.yatspec.rendering.Renderer; import static com.googlecode.totallylazy.Predicates.not; import static com.googlecode.totallylazy.Strings.EMPTY; import static com.googlecode.yatspec.rendering.html.JavaSourceRenderer.lines; import static java.lang.System.lineSeparator; package com.googlecode.yatspec.rendering.wiki; public class JavaSourceRenderer implements Renderer<JavaSource> { @Override public String render(JavaSource javaSource) throws Exception { return removeBlankLines(removeIndentation(javaSource.value())); } private String removeBlankLines(String value) { return value.replaceAll("^\\s+|\\s+$", EMPTY); } private String removeIndentation(String value) {
Sequence<String> lines = lines(value);
bodar/yatspec
src/com/googlecode/yatspec/rendering/html/JavaSourceRenderer.java
// Path: src/com/googlecode/yatspec/parsing/JavaSource.java // public class JavaSource implements Value<String> { // private static final String COMMA_OR_OPENING_BRACKET = "(\\s*[\\(\\,\"]\\s*)"; // private static final String COMMA_OR_CLOSING_BRACKET = "(\\s*[\\,\\)\"]\\s*)"; // private final String value; // // public JavaSource(String value) { // this.value = value; // } // // @Override // public String value() { // return value; // } // // public JavaSource replace(final List<String> oldValues, final List<String> newValues) { // String result = value(); // for (int i = 0; i < oldValues.size(); i++) { // String header = oldValues.get(i); // String value = newValues.get(i); // result = result.replaceAll(COMMA_OR_OPENING_BRACKET + header + COMMA_OR_CLOSING_BRACKET, "$1" + displayValue(value) + "$2"); // } // return new JavaSource(result); // } // // private static String displayValue(String value) { // if (value.matches("[A-Z0-9]*")) { // return value; // } // return "\"" + value + "\""; // } // // @Override // public String toString() { // return value(); // } // } // // Path: src/com/googlecode/yatspec/rendering/Renderer.java // public interface Renderer<T> { // String render(T t) throws Exception; // } // // Path: src/com/googlecode/yatspec/parsing/Text.java // public static String wordify(String value) { // final String wordified = quotedStrings.findMatches(value).replace(wordifier, doNothing); // return Strings.capitalise(spaceRemover.matcher(wordified).replaceAll(" ").trim()); // }
import com.googlecode.totallylazy.Sequence; import com.googlecode.yatspec.parsing.JavaSource; import com.googlecode.yatspec.rendering.Renderer; import java.util.regex.Pattern; import static com.googlecode.totallylazy.Sequences.sequence; import static com.googlecode.totallylazy.Xml.escape; import static com.googlecode.yatspec.parsing.Text.wordify; import static java.lang.System.lineSeparator;
package com.googlecode.yatspec.rendering.html; public class JavaSourceRenderer implements Renderer<JavaSource> { private static final Pattern DOT_CLASS = Pattern.compile("\\.class(\\W|$)"); @Override public String render(JavaSource javaSource) throws Exception {
// Path: src/com/googlecode/yatspec/parsing/JavaSource.java // public class JavaSource implements Value<String> { // private static final String COMMA_OR_OPENING_BRACKET = "(\\s*[\\(\\,\"]\\s*)"; // private static final String COMMA_OR_CLOSING_BRACKET = "(\\s*[\\,\\)\"]\\s*)"; // private final String value; // // public JavaSource(String value) { // this.value = value; // } // // @Override // public String value() { // return value; // } // // public JavaSource replace(final List<String> oldValues, final List<String> newValues) { // String result = value(); // for (int i = 0; i < oldValues.size(); i++) { // String header = oldValues.get(i); // String value = newValues.get(i); // result = result.replaceAll(COMMA_OR_OPENING_BRACKET + header + COMMA_OR_CLOSING_BRACKET, "$1" + displayValue(value) + "$2"); // } // return new JavaSource(result); // } // // private static String displayValue(String value) { // if (value.matches("[A-Z0-9]*")) { // return value; // } // return "\"" + value + "\""; // } // // @Override // public String toString() { // return value(); // } // } // // Path: src/com/googlecode/yatspec/rendering/Renderer.java // public interface Renderer<T> { // String render(T t) throws Exception; // } // // Path: src/com/googlecode/yatspec/parsing/Text.java // public static String wordify(String value) { // final String wordified = quotedStrings.findMatches(value).replace(wordifier, doNothing); // return Strings.capitalise(spaceRemover.matcher(wordified).replaceAll(" ").trim()); // } // Path: src/com/googlecode/yatspec/rendering/html/JavaSourceRenderer.java import com.googlecode.totallylazy.Sequence; import com.googlecode.yatspec.parsing.JavaSource; import com.googlecode.yatspec.rendering.Renderer; import java.util.regex.Pattern; import static com.googlecode.totallylazy.Sequences.sequence; import static com.googlecode.totallylazy.Xml.escape; import static com.googlecode.yatspec.parsing.Text.wordify; import static java.lang.System.lineSeparator; package com.googlecode.yatspec.rendering.html; public class JavaSourceRenderer implements Renderer<JavaSource> { private static final Pattern DOT_CLASS = Pattern.compile("\\.class(\\W|$)"); @Override public String render(JavaSource javaSource) throws Exception {
return escape(lines(removateDotClass(javaSource.value().trim())).map(wordify()).toString("\n"));
bodar/yatspec
test/com/googlecode/yatspec/plugin/jdom/StateExtractorsTest.java
// Path: src/com/googlecode/yatspec/state/givenwhenthen/CapturedInputAndOutputs.java // public class CapturedInputAndOutputs extends NiceMap<CapturedInputAndOutputs>{ // public CapturedInputAndOutputs(Object... instances) { // super(instances); // } // } // // Path: src/com/googlecode/yatspec/plugin/jdom/StateExtractors.java // public static StateExtractor<String> getXpathValue(final String key, final String xpath) { // return new StateExtractor<String>() { // public String execute(CapturedInputAndOutputs capturedInputAndOutputs) throws Exception { // return getXpathValues(capturedInputAndOutputs, key, xpath).get(0); // } // }; // } // // Path: src/com/googlecode/yatspec/plugin/jdom/StateExtractors.java // public static StateExtractor<List<String>> getXpathValues(final String key, final String xpath) { // return new StateExtractor<List<String>>() { // public List<String> execute(CapturedInputAndOutputs capturedInputAndOutputs) throws Exception { // return getXpathValues(capturedInputAndOutputs, key, xpath); // } // }; // }
import com.googlecode.yatspec.state.givenwhenthen.CapturedInputAndOutputs; import org.jdom.Document; import org.jdom.JDOMException; import org.jdom.input.SAXBuilder; import org.junit.Test; import java.io.IOException; import java.io.StringReader; import java.util.Arrays; import java.util.Collection; import static com.googlecode.yatspec.plugin.jdom.StateExtractors.getXpathValue; import static com.googlecode.yatspec.plugin.jdom.StateExtractors.getXpathValues; import static java.util.Arrays.asList; import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.core.IsCollectionContaining.hasItem;
package com.googlecode.yatspec.plugin.jdom; public class StateExtractorsTest { private static final String NAME = "Fred"; private static final String ANOTHER_NAME = "Joe"; private static final String KEY = "Key"; @Test public void shouldExtractValue() throws Exception {
// Path: src/com/googlecode/yatspec/state/givenwhenthen/CapturedInputAndOutputs.java // public class CapturedInputAndOutputs extends NiceMap<CapturedInputAndOutputs>{ // public CapturedInputAndOutputs(Object... instances) { // super(instances); // } // } // // Path: src/com/googlecode/yatspec/plugin/jdom/StateExtractors.java // public static StateExtractor<String> getXpathValue(final String key, final String xpath) { // return new StateExtractor<String>() { // public String execute(CapturedInputAndOutputs capturedInputAndOutputs) throws Exception { // return getXpathValues(capturedInputAndOutputs, key, xpath).get(0); // } // }; // } // // Path: src/com/googlecode/yatspec/plugin/jdom/StateExtractors.java // public static StateExtractor<List<String>> getXpathValues(final String key, final String xpath) { // return new StateExtractor<List<String>>() { // public List<String> execute(CapturedInputAndOutputs capturedInputAndOutputs) throws Exception { // return getXpathValues(capturedInputAndOutputs, key, xpath); // } // }; // } // Path: test/com/googlecode/yatspec/plugin/jdom/StateExtractorsTest.java import com.googlecode.yatspec.state.givenwhenthen.CapturedInputAndOutputs; import org.jdom.Document; import org.jdom.JDOMException; import org.jdom.input.SAXBuilder; import org.junit.Test; import java.io.IOException; import java.io.StringReader; import java.util.Arrays; import java.util.Collection; import static com.googlecode.yatspec.plugin.jdom.StateExtractors.getXpathValue; import static com.googlecode.yatspec.plugin.jdom.StateExtractors.getXpathValues; import static java.util.Arrays.asList; import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.core.IsCollectionContaining.hasItem; package com.googlecode.yatspec.plugin.jdom; public class StateExtractorsTest { private static final String NAME = "Fred"; private static final String ANOTHER_NAME = "Joe"; private static final String KEY = "Key"; @Test public void shouldExtractValue() throws Exception {
CapturedInputAndOutputs inputAndOutputs = new CapturedInputAndOutputs().add(KEY, NAME);
bodar/yatspec
test/com/googlecode/yatspec/plugin/jdom/StateExtractorsTest.java
// Path: src/com/googlecode/yatspec/state/givenwhenthen/CapturedInputAndOutputs.java // public class CapturedInputAndOutputs extends NiceMap<CapturedInputAndOutputs>{ // public CapturedInputAndOutputs(Object... instances) { // super(instances); // } // } // // Path: src/com/googlecode/yatspec/plugin/jdom/StateExtractors.java // public static StateExtractor<String> getXpathValue(final String key, final String xpath) { // return new StateExtractor<String>() { // public String execute(CapturedInputAndOutputs capturedInputAndOutputs) throws Exception { // return getXpathValues(capturedInputAndOutputs, key, xpath).get(0); // } // }; // } // // Path: src/com/googlecode/yatspec/plugin/jdom/StateExtractors.java // public static StateExtractor<List<String>> getXpathValues(final String key, final String xpath) { // return new StateExtractor<List<String>>() { // public List<String> execute(CapturedInputAndOutputs capturedInputAndOutputs) throws Exception { // return getXpathValues(capturedInputAndOutputs, key, xpath); // } // }; // }
import com.googlecode.yatspec.state.givenwhenthen.CapturedInputAndOutputs; import org.jdom.Document; import org.jdom.JDOMException; import org.jdom.input.SAXBuilder; import org.junit.Test; import java.io.IOException; import java.io.StringReader; import java.util.Arrays; import java.util.Collection; import static com.googlecode.yatspec.plugin.jdom.StateExtractors.getXpathValue; import static com.googlecode.yatspec.plugin.jdom.StateExtractors.getXpathValues; import static java.util.Arrays.asList; import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.core.IsCollectionContaining.hasItem;
package com.googlecode.yatspec.plugin.jdom; public class StateExtractorsTest { private static final String NAME = "Fred"; private static final String ANOTHER_NAME = "Joe"; private static final String KEY = "Key"; @Test public void shouldExtractValue() throws Exception { CapturedInputAndOutputs inputAndOutputs = new CapturedInputAndOutputs().add(KEY, NAME); assertThat(StateExtractors.getValue(KEY, String.class).execute(inputAndOutputs), is(NAME)); } @Test public void shouldExtractValues() throws Exception { CapturedInputAndOutputs inputAndOutputs = new CapturedInputAndOutputs().add(KEY, Arrays.asList(NAME, NAME)); assertThat(StateExtractors.<Collection<String>, String>getValues(KEY, String.class).execute(inputAndOutputs), hasItem(NAME)); } @Test public void shouldExtractXpathElement() throws Exception { Document document = document("<People><Person><Name>" + NAME + "</Name></Person></People>"); CapturedInputAndOutputs inputAndOutputs = new CapturedInputAndOutputs().add(KEY, document);
// Path: src/com/googlecode/yatspec/state/givenwhenthen/CapturedInputAndOutputs.java // public class CapturedInputAndOutputs extends NiceMap<CapturedInputAndOutputs>{ // public CapturedInputAndOutputs(Object... instances) { // super(instances); // } // } // // Path: src/com/googlecode/yatspec/plugin/jdom/StateExtractors.java // public static StateExtractor<String> getXpathValue(final String key, final String xpath) { // return new StateExtractor<String>() { // public String execute(CapturedInputAndOutputs capturedInputAndOutputs) throws Exception { // return getXpathValues(capturedInputAndOutputs, key, xpath).get(0); // } // }; // } // // Path: src/com/googlecode/yatspec/plugin/jdom/StateExtractors.java // public static StateExtractor<List<String>> getXpathValues(final String key, final String xpath) { // return new StateExtractor<List<String>>() { // public List<String> execute(CapturedInputAndOutputs capturedInputAndOutputs) throws Exception { // return getXpathValues(capturedInputAndOutputs, key, xpath); // } // }; // } // Path: test/com/googlecode/yatspec/plugin/jdom/StateExtractorsTest.java import com.googlecode.yatspec.state.givenwhenthen.CapturedInputAndOutputs; import org.jdom.Document; import org.jdom.JDOMException; import org.jdom.input.SAXBuilder; import org.junit.Test; import java.io.IOException; import java.io.StringReader; import java.util.Arrays; import java.util.Collection; import static com.googlecode.yatspec.plugin.jdom.StateExtractors.getXpathValue; import static com.googlecode.yatspec.plugin.jdom.StateExtractors.getXpathValues; import static java.util.Arrays.asList; import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.core.IsCollectionContaining.hasItem; package com.googlecode.yatspec.plugin.jdom; public class StateExtractorsTest { private static final String NAME = "Fred"; private static final String ANOTHER_NAME = "Joe"; private static final String KEY = "Key"; @Test public void shouldExtractValue() throws Exception { CapturedInputAndOutputs inputAndOutputs = new CapturedInputAndOutputs().add(KEY, NAME); assertThat(StateExtractors.getValue(KEY, String.class).execute(inputAndOutputs), is(NAME)); } @Test public void shouldExtractValues() throws Exception { CapturedInputAndOutputs inputAndOutputs = new CapturedInputAndOutputs().add(KEY, Arrays.asList(NAME, NAME)); assertThat(StateExtractors.<Collection<String>, String>getValues(KEY, String.class).execute(inputAndOutputs), hasItem(NAME)); } @Test public void shouldExtractXpathElement() throws Exception { Document document = document("<People><Person><Name>" + NAME + "</Name></Person></People>"); CapturedInputAndOutputs inputAndOutputs = new CapturedInputAndOutputs().add(KEY, document);
assertThat(getXpathValue(KEY, "//People/Person/Name").execute(inputAndOutputs), is(NAME));
bodar/yatspec
test/com/googlecode/yatspec/plugin/jdom/StateExtractorsTest.java
// Path: src/com/googlecode/yatspec/state/givenwhenthen/CapturedInputAndOutputs.java // public class CapturedInputAndOutputs extends NiceMap<CapturedInputAndOutputs>{ // public CapturedInputAndOutputs(Object... instances) { // super(instances); // } // } // // Path: src/com/googlecode/yatspec/plugin/jdom/StateExtractors.java // public static StateExtractor<String> getXpathValue(final String key, final String xpath) { // return new StateExtractor<String>() { // public String execute(CapturedInputAndOutputs capturedInputAndOutputs) throws Exception { // return getXpathValues(capturedInputAndOutputs, key, xpath).get(0); // } // }; // } // // Path: src/com/googlecode/yatspec/plugin/jdom/StateExtractors.java // public static StateExtractor<List<String>> getXpathValues(final String key, final String xpath) { // return new StateExtractor<List<String>>() { // public List<String> execute(CapturedInputAndOutputs capturedInputAndOutputs) throws Exception { // return getXpathValues(capturedInputAndOutputs, key, xpath); // } // }; // }
import com.googlecode.yatspec.state.givenwhenthen.CapturedInputAndOutputs; import org.jdom.Document; import org.jdom.JDOMException; import org.jdom.input.SAXBuilder; import org.junit.Test; import java.io.IOException; import java.io.StringReader; import java.util.Arrays; import java.util.Collection; import static com.googlecode.yatspec.plugin.jdom.StateExtractors.getXpathValue; import static com.googlecode.yatspec.plugin.jdom.StateExtractors.getXpathValues; import static java.util.Arrays.asList; import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.core.IsCollectionContaining.hasItem;
package com.googlecode.yatspec.plugin.jdom; public class StateExtractorsTest { private static final String NAME = "Fred"; private static final String ANOTHER_NAME = "Joe"; private static final String KEY = "Key"; @Test public void shouldExtractValue() throws Exception { CapturedInputAndOutputs inputAndOutputs = new CapturedInputAndOutputs().add(KEY, NAME); assertThat(StateExtractors.getValue(KEY, String.class).execute(inputAndOutputs), is(NAME)); } @Test public void shouldExtractValues() throws Exception { CapturedInputAndOutputs inputAndOutputs = new CapturedInputAndOutputs().add(KEY, Arrays.asList(NAME, NAME)); assertThat(StateExtractors.<Collection<String>, String>getValues(KEY, String.class).execute(inputAndOutputs), hasItem(NAME)); } @Test public void shouldExtractXpathElement() throws Exception { Document document = document("<People><Person><Name>" + NAME + "</Name></Person></People>"); CapturedInputAndOutputs inputAndOutputs = new CapturedInputAndOutputs().add(KEY, document); assertThat(getXpathValue(KEY, "//People/Person/Name").execute(inputAndOutputs), is(NAME)); } @Test public void shouldExtractMultipleSiblingXPathElements() throws Exception { Document document = document("<People><Person>"+"<Name>" + NAME + "</Name>"+"<Name>" + ANOTHER_NAME + "</Name>"+"</Person></People>"); CapturedInputAndOutputs inputAndOutputs = new CapturedInputAndOutputs().add(KEY, document);
// Path: src/com/googlecode/yatspec/state/givenwhenthen/CapturedInputAndOutputs.java // public class CapturedInputAndOutputs extends NiceMap<CapturedInputAndOutputs>{ // public CapturedInputAndOutputs(Object... instances) { // super(instances); // } // } // // Path: src/com/googlecode/yatspec/plugin/jdom/StateExtractors.java // public static StateExtractor<String> getXpathValue(final String key, final String xpath) { // return new StateExtractor<String>() { // public String execute(CapturedInputAndOutputs capturedInputAndOutputs) throws Exception { // return getXpathValues(capturedInputAndOutputs, key, xpath).get(0); // } // }; // } // // Path: src/com/googlecode/yatspec/plugin/jdom/StateExtractors.java // public static StateExtractor<List<String>> getXpathValues(final String key, final String xpath) { // return new StateExtractor<List<String>>() { // public List<String> execute(CapturedInputAndOutputs capturedInputAndOutputs) throws Exception { // return getXpathValues(capturedInputAndOutputs, key, xpath); // } // }; // } // Path: test/com/googlecode/yatspec/plugin/jdom/StateExtractorsTest.java import com.googlecode.yatspec.state.givenwhenthen.CapturedInputAndOutputs; import org.jdom.Document; import org.jdom.JDOMException; import org.jdom.input.SAXBuilder; import org.junit.Test; import java.io.IOException; import java.io.StringReader; import java.util.Arrays; import java.util.Collection; import static com.googlecode.yatspec.plugin.jdom.StateExtractors.getXpathValue; import static com.googlecode.yatspec.plugin.jdom.StateExtractors.getXpathValues; import static java.util.Arrays.asList; import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.core.IsCollectionContaining.hasItem; package com.googlecode.yatspec.plugin.jdom; public class StateExtractorsTest { private static final String NAME = "Fred"; private static final String ANOTHER_NAME = "Joe"; private static final String KEY = "Key"; @Test public void shouldExtractValue() throws Exception { CapturedInputAndOutputs inputAndOutputs = new CapturedInputAndOutputs().add(KEY, NAME); assertThat(StateExtractors.getValue(KEY, String.class).execute(inputAndOutputs), is(NAME)); } @Test public void shouldExtractValues() throws Exception { CapturedInputAndOutputs inputAndOutputs = new CapturedInputAndOutputs().add(KEY, Arrays.asList(NAME, NAME)); assertThat(StateExtractors.<Collection<String>, String>getValues(KEY, String.class).execute(inputAndOutputs), hasItem(NAME)); } @Test public void shouldExtractXpathElement() throws Exception { Document document = document("<People><Person><Name>" + NAME + "</Name></Person></People>"); CapturedInputAndOutputs inputAndOutputs = new CapturedInputAndOutputs().add(KEY, document); assertThat(getXpathValue(KEY, "//People/Person/Name").execute(inputAndOutputs), is(NAME)); } @Test public void shouldExtractMultipleSiblingXPathElements() throws Exception { Document document = document("<People><Person>"+"<Name>" + NAME + "</Name>"+"<Name>" + ANOTHER_NAME + "</Name>"+"</Person></People>"); CapturedInputAndOutputs inputAndOutputs = new CapturedInputAndOutputs().add(KEY, document);
assertThat(StateExtractors.getXpathValues(KEY, "//People/Person/Name").execute(inputAndOutputs), is(asList(NAME, ANOTHER_NAME)));
bodar/yatspec
test/com/googlecode/yatspec/junit/DecoratingFrameworkMethodTest.java
// Path: src/com/googlecode/yatspec/rendering/junit/HumanReadableScenarioNameRenderer.java // public class HumanReadableScenarioNameRenderer implements ScenarioNameRenderer { // // @Override // public String render(ScenarioName scenarioName) { // return scenarioName.getMethodName() + "(" + sequence(scenarioName.getRow()).toString(", ") + ")"; // } // } // // Path: src/com/googlecode/yatspec/rendering/junit/MavenSurefireScenarioNameRenderer.java // public class MavenSurefireScenarioNameRenderer implements ScenarioNameRenderer { // // @Override // public String render(ScenarioName scenarioName) { // if (scenarioName.hasEmptyRow()) { // return scenarioName.getMethodName(); // } // // return scenarioName.getMethodName() + "__" + sequence(scenarioName.getRow()).toString("_"); // } // } // // Path: src/com/googlecode/yatspec/state/ScenarioName.java // public class ScenarioName { // private final String methodName; // private final List<String> row; // // public ScenarioName(String methodName, List<String> row) { // this.methodName = methodName; // this.row = row; // } // // public String getMethodName() { // return methodName; // } // // public List<String> getRow() { // return row; // } // // public boolean hasEmptyRow() { // return getRow().isEmpty(); // } // } // // Path: test/com/googlecode/yatspec/fixture/RandomFixtures.java // public static String anyString() { // return anyStringOfLength(anyNumberBetween(8, 12)); // } // // Path: test/com/googlecode/yatspec/fixture/RandomFixtures.java // public static <T> T pickOneOf(T... choices) { // return choices[random.nextInt(choices.length)]; // } // // Path: src/com/googlecode/yatspec/rendering/ScenarioNameRendererFactory.java // public static final String SCENARIO_NAME_RENDERER = "yatspec.scenario.name.renderer";
import com.googlecode.yatspec.rendering.junit.HumanReadableScenarioNameRenderer; import com.googlecode.yatspec.rendering.junit.MavenSurefireScenarioNameRenderer; import com.googlecode.yatspec.state.ScenarioName; import org.junit.After; import org.junit.Before; import org.junit.Test; import org.junit.runners.model.FrameworkMethod; import java.lang.annotation.Annotation; import java.lang.reflect.Method; import java.util.List; import static com.googlecode.yatspec.fixture.RandomFixtures.anyString; import static com.googlecode.yatspec.fixture.RandomFixtures.pickOneOf; import static com.googlecode.yatspec.rendering.ScenarioNameRendererFactory.SCENARIO_NAME_RENDERER; import static java.util.Arrays.asList; import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.MatcherAssert.assertThat;
package com.googlecode.yatspec.junit; public class DecoratingFrameworkMethodTest { private static final String MAVEN_SCENARIO_NAME_RENDERER = MavenSurefireScenarioNameRenderer.class.getName(); private String originalScenarioNameRenderer; private List<String> args; private String methodName; private DecoratingFrameworkMethod decoratingFrameworkMethod; private Method method; @Before public void setUp() throws Exception {
// Path: src/com/googlecode/yatspec/rendering/junit/HumanReadableScenarioNameRenderer.java // public class HumanReadableScenarioNameRenderer implements ScenarioNameRenderer { // // @Override // public String render(ScenarioName scenarioName) { // return scenarioName.getMethodName() + "(" + sequence(scenarioName.getRow()).toString(", ") + ")"; // } // } // // Path: src/com/googlecode/yatspec/rendering/junit/MavenSurefireScenarioNameRenderer.java // public class MavenSurefireScenarioNameRenderer implements ScenarioNameRenderer { // // @Override // public String render(ScenarioName scenarioName) { // if (scenarioName.hasEmptyRow()) { // return scenarioName.getMethodName(); // } // // return scenarioName.getMethodName() + "__" + sequence(scenarioName.getRow()).toString("_"); // } // } // // Path: src/com/googlecode/yatspec/state/ScenarioName.java // public class ScenarioName { // private final String methodName; // private final List<String> row; // // public ScenarioName(String methodName, List<String> row) { // this.methodName = methodName; // this.row = row; // } // // public String getMethodName() { // return methodName; // } // // public List<String> getRow() { // return row; // } // // public boolean hasEmptyRow() { // return getRow().isEmpty(); // } // } // // Path: test/com/googlecode/yatspec/fixture/RandomFixtures.java // public static String anyString() { // return anyStringOfLength(anyNumberBetween(8, 12)); // } // // Path: test/com/googlecode/yatspec/fixture/RandomFixtures.java // public static <T> T pickOneOf(T... choices) { // return choices[random.nextInt(choices.length)]; // } // // Path: src/com/googlecode/yatspec/rendering/ScenarioNameRendererFactory.java // public static final String SCENARIO_NAME_RENDERER = "yatspec.scenario.name.renderer"; // Path: test/com/googlecode/yatspec/junit/DecoratingFrameworkMethodTest.java import com.googlecode.yatspec.rendering.junit.HumanReadableScenarioNameRenderer; import com.googlecode.yatspec.rendering.junit.MavenSurefireScenarioNameRenderer; import com.googlecode.yatspec.state.ScenarioName; import org.junit.After; import org.junit.Before; import org.junit.Test; import org.junit.runners.model.FrameworkMethod; import java.lang.annotation.Annotation; import java.lang.reflect.Method; import java.util.List; import static com.googlecode.yatspec.fixture.RandomFixtures.anyString; import static com.googlecode.yatspec.fixture.RandomFixtures.pickOneOf; import static com.googlecode.yatspec.rendering.ScenarioNameRendererFactory.SCENARIO_NAME_RENDERER; import static java.util.Arrays.asList; import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.MatcherAssert.assertThat; package com.googlecode.yatspec.junit; public class DecoratingFrameworkMethodTest { private static final String MAVEN_SCENARIO_NAME_RENDERER = MavenSurefireScenarioNameRenderer.class.getName(); private String originalScenarioNameRenderer; private List<String> args; private String methodName; private DecoratingFrameworkMethod decoratingFrameworkMethod; private Method method; @Before public void setUp() throws Exception {
originalScenarioNameRenderer = System.getProperty(SCENARIO_NAME_RENDERER);
bodar/yatspec
test/com/googlecode/yatspec/junit/DecoratingFrameworkMethodTest.java
// Path: src/com/googlecode/yatspec/rendering/junit/HumanReadableScenarioNameRenderer.java // public class HumanReadableScenarioNameRenderer implements ScenarioNameRenderer { // // @Override // public String render(ScenarioName scenarioName) { // return scenarioName.getMethodName() + "(" + sequence(scenarioName.getRow()).toString(", ") + ")"; // } // } // // Path: src/com/googlecode/yatspec/rendering/junit/MavenSurefireScenarioNameRenderer.java // public class MavenSurefireScenarioNameRenderer implements ScenarioNameRenderer { // // @Override // public String render(ScenarioName scenarioName) { // if (scenarioName.hasEmptyRow()) { // return scenarioName.getMethodName(); // } // // return scenarioName.getMethodName() + "__" + sequence(scenarioName.getRow()).toString("_"); // } // } // // Path: src/com/googlecode/yatspec/state/ScenarioName.java // public class ScenarioName { // private final String methodName; // private final List<String> row; // // public ScenarioName(String methodName, List<String> row) { // this.methodName = methodName; // this.row = row; // } // // public String getMethodName() { // return methodName; // } // // public List<String> getRow() { // return row; // } // // public boolean hasEmptyRow() { // return getRow().isEmpty(); // } // } // // Path: test/com/googlecode/yatspec/fixture/RandomFixtures.java // public static String anyString() { // return anyStringOfLength(anyNumberBetween(8, 12)); // } // // Path: test/com/googlecode/yatspec/fixture/RandomFixtures.java // public static <T> T pickOneOf(T... choices) { // return choices[random.nextInt(choices.length)]; // } // // Path: src/com/googlecode/yatspec/rendering/ScenarioNameRendererFactory.java // public static final String SCENARIO_NAME_RENDERER = "yatspec.scenario.name.renderer";
import com.googlecode.yatspec.rendering.junit.HumanReadableScenarioNameRenderer; import com.googlecode.yatspec.rendering.junit.MavenSurefireScenarioNameRenderer; import com.googlecode.yatspec.state.ScenarioName; import org.junit.After; import org.junit.Before; import org.junit.Test; import org.junit.runners.model.FrameworkMethod; import java.lang.annotation.Annotation; import java.lang.reflect.Method; import java.util.List; import static com.googlecode.yatspec.fixture.RandomFixtures.anyString; import static com.googlecode.yatspec.fixture.RandomFixtures.pickOneOf; import static com.googlecode.yatspec.rendering.ScenarioNameRendererFactory.SCENARIO_NAME_RENDERER; import static java.util.Arrays.asList; import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.MatcherAssert.assertThat;
package com.googlecode.yatspec.junit; public class DecoratingFrameworkMethodTest { private static final String MAVEN_SCENARIO_NAME_RENDERER = MavenSurefireScenarioNameRenderer.class.getName(); private String originalScenarioNameRenderer; private List<String> args; private String methodName; private DecoratingFrameworkMethod decoratingFrameworkMethod; private Method method; @Before public void setUp() throws Exception { originalScenarioNameRenderer = System.getProperty(SCENARIO_NAME_RENDERER);
// Path: src/com/googlecode/yatspec/rendering/junit/HumanReadableScenarioNameRenderer.java // public class HumanReadableScenarioNameRenderer implements ScenarioNameRenderer { // // @Override // public String render(ScenarioName scenarioName) { // return scenarioName.getMethodName() + "(" + sequence(scenarioName.getRow()).toString(", ") + ")"; // } // } // // Path: src/com/googlecode/yatspec/rendering/junit/MavenSurefireScenarioNameRenderer.java // public class MavenSurefireScenarioNameRenderer implements ScenarioNameRenderer { // // @Override // public String render(ScenarioName scenarioName) { // if (scenarioName.hasEmptyRow()) { // return scenarioName.getMethodName(); // } // // return scenarioName.getMethodName() + "__" + sequence(scenarioName.getRow()).toString("_"); // } // } // // Path: src/com/googlecode/yatspec/state/ScenarioName.java // public class ScenarioName { // private final String methodName; // private final List<String> row; // // public ScenarioName(String methodName, List<String> row) { // this.methodName = methodName; // this.row = row; // } // // public String getMethodName() { // return methodName; // } // // public List<String> getRow() { // return row; // } // // public boolean hasEmptyRow() { // return getRow().isEmpty(); // } // } // // Path: test/com/googlecode/yatspec/fixture/RandomFixtures.java // public static String anyString() { // return anyStringOfLength(anyNumberBetween(8, 12)); // } // // Path: test/com/googlecode/yatspec/fixture/RandomFixtures.java // public static <T> T pickOneOf(T... choices) { // return choices[random.nextInt(choices.length)]; // } // // Path: src/com/googlecode/yatspec/rendering/ScenarioNameRendererFactory.java // public static final String SCENARIO_NAME_RENDERER = "yatspec.scenario.name.renderer"; // Path: test/com/googlecode/yatspec/junit/DecoratingFrameworkMethodTest.java import com.googlecode.yatspec.rendering.junit.HumanReadableScenarioNameRenderer; import com.googlecode.yatspec.rendering.junit.MavenSurefireScenarioNameRenderer; import com.googlecode.yatspec.state.ScenarioName; import org.junit.After; import org.junit.Before; import org.junit.Test; import org.junit.runners.model.FrameworkMethod; import java.lang.annotation.Annotation; import java.lang.reflect.Method; import java.util.List; import static com.googlecode.yatspec.fixture.RandomFixtures.anyString; import static com.googlecode.yatspec.fixture.RandomFixtures.pickOneOf; import static com.googlecode.yatspec.rendering.ScenarioNameRendererFactory.SCENARIO_NAME_RENDERER; import static java.util.Arrays.asList; import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.MatcherAssert.assertThat; package com.googlecode.yatspec.junit; public class DecoratingFrameworkMethodTest { private static final String MAVEN_SCENARIO_NAME_RENDERER = MavenSurefireScenarioNameRenderer.class.getName(); private String originalScenarioNameRenderer; private List<String> args; private String methodName; private DecoratingFrameworkMethod decoratingFrameworkMethod; private Method method; @Before public void setUp() throws Exception { originalScenarioNameRenderer = System.getProperty(SCENARIO_NAME_RENDERER);
args = asList(anyString(),anyString());
bodar/yatspec
test/com/googlecode/yatspec/junit/DecoratingFrameworkMethodTest.java
// Path: src/com/googlecode/yatspec/rendering/junit/HumanReadableScenarioNameRenderer.java // public class HumanReadableScenarioNameRenderer implements ScenarioNameRenderer { // // @Override // public String render(ScenarioName scenarioName) { // return scenarioName.getMethodName() + "(" + sequence(scenarioName.getRow()).toString(", ") + ")"; // } // } // // Path: src/com/googlecode/yatspec/rendering/junit/MavenSurefireScenarioNameRenderer.java // public class MavenSurefireScenarioNameRenderer implements ScenarioNameRenderer { // // @Override // public String render(ScenarioName scenarioName) { // if (scenarioName.hasEmptyRow()) { // return scenarioName.getMethodName(); // } // // return scenarioName.getMethodName() + "__" + sequence(scenarioName.getRow()).toString("_"); // } // } // // Path: src/com/googlecode/yatspec/state/ScenarioName.java // public class ScenarioName { // private final String methodName; // private final List<String> row; // // public ScenarioName(String methodName, List<String> row) { // this.methodName = methodName; // this.row = row; // } // // public String getMethodName() { // return methodName; // } // // public List<String> getRow() { // return row; // } // // public boolean hasEmptyRow() { // return getRow().isEmpty(); // } // } // // Path: test/com/googlecode/yatspec/fixture/RandomFixtures.java // public static String anyString() { // return anyStringOfLength(anyNumberBetween(8, 12)); // } // // Path: test/com/googlecode/yatspec/fixture/RandomFixtures.java // public static <T> T pickOneOf(T... choices) { // return choices[random.nextInt(choices.length)]; // } // // Path: src/com/googlecode/yatspec/rendering/ScenarioNameRendererFactory.java // public static final String SCENARIO_NAME_RENDERER = "yatspec.scenario.name.renderer";
import com.googlecode.yatspec.rendering.junit.HumanReadableScenarioNameRenderer; import com.googlecode.yatspec.rendering.junit.MavenSurefireScenarioNameRenderer; import com.googlecode.yatspec.state.ScenarioName; import org.junit.After; import org.junit.Before; import org.junit.Test; import org.junit.runners.model.FrameworkMethod; import java.lang.annotation.Annotation; import java.lang.reflect.Method; import java.util.List; import static com.googlecode.yatspec.fixture.RandomFixtures.anyString; import static com.googlecode.yatspec.fixture.RandomFixtures.pickOneOf; import static com.googlecode.yatspec.rendering.ScenarioNameRendererFactory.SCENARIO_NAME_RENDERER; import static java.util.Arrays.asList; import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.MatcherAssert.assertThat;
package com.googlecode.yatspec.junit; public class DecoratingFrameworkMethodTest { private static final String MAVEN_SCENARIO_NAME_RENDERER = MavenSurefireScenarioNameRenderer.class.getName(); private String originalScenarioNameRenderer; private List<String> args; private String methodName; private DecoratingFrameworkMethod decoratingFrameworkMethod; private Method method; @Before public void setUp() throws Exception { originalScenarioNameRenderer = System.getProperty(SCENARIO_NAME_RENDERER); args = asList(anyString(),anyString()); method = method(); methodName = method.getName(); decoratingFrameworkMethod = new DecoratingFrameworkMethod(frameworkMethod(), row(args)); } @After public void tearDown() throws Exception { if (null != originalScenarioNameRenderer) { System.setProperty(SCENARIO_NAME_RENDERER, originalScenarioNameRenderer); } else { System.clearProperty(SCENARIO_NAME_RENDERER); } } @Test public void getsNameUsingDefaultRenderer() throws Exception { System.clearProperty(SCENARIO_NAME_RENDERER);
// Path: src/com/googlecode/yatspec/rendering/junit/HumanReadableScenarioNameRenderer.java // public class HumanReadableScenarioNameRenderer implements ScenarioNameRenderer { // // @Override // public String render(ScenarioName scenarioName) { // return scenarioName.getMethodName() + "(" + sequence(scenarioName.getRow()).toString(", ") + ")"; // } // } // // Path: src/com/googlecode/yatspec/rendering/junit/MavenSurefireScenarioNameRenderer.java // public class MavenSurefireScenarioNameRenderer implements ScenarioNameRenderer { // // @Override // public String render(ScenarioName scenarioName) { // if (scenarioName.hasEmptyRow()) { // return scenarioName.getMethodName(); // } // // return scenarioName.getMethodName() + "__" + sequence(scenarioName.getRow()).toString("_"); // } // } // // Path: src/com/googlecode/yatspec/state/ScenarioName.java // public class ScenarioName { // private final String methodName; // private final List<String> row; // // public ScenarioName(String methodName, List<String> row) { // this.methodName = methodName; // this.row = row; // } // // public String getMethodName() { // return methodName; // } // // public List<String> getRow() { // return row; // } // // public boolean hasEmptyRow() { // return getRow().isEmpty(); // } // } // // Path: test/com/googlecode/yatspec/fixture/RandomFixtures.java // public static String anyString() { // return anyStringOfLength(anyNumberBetween(8, 12)); // } // // Path: test/com/googlecode/yatspec/fixture/RandomFixtures.java // public static <T> T pickOneOf(T... choices) { // return choices[random.nextInt(choices.length)]; // } // // Path: src/com/googlecode/yatspec/rendering/ScenarioNameRendererFactory.java // public static final String SCENARIO_NAME_RENDERER = "yatspec.scenario.name.renderer"; // Path: test/com/googlecode/yatspec/junit/DecoratingFrameworkMethodTest.java import com.googlecode.yatspec.rendering.junit.HumanReadableScenarioNameRenderer; import com.googlecode.yatspec.rendering.junit.MavenSurefireScenarioNameRenderer; import com.googlecode.yatspec.state.ScenarioName; import org.junit.After; import org.junit.Before; import org.junit.Test; import org.junit.runners.model.FrameworkMethod; import java.lang.annotation.Annotation; import java.lang.reflect.Method; import java.util.List; import static com.googlecode.yatspec.fixture.RandomFixtures.anyString; import static com.googlecode.yatspec.fixture.RandomFixtures.pickOneOf; import static com.googlecode.yatspec.rendering.ScenarioNameRendererFactory.SCENARIO_NAME_RENDERER; import static java.util.Arrays.asList; import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.MatcherAssert.assertThat; package com.googlecode.yatspec.junit; public class DecoratingFrameworkMethodTest { private static final String MAVEN_SCENARIO_NAME_RENDERER = MavenSurefireScenarioNameRenderer.class.getName(); private String originalScenarioNameRenderer; private List<String> args; private String methodName; private DecoratingFrameworkMethod decoratingFrameworkMethod; private Method method; @Before public void setUp() throws Exception { originalScenarioNameRenderer = System.getProperty(SCENARIO_NAME_RENDERER); args = asList(anyString(),anyString()); method = method(); methodName = method.getName(); decoratingFrameworkMethod = new DecoratingFrameworkMethod(frameworkMethod(), row(args)); } @After public void tearDown() throws Exception { if (null != originalScenarioNameRenderer) { System.setProperty(SCENARIO_NAME_RENDERER, originalScenarioNameRenderer); } else { System.clearProperty(SCENARIO_NAME_RENDERER); } } @Test public void getsNameUsingDefaultRenderer() throws Exception { System.clearProperty(SCENARIO_NAME_RENDERER);
String expectedName = new HumanReadableScenarioNameRenderer().render(new ScenarioName(methodName, args));
bodar/yatspec
test/com/googlecode/yatspec/junit/DecoratingFrameworkMethodTest.java
// Path: src/com/googlecode/yatspec/rendering/junit/HumanReadableScenarioNameRenderer.java // public class HumanReadableScenarioNameRenderer implements ScenarioNameRenderer { // // @Override // public String render(ScenarioName scenarioName) { // return scenarioName.getMethodName() + "(" + sequence(scenarioName.getRow()).toString(", ") + ")"; // } // } // // Path: src/com/googlecode/yatspec/rendering/junit/MavenSurefireScenarioNameRenderer.java // public class MavenSurefireScenarioNameRenderer implements ScenarioNameRenderer { // // @Override // public String render(ScenarioName scenarioName) { // if (scenarioName.hasEmptyRow()) { // return scenarioName.getMethodName(); // } // // return scenarioName.getMethodName() + "__" + sequence(scenarioName.getRow()).toString("_"); // } // } // // Path: src/com/googlecode/yatspec/state/ScenarioName.java // public class ScenarioName { // private final String methodName; // private final List<String> row; // // public ScenarioName(String methodName, List<String> row) { // this.methodName = methodName; // this.row = row; // } // // public String getMethodName() { // return methodName; // } // // public List<String> getRow() { // return row; // } // // public boolean hasEmptyRow() { // return getRow().isEmpty(); // } // } // // Path: test/com/googlecode/yatspec/fixture/RandomFixtures.java // public static String anyString() { // return anyStringOfLength(anyNumberBetween(8, 12)); // } // // Path: test/com/googlecode/yatspec/fixture/RandomFixtures.java // public static <T> T pickOneOf(T... choices) { // return choices[random.nextInt(choices.length)]; // } // // Path: src/com/googlecode/yatspec/rendering/ScenarioNameRendererFactory.java // public static final String SCENARIO_NAME_RENDERER = "yatspec.scenario.name.renderer";
import com.googlecode.yatspec.rendering.junit.HumanReadableScenarioNameRenderer; import com.googlecode.yatspec.rendering.junit.MavenSurefireScenarioNameRenderer; import com.googlecode.yatspec.state.ScenarioName; import org.junit.After; import org.junit.Before; import org.junit.Test; import org.junit.runners.model.FrameworkMethod; import java.lang.annotation.Annotation; import java.lang.reflect.Method; import java.util.List; import static com.googlecode.yatspec.fixture.RandomFixtures.anyString; import static com.googlecode.yatspec.fixture.RandomFixtures.pickOneOf; import static com.googlecode.yatspec.rendering.ScenarioNameRendererFactory.SCENARIO_NAME_RENDERER; import static java.util.Arrays.asList; import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.MatcherAssert.assertThat;
package com.googlecode.yatspec.junit; public class DecoratingFrameworkMethodTest { private static final String MAVEN_SCENARIO_NAME_RENDERER = MavenSurefireScenarioNameRenderer.class.getName(); private String originalScenarioNameRenderer; private List<String> args; private String methodName; private DecoratingFrameworkMethod decoratingFrameworkMethod; private Method method; @Before public void setUp() throws Exception { originalScenarioNameRenderer = System.getProperty(SCENARIO_NAME_RENDERER); args = asList(anyString(),anyString()); method = method(); methodName = method.getName(); decoratingFrameworkMethod = new DecoratingFrameworkMethod(frameworkMethod(), row(args)); } @After public void tearDown() throws Exception { if (null != originalScenarioNameRenderer) { System.setProperty(SCENARIO_NAME_RENDERER, originalScenarioNameRenderer); } else { System.clearProperty(SCENARIO_NAME_RENDERER); } } @Test public void getsNameUsingDefaultRenderer() throws Exception { System.clearProperty(SCENARIO_NAME_RENDERER);
// Path: src/com/googlecode/yatspec/rendering/junit/HumanReadableScenarioNameRenderer.java // public class HumanReadableScenarioNameRenderer implements ScenarioNameRenderer { // // @Override // public String render(ScenarioName scenarioName) { // return scenarioName.getMethodName() + "(" + sequence(scenarioName.getRow()).toString(", ") + ")"; // } // } // // Path: src/com/googlecode/yatspec/rendering/junit/MavenSurefireScenarioNameRenderer.java // public class MavenSurefireScenarioNameRenderer implements ScenarioNameRenderer { // // @Override // public String render(ScenarioName scenarioName) { // if (scenarioName.hasEmptyRow()) { // return scenarioName.getMethodName(); // } // // return scenarioName.getMethodName() + "__" + sequence(scenarioName.getRow()).toString("_"); // } // } // // Path: src/com/googlecode/yatspec/state/ScenarioName.java // public class ScenarioName { // private final String methodName; // private final List<String> row; // // public ScenarioName(String methodName, List<String> row) { // this.methodName = methodName; // this.row = row; // } // // public String getMethodName() { // return methodName; // } // // public List<String> getRow() { // return row; // } // // public boolean hasEmptyRow() { // return getRow().isEmpty(); // } // } // // Path: test/com/googlecode/yatspec/fixture/RandomFixtures.java // public static String anyString() { // return anyStringOfLength(anyNumberBetween(8, 12)); // } // // Path: test/com/googlecode/yatspec/fixture/RandomFixtures.java // public static <T> T pickOneOf(T... choices) { // return choices[random.nextInt(choices.length)]; // } // // Path: src/com/googlecode/yatspec/rendering/ScenarioNameRendererFactory.java // public static final String SCENARIO_NAME_RENDERER = "yatspec.scenario.name.renderer"; // Path: test/com/googlecode/yatspec/junit/DecoratingFrameworkMethodTest.java import com.googlecode.yatspec.rendering.junit.HumanReadableScenarioNameRenderer; import com.googlecode.yatspec.rendering.junit.MavenSurefireScenarioNameRenderer; import com.googlecode.yatspec.state.ScenarioName; import org.junit.After; import org.junit.Before; import org.junit.Test; import org.junit.runners.model.FrameworkMethod; import java.lang.annotation.Annotation; import java.lang.reflect.Method; import java.util.List; import static com.googlecode.yatspec.fixture.RandomFixtures.anyString; import static com.googlecode.yatspec.fixture.RandomFixtures.pickOneOf; import static com.googlecode.yatspec.rendering.ScenarioNameRendererFactory.SCENARIO_NAME_RENDERER; import static java.util.Arrays.asList; import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.MatcherAssert.assertThat; package com.googlecode.yatspec.junit; public class DecoratingFrameworkMethodTest { private static final String MAVEN_SCENARIO_NAME_RENDERER = MavenSurefireScenarioNameRenderer.class.getName(); private String originalScenarioNameRenderer; private List<String> args; private String methodName; private DecoratingFrameworkMethod decoratingFrameworkMethod; private Method method; @Before public void setUp() throws Exception { originalScenarioNameRenderer = System.getProperty(SCENARIO_NAME_RENDERER); args = asList(anyString(),anyString()); method = method(); methodName = method.getName(); decoratingFrameworkMethod = new DecoratingFrameworkMethod(frameworkMethod(), row(args)); } @After public void tearDown() throws Exception { if (null != originalScenarioNameRenderer) { System.setProperty(SCENARIO_NAME_RENDERER, originalScenarioNameRenderer); } else { System.clearProperty(SCENARIO_NAME_RENDERER); } } @Test public void getsNameUsingDefaultRenderer() throws Exception { System.clearProperty(SCENARIO_NAME_RENDERER);
String expectedName = new HumanReadableScenarioNameRenderer().render(new ScenarioName(methodName, args));
bodar/yatspec
test/com/googlecode/yatspec/junit/DecoratingFrameworkMethodTest.java
// Path: src/com/googlecode/yatspec/rendering/junit/HumanReadableScenarioNameRenderer.java // public class HumanReadableScenarioNameRenderer implements ScenarioNameRenderer { // // @Override // public String render(ScenarioName scenarioName) { // return scenarioName.getMethodName() + "(" + sequence(scenarioName.getRow()).toString(", ") + ")"; // } // } // // Path: src/com/googlecode/yatspec/rendering/junit/MavenSurefireScenarioNameRenderer.java // public class MavenSurefireScenarioNameRenderer implements ScenarioNameRenderer { // // @Override // public String render(ScenarioName scenarioName) { // if (scenarioName.hasEmptyRow()) { // return scenarioName.getMethodName(); // } // // return scenarioName.getMethodName() + "__" + sequence(scenarioName.getRow()).toString("_"); // } // } // // Path: src/com/googlecode/yatspec/state/ScenarioName.java // public class ScenarioName { // private final String methodName; // private final List<String> row; // // public ScenarioName(String methodName, List<String> row) { // this.methodName = methodName; // this.row = row; // } // // public String getMethodName() { // return methodName; // } // // public List<String> getRow() { // return row; // } // // public boolean hasEmptyRow() { // return getRow().isEmpty(); // } // } // // Path: test/com/googlecode/yatspec/fixture/RandomFixtures.java // public static String anyString() { // return anyStringOfLength(anyNumberBetween(8, 12)); // } // // Path: test/com/googlecode/yatspec/fixture/RandomFixtures.java // public static <T> T pickOneOf(T... choices) { // return choices[random.nextInt(choices.length)]; // } // // Path: src/com/googlecode/yatspec/rendering/ScenarioNameRendererFactory.java // public static final String SCENARIO_NAME_RENDERER = "yatspec.scenario.name.renderer";
import com.googlecode.yatspec.rendering.junit.HumanReadableScenarioNameRenderer; import com.googlecode.yatspec.rendering.junit.MavenSurefireScenarioNameRenderer; import com.googlecode.yatspec.state.ScenarioName; import org.junit.After; import org.junit.Before; import org.junit.Test; import org.junit.runners.model.FrameworkMethod; import java.lang.annotation.Annotation; import java.lang.reflect.Method; import java.util.List; import static com.googlecode.yatspec.fixture.RandomFixtures.anyString; import static com.googlecode.yatspec.fixture.RandomFixtures.pickOneOf; import static com.googlecode.yatspec.rendering.ScenarioNameRendererFactory.SCENARIO_NAME_RENDERER; import static java.util.Arrays.asList; import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.MatcherAssert.assertThat;
@After public void tearDown() throws Exception { if (null != originalScenarioNameRenderer) { System.setProperty(SCENARIO_NAME_RENDERER, originalScenarioNameRenderer); } else { System.clearProperty(SCENARIO_NAME_RENDERER); } } @Test public void getsNameUsingDefaultRenderer() throws Exception { System.clearProperty(SCENARIO_NAME_RENDERER); String expectedName = new HumanReadableScenarioNameRenderer().render(new ScenarioName(methodName, args)); String actualName = decoratingFrameworkMethod.getName(); assertThat(actualName, is(expectedName)); } @Test public void getsNameUsingRenderSpecifiedBySystemProperty() throws Exception { System.setProperty(SCENARIO_NAME_RENDERER, MAVEN_SCENARIO_NAME_RENDERER); String expectedName = new MavenSurefireScenarioNameRenderer().render(new ScenarioName(methodName, args)); String actualName = decoratingFrameworkMethod.getName(); assertThat(actualName, is(expectedName)); } private Method method() throws NoSuchMethodException {
// Path: src/com/googlecode/yatspec/rendering/junit/HumanReadableScenarioNameRenderer.java // public class HumanReadableScenarioNameRenderer implements ScenarioNameRenderer { // // @Override // public String render(ScenarioName scenarioName) { // return scenarioName.getMethodName() + "(" + sequence(scenarioName.getRow()).toString(", ") + ")"; // } // } // // Path: src/com/googlecode/yatspec/rendering/junit/MavenSurefireScenarioNameRenderer.java // public class MavenSurefireScenarioNameRenderer implements ScenarioNameRenderer { // // @Override // public String render(ScenarioName scenarioName) { // if (scenarioName.hasEmptyRow()) { // return scenarioName.getMethodName(); // } // // return scenarioName.getMethodName() + "__" + sequence(scenarioName.getRow()).toString("_"); // } // } // // Path: src/com/googlecode/yatspec/state/ScenarioName.java // public class ScenarioName { // private final String methodName; // private final List<String> row; // // public ScenarioName(String methodName, List<String> row) { // this.methodName = methodName; // this.row = row; // } // // public String getMethodName() { // return methodName; // } // // public List<String> getRow() { // return row; // } // // public boolean hasEmptyRow() { // return getRow().isEmpty(); // } // } // // Path: test/com/googlecode/yatspec/fixture/RandomFixtures.java // public static String anyString() { // return anyStringOfLength(anyNumberBetween(8, 12)); // } // // Path: test/com/googlecode/yatspec/fixture/RandomFixtures.java // public static <T> T pickOneOf(T... choices) { // return choices[random.nextInt(choices.length)]; // } // // Path: src/com/googlecode/yatspec/rendering/ScenarioNameRendererFactory.java // public static final String SCENARIO_NAME_RENDERER = "yatspec.scenario.name.renderer"; // Path: test/com/googlecode/yatspec/junit/DecoratingFrameworkMethodTest.java import com.googlecode.yatspec.rendering.junit.HumanReadableScenarioNameRenderer; import com.googlecode.yatspec.rendering.junit.MavenSurefireScenarioNameRenderer; import com.googlecode.yatspec.state.ScenarioName; import org.junit.After; import org.junit.Before; import org.junit.Test; import org.junit.runners.model.FrameworkMethod; import java.lang.annotation.Annotation; import java.lang.reflect.Method; import java.util.List; import static com.googlecode.yatspec.fixture.RandomFixtures.anyString; import static com.googlecode.yatspec.fixture.RandomFixtures.pickOneOf; import static com.googlecode.yatspec.rendering.ScenarioNameRendererFactory.SCENARIO_NAME_RENDERER; import static java.util.Arrays.asList; import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.MatcherAssert.assertThat; @After public void tearDown() throws Exception { if (null != originalScenarioNameRenderer) { System.setProperty(SCENARIO_NAME_RENDERER, originalScenarioNameRenderer); } else { System.clearProperty(SCENARIO_NAME_RENDERER); } } @Test public void getsNameUsingDefaultRenderer() throws Exception { System.clearProperty(SCENARIO_NAME_RENDERER); String expectedName = new HumanReadableScenarioNameRenderer().render(new ScenarioName(methodName, args)); String actualName = decoratingFrameworkMethod.getName(); assertThat(actualName, is(expectedName)); } @Test public void getsNameUsingRenderSpecifiedBySystemProperty() throws Exception { System.setProperty(SCENARIO_NAME_RENDERER, MAVEN_SCENARIO_NAME_RENDERER); String expectedName = new MavenSurefireScenarioNameRenderer().render(new ScenarioName(methodName, args)); String actualName = decoratingFrameworkMethod.getName(); assertThat(actualName, is(expectedName)); } private Method method() throws NoSuchMethodException {
return pickOneOf(Object.class.getMethods());
bodar/yatspec
src/com/googlecode/yatspec/state/Results.java
// Path: src/com/googlecode/yatspec/state/StatusPriority.java // public static StatusPriority statusPriority(){ // return new StatusPriority(); // } // // Path: src/com/googlecode/yatspec/state/TestMethods.java // public static Callable1<? super TestMethod, Status> status() { // return new Callable1<TestMethod, Status>() { // @Override // public Status call(TestMethod testMethod) throws Exception { // return testMethod.getStatus(); // } // }; // }
import com.googlecode.totallylazy.Callable1; import static com.googlecode.totallylazy.Sequences.sequence; import static com.googlecode.yatspec.state.StatusPriority.statusPriority; import static com.googlecode.yatspec.state.TestMethods.status;
package com.googlecode.yatspec.state; public class Results { public static Callable1<Result, Iterable<TestMethod>> testMethods() { return new Callable1<Result, Iterable<TestMethod>>() { @Override public Iterable<TestMethod> call(Result result) throws Exception { return result.getTestMethods(); } }; } public static Callable1<Result, String> packageName() { return new Callable1<Result, String>() { @Override public String call(Result result) throws Exception { return result.getPackageName(); } }; } public static Callable1<Result, Status> resultStatus(){ return new Callable1<Result, Status>() { @Override public Status call(Result result) throws Exception { return sequence(result.getTestMethods()).
// Path: src/com/googlecode/yatspec/state/StatusPriority.java // public static StatusPriority statusPriority(){ // return new StatusPriority(); // } // // Path: src/com/googlecode/yatspec/state/TestMethods.java // public static Callable1<? super TestMethod, Status> status() { // return new Callable1<TestMethod, Status>() { // @Override // public Status call(TestMethod testMethod) throws Exception { // return testMethod.getStatus(); // } // }; // } // Path: src/com/googlecode/yatspec/state/Results.java import com.googlecode.totallylazy.Callable1; import static com.googlecode.totallylazy.Sequences.sequence; import static com.googlecode.yatspec.state.StatusPriority.statusPriority; import static com.googlecode.yatspec.state.TestMethods.status; package com.googlecode.yatspec.state; public class Results { public static Callable1<Result, Iterable<TestMethod>> testMethods() { return new Callable1<Result, Iterable<TestMethod>>() { @Override public Iterable<TestMethod> call(Result result) throws Exception { return result.getTestMethods(); } }; } public static Callable1<Result, String> packageName() { return new Callable1<Result, String>() { @Override public String call(Result result) throws Exception { return result.getPackageName(); } }; } public static Callable1<Result, Status> resultStatus(){ return new Callable1<Result, Status>() { @Override public Status call(Result result) throws Exception { return sequence(result.getTestMethods()).
map(status()).
bodar/yatspec
src/com/googlecode/yatspec/state/Results.java
// Path: src/com/googlecode/yatspec/state/StatusPriority.java // public static StatusPriority statusPriority(){ // return new StatusPriority(); // } // // Path: src/com/googlecode/yatspec/state/TestMethods.java // public static Callable1<? super TestMethod, Status> status() { // return new Callable1<TestMethod, Status>() { // @Override // public Status call(TestMethod testMethod) throws Exception { // return testMethod.getStatus(); // } // }; // }
import com.googlecode.totallylazy.Callable1; import static com.googlecode.totallylazy.Sequences.sequence; import static com.googlecode.yatspec.state.StatusPriority.statusPriority; import static com.googlecode.yatspec.state.TestMethods.status;
package com.googlecode.yatspec.state; public class Results { public static Callable1<Result, Iterable<TestMethod>> testMethods() { return new Callable1<Result, Iterable<TestMethod>>() { @Override public Iterable<TestMethod> call(Result result) throws Exception { return result.getTestMethods(); } }; } public static Callable1<Result, String> packageName() { return new Callable1<Result, String>() { @Override public String call(Result result) throws Exception { return result.getPackageName(); } }; } public static Callable1<Result, Status> resultStatus(){ return new Callable1<Result, Status>() { @Override public Status call(Result result) throws Exception { return sequence(result.getTestMethods()). map(status()).
// Path: src/com/googlecode/yatspec/state/StatusPriority.java // public static StatusPriority statusPriority(){ // return new StatusPriority(); // } // // Path: src/com/googlecode/yatspec/state/TestMethods.java // public static Callable1<? super TestMethod, Status> status() { // return new Callable1<TestMethod, Status>() { // @Override // public Status call(TestMethod testMethod) throws Exception { // return testMethod.getStatus(); // } // }; // } // Path: src/com/googlecode/yatspec/state/Results.java import com.googlecode.totallylazy.Callable1; import static com.googlecode.totallylazy.Sequences.sequence; import static com.googlecode.yatspec.state.StatusPriority.statusPriority; import static com.googlecode.yatspec.state.TestMethods.status; package com.googlecode.yatspec.state; public class Results { public static Callable1<Result, Iterable<TestMethod>> testMethods() { return new Callable1<Result, Iterable<TestMethod>>() { @Override public Iterable<TestMethod> call(Result result) throws Exception { return result.getTestMethods(); } }; } public static Callable1<Result, String> packageName() { return new Callable1<Result, String>() { @Override public String call(Result result) throws Exception { return result.getPackageName(); } }; } public static Callable1<Result, Status> resultStatus(){ return new Callable1<Result, Status>() { @Override public Status call(Result result) throws Exception { return sequence(result.getTestMethods()). map(status()).
sortBy(statusPriority()).
bodar/yatspec
src/com/googlecode/yatspec/state/TestResult.java
// Path: src/com/googlecode/yatspec/parsing/TestParser.java // public class TestParser { // // private static final Option<URL> NO_URL = none(URL.class); // // public static List<TestMethod> parseTestMethods(Class aClass) throws Exception { // final Sequence<Method> methods = getMethods(aClass); // return collectTestMethods(aClass, methods).toList(); // } // // private static Sequence<TestMethod> collectTestMethods(Class aClass, Sequence<Method> methods) throws IOException { // final Option<JavaClass> javaClass = getJavaClass(aClass); // if (javaClass.isEmpty()) { // return empty(); // } // // Map<String, List<JavaMethod>> sourceMethodsByName = getMethods(javaClass.get()).toMap(sourceMethodName()); // Map<String, List<Method>> reflectionMethodsByName = methods.toMap(reflectionMethodName()); // // List<TestMethod> testMethods = new ArrayList<TestMethod>(); // TestMethodExtractor extractor = new TestMethodExtractor(); // for (String name : sourceMethodsByName.keySet()) { // List<JavaMethod> javaMethods = sourceMethodsByName.get(name); // List<Method> reflectionMethods = reflectionMethodsByName.get(name); // testMethods.add(extractor.toTestMethod(aClass, javaMethods.get(0), reflectionMethods.get(0))); // // TODO: If people overload test methods we will have to use the full name rather than the short name // } // // Sequence<TestMethod> myTestMethods = sequence(testMethods); // Sequence<TestMethod> parentTestMethods = collectTestMethods(aClass.getSuperclass(), methods); // // return myTestMethods.join(parentTestMethods); // } // // private static Callable1<? super Method, String> reflectionMethodName() { // return new Callable1<Method, String>() { // @Override // public String call(Method method) throws Exception { // return method.getName(); // } // }; // } // // private static Callable1<JavaMethod, String> sourceMethodName() { // return new Callable1<JavaMethod, String>() { // @Override // public String call(JavaMethod javaMethod) throws Exception { // return javaMethod.getName(); // } // }; // } // // private static Option<JavaClass> getJavaClass(final Class aClass) throws IOException { // Option<URL> option = getJavaSourceFromClassPath(aClass); // option = !option.isEmpty() ? option : getJavaSourceFromFileSystem(aClass); // return option.map(asAJavaClass(aClass)); // } // // private static Callable1<URL, JavaClass> asAJavaClass(final Class aClass) { // return new Callable1<URL, JavaClass>() { // @Override // public JavaClass call(URL url) throws Exception { // JavaDocBuilder builder = new JavaDocBuilder(); // builder.addSource(url); // return builder.getClassByName(aClass.getName()); // } // }; // } // // private static Sequence<Method> getMethods(Class aClass) { // return sequence(aClass.getMethods()).filter(where(annotation(Test.class), notNullValue())); // } // // @SuppressWarnings("unchecked") // private static Sequence<JavaMethod> getMethods(JavaClass javaClass) { // return sequence(javaClass.getMethods()).filter(where(annotations(), contains(Test.class))); // } // // private static Option<URL> getJavaSourceFromClassPath(Class aClass) { // return isObject(aClass) ? NO_URL : option(aClass.getClassLoader().getResource(toJavaResourcePath(aClass))); // } // // private static Option<URL> getJavaSourceFromFileSystem(Class aClass) { // return isObject(aClass) ? NO_URL : recursiveFiles(workingDirectory()).find(where(path(), endsWith(toJavaPath(aClass)))).map(toURL()); // } // // private static boolean isObject(Class aClass) { // return aClass.equals(Object.class); // } // // private static Predicate<? super Sequence<Annotation>> contains(final Class aClass) { // return new Predicate<Sequence<Annotation>>() { // @Override // public boolean matches(Sequence<Annotation> annotations) { // return annotations.exists(where(name(), is(aClass.getName()))); // } // }; // } // // public static Callable1<? super Annotation, String> name() { // return new Callable1<Annotation, String>() { // @Override // public String call(Annotation annotation) throws Exception { // return annotation.getType().getFullyQualifiedName(); // } // }; // } // // public static Callable1<? super JavaMethod, Sequence<Annotation>> annotations() { // return new Callable1<JavaMethod, Sequence<Annotation>>() { // @Override // public Sequence<Annotation> call(JavaMethod javaMethod) throws Exception { // return sequence(javaMethod.getAnnotations()); // } // }; // } // // // } // // Path: src/com/googlecode/yatspec/parsing/Text.java // public static String wordify(String value) { // final String wordified = quotedStrings.findMatches(value).replace(wordifier, doNothing); // return Strings.capitalise(spaceRemover.matcher(wordified).replaceAll(" ").trim()); // }
import com.googlecode.totallylazy.Predicate; import com.googlecode.yatspec.parsing.TestParser; import java.lang.annotation.Annotation; import java.util.List; import static com.googlecode.totallylazy.Sequences.sequence; import static com.googlecode.yatspec.junit.YatspecAnnotation.methods.yatspecAnnotations; import static com.googlecode.yatspec.parsing.Text.wordify; import static java.util.Arrays.asList;
package com.googlecode.yatspec.state; @SuppressWarnings({"unused"}) public class TestResult implements Result { private final Class<?> klass; private List<TestMethod> testMethods; public TestResult(Class<?> klass) { this.klass = klass; } @Override public Class<?> getTestClass() { return klass; } @Override public List<TestMethod> getTestMethods() throws Exception { if (testMethods == null) {
// Path: src/com/googlecode/yatspec/parsing/TestParser.java // public class TestParser { // // private static final Option<URL> NO_URL = none(URL.class); // // public static List<TestMethod> parseTestMethods(Class aClass) throws Exception { // final Sequence<Method> methods = getMethods(aClass); // return collectTestMethods(aClass, methods).toList(); // } // // private static Sequence<TestMethod> collectTestMethods(Class aClass, Sequence<Method> methods) throws IOException { // final Option<JavaClass> javaClass = getJavaClass(aClass); // if (javaClass.isEmpty()) { // return empty(); // } // // Map<String, List<JavaMethod>> sourceMethodsByName = getMethods(javaClass.get()).toMap(sourceMethodName()); // Map<String, List<Method>> reflectionMethodsByName = methods.toMap(reflectionMethodName()); // // List<TestMethod> testMethods = new ArrayList<TestMethod>(); // TestMethodExtractor extractor = new TestMethodExtractor(); // for (String name : sourceMethodsByName.keySet()) { // List<JavaMethod> javaMethods = sourceMethodsByName.get(name); // List<Method> reflectionMethods = reflectionMethodsByName.get(name); // testMethods.add(extractor.toTestMethod(aClass, javaMethods.get(0), reflectionMethods.get(0))); // // TODO: If people overload test methods we will have to use the full name rather than the short name // } // // Sequence<TestMethod> myTestMethods = sequence(testMethods); // Sequence<TestMethod> parentTestMethods = collectTestMethods(aClass.getSuperclass(), methods); // // return myTestMethods.join(parentTestMethods); // } // // private static Callable1<? super Method, String> reflectionMethodName() { // return new Callable1<Method, String>() { // @Override // public String call(Method method) throws Exception { // return method.getName(); // } // }; // } // // private static Callable1<JavaMethod, String> sourceMethodName() { // return new Callable1<JavaMethod, String>() { // @Override // public String call(JavaMethod javaMethod) throws Exception { // return javaMethod.getName(); // } // }; // } // // private static Option<JavaClass> getJavaClass(final Class aClass) throws IOException { // Option<URL> option = getJavaSourceFromClassPath(aClass); // option = !option.isEmpty() ? option : getJavaSourceFromFileSystem(aClass); // return option.map(asAJavaClass(aClass)); // } // // private static Callable1<URL, JavaClass> asAJavaClass(final Class aClass) { // return new Callable1<URL, JavaClass>() { // @Override // public JavaClass call(URL url) throws Exception { // JavaDocBuilder builder = new JavaDocBuilder(); // builder.addSource(url); // return builder.getClassByName(aClass.getName()); // } // }; // } // // private static Sequence<Method> getMethods(Class aClass) { // return sequence(aClass.getMethods()).filter(where(annotation(Test.class), notNullValue())); // } // // @SuppressWarnings("unchecked") // private static Sequence<JavaMethod> getMethods(JavaClass javaClass) { // return sequence(javaClass.getMethods()).filter(where(annotations(), contains(Test.class))); // } // // private static Option<URL> getJavaSourceFromClassPath(Class aClass) { // return isObject(aClass) ? NO_URL : option(aClass.getClassLoader().getResource(toJavaResourcePath(aClass))); // } // // private static Option<URL> getJavaSourceFromFileSystem(Class aClass) { // return isObject(aClass) ? NO_URL : recursiveFiles(workingDirectory()).find(where(path(), endsWith(toJavaPath(aClass)))).map(toURL()); // } // // private static boolean isObject(Class aClass) { // return aClass.equals(Object.class); // } // // private static Predicate<? super Sequence<Annotation>> contains(final Class aClass) { // return new Predicate<Sequence<Annotation>>() { // @Override // public boolean matches(Sequence<Annotation> annotations) { // return annotations.exists(where(name(), is(aClass.getName()))); // } // }; // } // // public static Callable1<? super Annotation, String> name() { // return new Callable1<Annotation, String>() { // @Override // public String call(Annotation annotation) throws Exception { // return annotation.getType().getFullyQualifiedName(); // } // }; // } // // public static Callable1<? super JavaMethod, Sequence<Annotation>> annotations() { // return new Callable1<JavaMethod, Sequence<Annotation>>() { // @Override // public Sequence<Annotation> call(JavaMethod javaMethod) throws Exception { // return sequence(javaMethod.getAnnotations()); // } // }; // } // // // } // // Path: src/com/googlecode/yatspec/parsing/Text.java // public static String wordify(String value) { // final String wordified = quotedStrings.findMatches(value).replace(wordifier, doNothing); // return Strings.capitalise(spaceRemover.matcher(wordified).replaceAll(" ").trim()); // } // Path: src/com/googlecode/yatspec/state/TestResult.java import com.googlecode.totallylazy.Predicate; import com.googlecode.yatspec.parsing.TestParser; import java.lang.annotation.Annotation; import java.util.List; import static com.googlecode.totallylazy.Sequences.sequence; import static com.googlecode.yatspec.junit.YatspecAnnotation.methods.yatspecAnnotations; import static com.googlecode.yatspec.parsing.Text.wordify; import static java.util.Arrays.asList; package com.googlecode.yatspec.state; @SuppressWarnings({"unused"}) public class TestResult implements Result { private final Class<?> klass; private List<TestMethod> testMethods; public TestResult(Class<?> klass) { this.klass = klass; } @Override public Class<?> getTestClass() { return klass; } @Override public List<TestMethod> getTestMethods() throws Exception { if (testMethods == null) {
testMethods = TestParser.parseTestMethods(klass);