proj_name stringclasses 131
values | relative_path stringlengths 30 228 | class_name stringlengths 1 68 | func_name stringlengths 1 48 | masked_class stringlengths 78 9.82k | func_body stringlengths 46 9.61k | len_input int64 29 2.01k | len_output int64 14 1.94k | total int64 55 2.05k | relevant_context stringlengths 0 38.4k |
|---|---|---|---|---|---|---|---|---|---|
sannies_mp4parser | mp4parser/muxer/src/main/java/org/mp4parser/muxer/tracks/Avc1ToAvc3TrackImpl.java | ReplaceSyncSamplesList | get | class ReplaceSyncSamplesList extends AbstractList<Sample> {
List<Sample> parentSamples;
public ReplaceSyncSamplesList(List<Sample> parentSamples) {
this.parentSamples = parentSamples;
}
@Override
public Sample get(final int index) {<FILL_FUNCTION_BODY>}
@Ov... |
final Sample orignalSample = parentSamples.get(index);
if (orignalSample.getSampleEntry().getType().equals("avc1") && Arrays.binarySearch(Avc1ToAvc3TrackImpl.this.getSyncSamples(), index + 1) >= 0) {
final AvcConfigurationBox avcC = orignalSample.getSampleEntry().getBoxes(AvcC... | 117 | 979 | 1,096 | <methods>public void <init>(org.mp4parser.muxer.Track) ,public void close() throws java.io.IOException,public List<org.mp4parser.boxes.iso14496.part12.CompositionTimeToSample.Entry> getCompositionTimeEntries() ,public long getDuration() ,public List<org.mp4parser.muxer.Edit> getEdits() ,public java.lang.String getHandl... |
sannies_mp4parser | mp4parser/muxer/src/main/java/org/mp4parser/muxer/tracks/ChangeTimeScaleTrack.java | ChangeTimeScaleTrack | adjustCtts | class ChangeTimeScaleTrack implements Track {
private static Logger LOG = LoggerFactory.getLogger(ChangeTimeScaleTrack.class.getName());
Track source;
List<CompositionTimeToSample.Entry> ctts;
long[] decodingTimes;
long timeScale;
/**
* Changes the time scale of the source track to the ta... |
if (source != null) {
List<CompositionTimeToSample.Entry> entries2 = new ArrayList<CompositionTimeToSample.Entry>(source.size());
for (CompositionTimeToSample.Entry entry : source) {
entries2.add(new CompositionTimeToSample.Entry(entry.getCount(), (int) Math.round(timeSc... | 1,357 | 121 | 1,478 | <no_super_class> |
sannies_mp4parser | mp4parser/muxer/src/main/java/org/mp4parser/muxer/tracks/CleanInputStream.java | CleanInputStream | read | class CleanInputStream extends FilterInputStream {
int prevprev = -1;
int prev = -1;
public CleanInputStream(InputStream in) {
super(in);
}
public boolean markSupported() {
return false;
}
public int read() throws IOException {<FILL_FUNCTION_BODY>}
/**
* Copy of... |
int c = super.read();
if (c == 3 && prevprev == 0 && prev == 0) {
// discard this character
prevprev = -1;
prev = -1;
c = super.read();
}
prevprev = prev;
prev = c;
return c;
| 341 | 81 | 422 | <methods>public int available() throws java.io.IOException,public void close() throws java.io.IOException,public synchronized void mark(int) ,public boolean markSupported() ,public int read() throws java.io.IOException,public int read(byte[]) throws java.io.IOException,public int read(byte[], int, int) throws java.io.I... |
sannies_mp4parser | mp4parser/muxer/src/main/java/org/mp4parser/muxer/tracks/ClippedTrack.java | ClippedTrack | getDecodingTimeEntries | class ClippedTrack extends AbstractTrack {
private Track origTrack;
private int fromSample;
private int toSample;
/**
* Wraps an existing track and masks out a number of samples.
* Works like {@link java.util.List#subList(int, int)}.
*
* @param origTrack the original <code>Track</c... |
if (origSamples != null && !origSamples.isEmpty()) {
long current = 0;
ListIterator<TimeToSampleBox.Entry> e = origSamples.listIterator();
LinkedList<TimeToSampleBox.Entry> nuList = new LinkedList<TimeToSampleBox.Entry>();
// Skip while not yet reached:
... | 1,305 | 348 | 1,653 | <methods>public void <init>(java.lang.String) ,public List<org.mp4parser.boxes.iso14496.part12.CompositionTimeToSample.Entry> getCompositionTimeEntries() ,public long getDuration() ,public List<org.mp4parser.muxer.Edit> getEdits() ,public java.lang.String getName() ,public List<org.mp4parser.boxes.iso14496.part12.Sampl... |
sannies_mp4parser | mp4parser/muxer/src/main/java/org/mp4parser/muxer/tracks/DTSTrackImpl.java | LookAhead | getSample | class LookAhead {
private final int corePresent;
long bufferStartPos;
int inBufferPos = 0;
DataSource dataSource;
long dataEnd;
ByteBuffer buffer;
long start;
LookAhead(DataSource dataSource, long bufferStartPos, long dataSize, int corePresent) throws IO... |
if (start >= bufferStartPos) {
((Buffer)buffer).position((int) (start - bufferStartPos));
Buffer sample = buffer.slice();
((Buffer)sample).limit((int) (inBufferPos - (start - bufferStartPos)));
return (ByteBuffer) sample;
} else {
... | 1,176 | 113 | 1,289 | <methods>public void <init>(java.lang.String) ,public List<org.mp4parser.boxes.iso14496.part12.CompositionTimeToSample.Entry> getCompositionTimeEntries() ,public long getDuration() ,public List<org.mp4parser.muxer.Edit> getEdits() ,public java.lang.String getName() ,public List<org.mp4parser.boxes.iso14496.part12.Sampl... |
sannies_mp4parser | mp4parser/muxer/src/main/java/org/mp4parser/muxer/tracks/DivideTimeScaleTrack.java | DivideTimeScaleTrack | adjustCtts | class DivideTimeScaleTrack implements Track {
Track source;
private int timeScaleDivisor;
public DivideTimeScaleTrack(Track source, int timeScaleDivisor) {
this.source = source;
this.timeScaleDivisor = timeScaleDivisor;
}
public void close() throws IOException {
source.clos... |
List<CompositionTimeToSample.Entry> origCtts = this.source.getCompositionTimeEntries();
if (origCtts != null) {
List<CompositionTimeToSample.Entry> entries2 = new ArrayList<CompositionTimeToSample.Entry>(origCtts.size());
for (CompositionTimeToSample.Entry entry : origCtts) {
... | 654 | 151 | 805 | <no_super_class> |
sannies_mp4parser | mp4parser/muxer/src/main/java/org/mp4parser/muxer/tracks/MultiplyTimeScaleTrack.java | MultiplyTimeScaleTrack | adjustCtts | class MultiplyTimeScaleTrack implements Track {
Track source;
private int timeScaleFactor;
public MultiplyTimeScaleTrack(Track source, int timeScaleFactor) {
this.source = source;
this.timeScaleFactor = timeScaleFactor;
}
static List<CompositionTimeToSample.Entry> adjustCtts(List<C... |
if (source != null) {
List<CompositionTimeToSample.Entry> entries2 = new ArrayList<CompositionTimeToSample.Entry>(source.size());
for (CompositionTimeToSample.Entry entry : source) {
entries2.add(new CompositionTimeToSample.Entry(entry.getCount(), timeScaleFactor * entry... | 665 | 113 | 778 | <no_super_class> |
sannies_mp4parser | mp4parser/muxer/src/main/java/org/mp4parser/muxer/tracks/ReplaceSampleTrack.java | ReplaceASingleEntryList | get | class ReplaceASingleEntryList extends AbstractList<Sample> {
@Override
public Sample get(int index) {<FILL_FUNCTION_BODY>}
@Override
public int size() {
return ReplaceSampleTrack.this.origTrack.getSamples().size();
}
} |
if (ReplaceSampleTrack.this.sampleNumber == index) {
return ReplaceSampleTrack.this.sampleContent;
} else {
return ReplaceSampleTrack.this.origTrack.getSamples().get(index);
}
| 79 | 61 | 140 | <methods>public void <init>(java.lang.String) ,public List<org.mp4parser.boxes.iso14496.part12.CompositionTimeToSample.Entry> getCompositionTimeEntries() ,public long getDuration() ,public List<org.mp4parser.muxer.Edit> getEdits() ,public java.lang.String getName() ,public List<org.mp4parser.boxes.iso14496.part12.Sampl... |
sannies_mp4parser | mp4parser/muxer/src/main/java/org/mp4parser/muxer/tracks/SilenceTrackImpl.java | SilenceTrackImpl | getDuration | class SilenceTrackImpl implements Track {
private Track source;
private List<Sample> samples = new LinkedList<Sample>();
private long[] decodingTimes;
private String name;
public SilenceTrackImpl(Track ofType, long ms) {
source = ofType;
name = "" + ms + "ms silence";
asse... |
long duration = 0;
for (long delta : decodingTimes) {
duration += delta;
}
return duration;
| 671 | 36 | 707 | <no_super_class> |
sannies_mp4parser | mp4parser/muxer/src/main/java/org/mp4parser/muxer/tracks/TextTrackImpl.java | TextTrackImpl | getSamples | class TextTrackImpl extends AbstractTrack {
TrackMetaData trackMetaData = new TrackMetaData();
TextSampleEntry tx3g;
List<Line> subs = new LinkedList<Line>();
List<Sample> samples;
public TextTrackImpl() {
super("subtitles");
tx3g = new TextSampleEntry("tx3g");
tx3g.setData... |
if (samples == null) {
samples = new ArrayList<>();
long lastEnd = 0;
for (Line sub : subs) {
long silentTime = sub.from - lastEnd;
if (silentTime > 0) {
samples.add(new SampleImpl(ByteBuffer.wrap(new byte[]{0, 0}), tx3g));... | 824 | 269 | 1,093 | <methods>public void <init>(java.lang.String) ,public List<org.mp4parser.boxes.iso14496.part12.CompositionTimeToSample.Entry> getCompositionTimeEntries() ,public long getDuration() ,public List<org.mp4parser.muxer.Edit> getEdits() ,public java.lang.String getName() ,public List<org.mp4parser.boxes.iso14496.part12.Sampl... |
sannies_mp4parser | mp4parser/muxer/src/main/java/org/mp4parser/muxer/tracks/encryption/CencDecryptingSampleEntryTransformer.java | CencDecryptingSampleEntryTransformer | transform | class CencDecryptingSampleEntryTransformer {
private HashMap<SampleEntry, SampleEntry> cache = new HashMap<>();
SampleEntry transform(SampleEntry se) {<FILL_FUNCTION_BODY>}
} |
SampleEntry decSe = cache.get(se);
if (decSe == null) {
OriginalFormatBox frma;
if (se.getType().equals("enca")) {
frma = Path.getPath((AudioSampleEntry) se, "sinf/frma");
} else if (se.getType().equals("encv")) {
frma = Path.getPath((... | 57 | 473 | 530 | <no_super_class> |
sannies_mp4parser | mp4parser/muxer/src/main/java/org/mp4parser/muxer/tracks/encryption/CencDecryptingSampleList.java | CencDecryptingSampleList | get | class CencDecryptingSampleList extends AbstractList<Sample> {
private RangeStartMap<Integer, SampleEntry> sampleEntries;
private List<CencSampleAuxiliaryDataFormat> sencInfo;
private RangeStartMap<Integer, SecretKey> keys = new RangeStartMap<>();
private List<Sample> parent;
public CencDecryptingS... |
if (keys.get(index) != null) {
Sample encSample = parent.get(index);
final ByteBuffer encSampleBuffer = encSample.asByteBuffer();
((Buffer)encSampleBuffer).rewind();
final ByteBuffer decSampleBuffer = ByteBuffer.allocate(encSampleBuffer.limit());
fina... | 622 | 698 | 1,320 | <methods>public boolean add(org.mp4parser.muxer.Sample) ,public void add(int, org.mp4parser.muxer.Sample) ,public boolean addAll(int, Collection<? extends org.mp4parser.muxer.Sample>) ,public void clear() ,public boolean equals(java.lang.Object) ,public abstract org.mp4parser.muxer.Sample get(int) ,public int hashCode(... |
sannies_mp4parser | mp4parser/muxer/src/main/java/org/mp4parser/muxer/tracks/encryption/CencDecryptingTrackImpl.java | CencDecryptingTrackImpl | init | class CencDecryptingTrackImpl extends AbstractTrack {
private CencDecryptingSampleList samples;
private CencEncryptedTrack original;
private LinkedHashSet<SampleEntry> sampleEntries = new LinkedHashSet<>();
public CencDecryptingTrackImpl(CencEncryptedTrack original, SecretKey sk) {
super("dec... |
CencDecryptingSampleEntryTransformer tx = new CencDecryptingSampleEntryTransformer();
List<Sample> encSamples = original.getSamples();
RangeStartMap<Integer, SecretKey> indexToKey = new RangeStartMap<>();
RangeStartMap<Integer, SampleEntry> indexToSampleEntry = new RangeStartMap<>();
... | 504 | 338 | 842 | <methods>public void <init>(java.lang.String) ,public List<org.mp4parser.boxes.iso14496.part12.CompositionTimeToSample.Entry> getCompositionTimeEntries() ,public long getDuration() ,public List<org.mp4parser.muxer.Edit> getEdits() ,public java.lang.String getName() ,public List<org.mp4parser.boxes.iso14496.part12.Sampl... |
sannies_mp4parser | mp4parser/muxer/src/main/java/org/mp4parser/muxer/tracks/encryption/CencEncryptingSampleEntryTransformer.java | CencEncryptingSampleEntryTransformer | transform | class CencEncryptingSampleEntryTransformer {
private HashMap<SampleEntry, SampleEntry> cache = new HashMap<>();
public SampleEntry transform(SampleEntry se, String encryptionAlgo, UUID defaultKeyId) {<FILL_FUNCTION_BODY>}
} |
SampleEntry encSampleEntry = cache.get(se);
if (encSampleEntry == null) {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
try {
se.getBox(Channels.newChannel(baos));
encSampleEntry= (SampleEntry) new IsoFile(new ByteBufferByteChannel(Byt... | 69 | 538 | 607 | <no_super_class> |
sannies_mp4parser | mp4parser/muxer/src/main/java/org/mp4parser/muxer/tracks/encryption/CencEncryptingSampleList.java | EncryptedSampleImpl | writeTo | class EncryptedSampleImpl implements Sample {
private final Sample clearSample;
private int index;
private EncryptedSampleImpl(
Sample clearSample,
int index
) {
this.clearSample = clearSample;
this.index = index;
... |
ByteBuffer sample = (ByteBuffer)((Buffer)clearSample.asByteBuffer()).rewind();
SampleEntry se = sampleEntries.get(index);
KeyIdKeyPair keyIdKeyPair = keys.get(index);
CencSampleAuxiliaryDataFormat entry = auxiliaryDataFormats.get(index);
SchemeTypeBox schm =... | 752 | 554 | 1,306 | <methods>public boolean add(org.mp4parser.muxer.Sample) ,public void add(int, org.mp4parser.muxer.Sample) ,public boolean addAll(int, Collection<? extends org.mp4parser.muxer.Sample>) ,public void clear() ,public boolean equals(java.lang.Object) ,public abstract org.mp4parser.muxer.Sample get(int) ,public int hashCode(... |
sannies_mp4parser | mp4parser/muxer/src/main/java/org/mp4parser/muxer/tracks/h264/H264TrackImpl.java | FirstVclNalDetector | isFirstInNew | class FirstVclNalDetector {
int frame_num;
int pic_parameter_set_id;
boolean field_pic_flag;
boolean bottom_field_flag;
int nal_ref_idc;
int pic_order_cnt_type;
int delta_pic_order_cnt_bottom;
int pic_order_cnt_lsb;
... |
if (nu.frame_num != frame_num) {
return true;
}
if (nu.pic_parameter_set_id != pic_parameter_set_id) {
return true;
}
if (nu.field_pic_flag != field_pic_flag) {
return true;
... | 553 | 462 | 1,015 | <methods>public void <init>(org.mp4parser.muxer.DataSource, boolean) ,public void <init>(org.mp4parser.muxer.DataSource) ,public void close() throws java.io.IOException,public List<org.mp4parser.boxes.iso14496.part12.CompositionTimeToSample.Entry> getCompositionTimeEntries() ,public List<org.mp4parser.boxes.iso14496.pa... |
sannies_mp4parser | mp4parser/muxer/src/main/java/org/mp4parser/muxer/tracks/h264/SliceHeader.java | SliceHeader | toString | class SliceHeader {
public int first_mb_in_slice;
public SliceType slice_type;
public int pic_parameter_set_id;
public int colour_plane_id;
public int frame_num;
public boolean field_pic_flag = false;
public boolean bottom_field_flag = false;
public int idr_pic_id;
public int pic_or... |
return "SliceHeader{" +
"first_mb_in_slice=" + first_mb_in_slice +
", slice_type=" + slice_type +
", pic_parameter_set_id=" + pic_parameter_set_id +
", colour_plane_id=" + colour_plane_id +
", frame_num=" + frame_num +
... | 1,146 | 207 | 1,353 | <no_super_class> |
sannies_mp4parser | mp4parser/muxer/src/main/java/org/mp4parser/muxer/tracks/h264/parsing/BTree.java | BTree | addString | class BTree {
private BTree zero;
private BTree one;
private Object value;
public void addString(String path, Object value) {<FILL_FUNCTION_BODY>}
public BTree down(int b) {
if (b == 0)
return zero;
else
return one;
}
public Object getValue() {
... |
if (path.length() == 0) {
this.value = value;
return;
}
char charAt = path.charAt(0);
BTree branch;
if (charAt == '0') {
if (zero == null)
zero = new BTree();
branch = zero;
} else {
if (one == n... | 108 | 128 | 236 | <no_super_class> |
sannies_mp4parser | mp4parser/muxer/src/main/java/org/mp4parser/muxer/tracks/h264/parsing/CharCache.java | CharCache | append | class CharCache {
private char[] cache;
private int pos;
public CharCache(int capacity) {
cache = new char[capacity];
}
public void append(String str) {<FILL_FUNCTION_BODY>}
public String toString() {
return new String(cache, 0, pos);
}
public void clear() {
p... |
char[] chars = str.toCharArray();
int available = cache.length - pos;
int toWrite = chars.length < available ? chars.length : available;
System.arraycopy(chars, 0, cache, pos, toWrite);
pos += toWrite;
| 170 | 74 | 244 | <no_super_class> |
sannies_mp4parser | mp4parser/muxer/src/main/java/org/mp4parser/muxer/tracks/h264/parsing/Debug.java | Debug | print8x8 | class Debug {
public final static boolean debug = false;
public final static void print8x8(int[] output) {
int i = 0;
for (int x = 0; x < 8; x++) {
for (int y = 0; y < 8; y++) {
System.out.printf("%3d, ", output[i]);
i++;
}
Sys... |
int i = 0;
for (int x = 0; x < 8; x++) {
for (int y = 0; y < 8; y++) {
System.out.printf("%3d, ", output[i]);
i++;
}
System.out.println();
}
| 449 | 79 | 528 | <no_super_class> |
sannies_mp4parser | mp4parser/muxer/src/main/java/org/mp4parser/muxer/tracks/h264/parsing/model/AspectRatio.java | AspectRatio | fromValue | class AspectRatio {
public static final AspectRatio Extended_SAR = new AspectRatio(255);
private int value;
private AspectRatio(int value) {
this.value = value;
}
public static AspectRatio fromValue(int value) {<FILL_FUNCTION_BODY>}
public int getValue() {
return value;
... |
if (value == Extended_SAR.value) {
return Extended_SAR;
}
return new AspectRatio(value);
| 172 | 41 | 213 | <no_super_class> |
sannies_mp4parser | mp4parser/muxer/src/main/java/org/mp4parser/muxer/tracks/h264/parsing/model/ChromaFormat.java | ChromaFormat | fromId | class ChromaFormat {
public static final ChromaFormat MONOCHROME = new ChromaFormat(0, 0, 0);
public static final ChromaFormat YUV_420 = new ChromaFormat(1, 2, 2);
public static final ChromaFormat YUV_422 = new ChromaFormat(2, 2, 1);
public static final ChromaFormat YUV_444 = new ChromaFormat(3, 1, 1);
... |
if (id == MONOCHROME.id) {
return MONOCHROME;
} else if (id == YUV_420.id) {
return YUV_420;
} else if (id == YUV_422.id) {
return YUV_422;
} else if (id == YUV_444.id) {
return YUV_444;
}
return null;
| 361 | 121 | 482 | <no_super_class> |
sannies_mp4parser | mp4parser/muxer/src/main/java/org/mp4parser/muxer/tracks/h264/parsing/model/HRDParameters.java | HRDParameters | toString | class HRDParameters {
public int cpb_cnt_minus1;
public int bit_rate_scale;
public int cpb_size_scale;
public int[] bit_rate_value_minus1;
public int[] cpb_size_value_minus1;
public boolean[] cbr_flag;
public int initial_cpb_removal_delay_length_minus1;
public int cpb_removal_delay_leng... |
return "HRDParameters{" +
"cpb_cnt_minus1=" + cpb_cnt_minus1 +
", bit_rate_scale=" + bit_rate_scale +
", cpb_size_scale=" + cpb_size_scale +
", bit_rate_value_minus1=" + Arrays.toString(bit_rate_value_minus1) +
", cpb_size_value_mi... | 169 | 269 | 438 | <no_super_class> |
sannies_mp4parser | mp4parser/muxer/src/main/java/org/mp4parser/muxer/tracks/h264/parsing/model/ScalingList.java | ScalingList | toString | class ScalingList {
public int[] scalingList;
public boolean useDefaultScalingMatrixFlag;
public static ScalingList read(CAVLCReader is, int sizeOfScalingList)
throws IOException {
ScalingList sl = new ScalingList();
sl.scalingList = new int[sizeOfScalingList];
int las... |
return "ScalingList{" +
"scalingList=" + scalingList +
", useDefaultScalingMatrixFlag=" + useDefaultScalingMatrixFlag +
'}';
| 416 | 48 | 464 | <no_super_class> |
sannies_mp4parser | mp4parser/muxer/src/main/java/org/mp4parser/muxer/tracks/h264/parsing/model/ScalingMatrix.java | ScalingMatrix | toString | class ScalingMatrix {
public ScalingList[] ScalingList4x4;
public ScalingList[] ScalingList8x8;
@Override
public String toString() {<FILL_FUNCTION_BODY>}
} |
return "ScalingMatrix{" +
"ScalingList4x4=" + (ScalingList4x4 == null ? null : Arrays.asList(ScalingList4x4)) + "\n" +
", ScalingList8x8=" + (ScalingList8x8 == null ? null : Arrays.asList(ScalingList8x8)) + "\n" +
'}';
| 62 | 101 | 163 | <no_super_class> |
sannies_mp4parser | mp4parser/muxer/src/main/java/org/mp4parser/muxer/tracks/h264/parsing/model/VUIParameters.java | VUIParameters | toString | class VUIParameters {
public boolean aspect_ratio_info_present_flag;
public int sar_width;
public int sar_height;
public boolean overscan_info_present_flag;
public boolean overscan_appropriate_flag;
public boolean video_signal_type_present_flag;
public int video_format;
public boolean v... |
return "VUIParameters{" + "\n" +
"aspect_ratio_info_present_flag=" + aspect_ratio_info_present_flag + "\n" +
", sar_width=" + sar_width + "\n" +
", sar_height=" + sar_height + "\n" +
", overscan_info_present_flag=" + overscan_info_present_flag + "... | 715 | 621 | 1,336 | <no_super_class> |
sannies_mp4parser | mp4parser/muxer/src/main/java/org/mp4parser/muxer/tracks/h264/parsing/read/BitstreamReader.java | BitstreamReader | moreRBSPData | class BitstreamReader {
protected static int bitsRead;
protected CharCache debugBits = new CharCache(50);
int nBit;
private InputStream is;
private int curByte;
private int nextByte;
public BitstreamReader(InputStream is) throws IOException {
this.is = is;
curByte = is.read(... |
if (nBit == 8) {
advance();
}
int tail = 1 << (8 - nBit - 1);
int mask = ((tail << 1) - 1);
boolean hasTail = (curByte & mask) == tail;
return !(curByte == -1 || (nextByte == -1 && hasTail));
| 1,199 | 89 | 1,288 | <no_super_class> |
sannies_mp4parser | mp4parser/muxer/src/main/java/org/mp4parser/muxer/tracks/h264/parsing/read/CAVLCReader.java | CAVLCReader | readCE | class CAVLCReader extends BitstreamReader {
public CAVLCReader(InputStream is) throws IOException {
super(is);
}
public long readNBit(int n, String message) throws IOException {
long val = readNBit(n);
trace(message, String.valueOf(val));
return val;
}
/**
*... |
while (true) {
int bit = read1Bit();
bt = bt.down(bit);
if (bt == null) {
throw new RuntimeException("Illegal code");
}
Object i = bt.getValue();
if (i != null) {
trace(message, i.toString());
... | 1,041 | 95 | 1,136 | <methods>public void <init>(java.io.InputStream) throws java.io.IOException,public void close() throws java.io.IOException,public long getBitPosition() ,public int getCurBit() ,public boolean isByteAligned() ,public boolean moreRBSPData() throws java.io.IOException,public int peakNextBits(int) throws java.io.IOExceptio... |
sannies_mp4parser | mp4parser/muxer/src/main/java/org/mp4parser/muxer/tracks/h264/parsing/write/BitstreamWriter.java | BitstreamWriter | writeCurByte | class BitstreamWriter {
private final OutputStream os;
private int[] curByte = new int[8];
private int curBit;
public BitstreamWriter(OutputStream out) {
this.os = out;
}
/*
* (non-Javadoc)
*
* @see ua.org.jplayer.javcodec.h264.H264BitOutputStream#flush()
*/
p... |
int toWrite = (curByte[0] << 7) | (curByte[1] << 6) | (curByte[2] << 5)
| (curByte[3] << 4) | (curByte[4] << 3) | (curByte[5] << 2)
| (curByte[6] << 1) | curByte[7];
os.write(toWrite);
| 599 | 97 | 696 | <no_super_class> |
sannies_mp4parser | mp4parser/muxer/src/main/java/org/mp4parser/muxer/tracks/h264/parsing/write/CAVLCWriter.java | CAVLCWriter | writeUE | class CAVLCWriter extends BitstreamWriter {
public CAVLCWriter(OutputStream out) {
super(out);
}
public void writeU(int value, int n, String string) throws IOException {
Debug.print(string + "\t");
writeNBit(value, n);
Debug.println("\t" + value);
}
public void wri... |
int bits = 0;
int cumul = 0;
for (int i = 0; i < 15; i++) {
if (value < cumul + (1 << i)) {
bits = i;
break;
}
cumul += (1 << i);
}
writeNBit(0, bits);
write1Bit(1);
writeNBit(value - cumul, bits... | 481 | 108 | 589 | <methods>public void <init>(java.io.OutputStream) ,public void flush() throws java.io.IOException,public void write1Bit(int) throws java.io.IOException,public void writeByte(int) throws java.io.IOException,public void writeNBit(long, int) throws java.io.IOException,public void writeRemainingZero() throws java.io.IOExce... |
sannies_mp4parser | mp4parser/muxer/src/main/java/org/mp4parser/muxer/tracks/mjpeg/OneJpegPerIframe.java | OneJpegPerIframe | getSamples | class OneJpegPerIframe extends AbstractTrack {
private File[] jpegs;
private TrackMetaData trackMetaData = new TrackMetaData();
private long[] sampleDurations;
private long[] syncSamples;
private VisualSampleEntry mp4v;
public OneJpegPerIframe(String name, File[] jpegs, Track alignTo) throws I... |
return new AbstractList<Sample>() {
@Override
public int size() {
return jpegs.length;
}
@Override
public Sample get(final int index) {
return new Sample() {
ByteBuffer sample = null;
... | 1,464 | 306 | 1,770 | <methods>public void <init>(java.lang.String) ,public List<org.mp4parser.boxes.iso14496.part12.CompositionTimeToSample.Entry> getCompositionTimeEntries() ,public long getDuration() ,public List<org.mp4parser.muxer.Edit> getEdits() ,public java.lang.String getName() ,public List<org.mp4parser.boxes.iso14496.part12.Sampl... |
sannies_mp4parser | mp4parser/muxer/src/main/java/org/mp4parser/muxer/tracks/ttml/TtmlSegmenter.java | TtmlSegmenter | pushDown | class TtmlSegmenter {
public static List<Document> split(Document doc, int splitTimeInSeconds) throws XPathExpressionException {
int splitTime = splitTimeInSeconds * 1000;
XPathFactory xPathfactory = XPathFactory.newInstance();
XPath xpath = xPathfactory.newXPath();
XPathExpression... |
long time = 0;
Node current = p;
while ((current = current.getParentNode()) != null) {
if (current.getAttributes() != null && current.getAttributes().getNamedItem("begin") != null) {
time += toTime(current.getAttributes().getNamedItem("begin").getNodeValue());
... | 1,508 | 242 | 1,750 | <no_super_class> |
sannies_mp4parser | mp4parser/muxer/src/main/java/org/mp4parser/muxer/tracks/webvtt/sampleboxes/AbstractCueBox.java | AbstractCueBox | getBox | class AbstractCueBox implements Box {
String content = "";
String type;
public AbstractCueBox(String type) {
this.type = type;
}
public String getContent() {
return content;
}
public void setContent(String content) {
this.content = content;
}
public long g... |
ByteBuffer header = ByteBuffer.allocate(l2i(getSize()));
IsoTypeWriter.writeUInt32(header, getSize());
header.put(IsoFile.fourCCtoBytes(getType()));
header.put(Utf8.convert(content));
writableByteChannel.write((ByteBuffer)((Buffer)header).rewind());
| 167 | 92 | 259 | <no_super_class> |
sannies_mp4parser | mp4parser/muxer/src/main/java/org/mp4parser/muxer/tracks/webvtt/sampleboxes/VTTCueBox.java | VTTCueBox | getSize | class VTTCueBox implements Box {
CueSourceIDBox cueSourceIDBox; // optional source ID
CueIDBox cueIDBox; // optional
CueTimeBox cueTimeBox; // optional current time indication
CueSettingsBox cueSettingsBox; // optional, cue settings
CuePayloadBox cuePayloadBox; // the (mandatory) cue payload lines
... |
return 8 +
(cueSourceIDBox != null ? cueSourceIDBox.getSize() : 0) +
(cueIDBox != null ? cueIDBox.getSize() : 0) +
(cueTimeBox != null ? cueTimeBox.getSize() : 0) +
(cueSettingsBox != null ? cueSettingsBox.getSize() : 0) +
(cuePayl... | 742 | 133 | 875 | <no_super_class> |
sannies_mp4parser | mp4parser/muxer/src/main/java/org/mp4parser/muxer/tracks/webvtt/sampleboxes/VTTEmptyCueBox.java | VTTEmptyCueBox | getBox | class VTTEmptyCueBox implements Box {
public VTTEmptyCueBox() {
}
public long getSize() {
return 8;
}
public void getBox(WritableByteChannel writableByteChannel) throws IOException {<FILL_FUNCTION_BODY>}
public String getType() {
return "vtte";
}
} |
ByteBuffer header = ByteBuffer.allocate(8);
IsoTypeWriter.writeUInt32(header, getSize());
header.put(IsoFile.fourCCtoBytes(getType()));
writableByteChannel.write((ByteBuffer)((Buffer) header).rewind());
| 101 | 73 | 174 | <no_super_class> |
sannies_mp4parser | mp4parser/streaming/src/main/java/org/mp4parser/streaming/extensions/CompositionTimeSampleExtension.java | CompositionTimeSampleExtension | create | class CompositionTimeSampleExtension implements SampleExtension {
public static Map<Long, CompositionTimeSampleExtension> pool =
Collections.synchronizedMap(new HashMap<Long, CompositionTimeSampleExtension>());
private long ctts;
public static CompositionTimeSampleExtension create(long offset) ... |
CompositionTimeSampleExtension c = pool.get(offset);
if (c == null) {
c = new CompositionTimeSampleExtension();
c.ctts = offset;
pool.put(offset, c);
}
return c;
| 209 | 65 | 274 | <no_super_class> |
sannies_mp4parser | mp4parser/streaming/src/main/java/org/mp4parser/streaming/extensions/DefaultSampleFlagsTrackExtension.java | DefaultSampleFlagsTrackExtension | create | class DefaultSampleFlagsTrackExtension implements TrackExtension {
public static Map<Long, SampleFlagsSampleExtension> pool =
Collections.synchronizedMap(new HashMap<Long, SampleFlagsSampleExtension>());
private byte isLeading, sampleDependsOn, sampleIsDependedOn, sampleHasRedundancy, samplePadding... |
DefaultSampleFlagsTrackExtension c = new DefaultSampleFlagsTrackExtension();
c.isLeading = isLeading;
c.sampleDependsOn = sampleDependsOn;
c.sampleIsDependedOn = sampleIsDependedOn;
c.sampleHasRedundancy = sampleHasRedundancy;
c.samplePaddingValue = samplePaddingValue;
... | 643 | 131 | 774 | <no_super_class> |
sannies_mp4parser | mp4parser/streaming/src/main/java/org/mp4parser/streaming/extensions/DimensionTrackExtension.java | DimensionTrackExtension | toString | class DimensionTrackExtension implements TrackExtension {
int width;
int height;
public DimensionTrackExtension(int width, int height) {
this.width = width;
this.height = height;
}
public int getWidth() {
return width;
}
public void setWidth(int width) {
th... |
return "width=" + width + ", height=" + height;
| 162 | 20 | 182 | <no_super_class> |
sannies_mp4parser | mp4parser/streaming/src/main/java/org/mp4parser/streaming/extensions/NameTrackExtension.java | NameTrackExtension | create | class NameTrackExtension implements TrackExtension {
private String name;
public static NameTrackExtension create(String name) {<FILL_FUNCTION_BODY>}
public String getName() {
return name;
}
} |
NameTrackExtension nameTrackExtension = new NameTrackExtension();
nameTrackExtension.name = name;
return nameTrackExtension;
| 60 | 34 | 94 | <no_super_class> |
sannies_mp4parser | mp4parser/streaming/src/main/java/org/mp4parser/streaming/extensions/SampleFlagsSampleExtension.java | SampleFlagsSampleExtension | create | class SampleFlagsSampleExtension implements SampleExtension {
public static Map<Long, SampleFlagsSampleExtension> pool =
Collections.synchronizedMap(new HashMap<Long, SampleFlagsSampleExtension>());
private byte isLeading, sampleDependsOn, sampleIsDependedOn, sampleHasRedundancy, samplePaddingValue... |
long key = isLeading + (sampleDependsOn << 2) + (sampleIsDependedOn << 4) + (sampleHasRedundancy << 6);
key += (samplePaddingValue << 8);
key += (sampleDegradationPriority << 11);
key += (sampleIsNonSyncSample ? 1 : 0) << 27;
SampleFlagsSampleExtension c = pool.get(key);
... | 757 | 246 | 1,003 | <no_super_class> |
sannies_mp4parser | mp4parser/streaming/src/main/java/org/mp4parser/streaming/input/h264/H264AnnexBTrack.java | NalStreamTokenizer | getNext | class NalStreamTokenizer {
private static Logger LOG = LoggerFactory.getLogger(NalStreamTokenizer.class.getName());
MyByteArrayOutputStream next = new MyByteArrayOutputStream();
int pattern = 0;
private InputStream inputStream;
public NalStreamTokenizer(InputStream inputStream) ... |
//System.err.println("getNext() called");
if (LOG.isDebugEnabled()) {
LOG.debug("getNext() called");
}
int c;
while ((c = inputStream.read()) != -1) {
if (!(pattern == 2 && c == 3)) {
next.write(c);
... | 120 | 329 | 449 | <methods>public void <init>() ,public void close() throws java.io.IOException,public synchronized void configure() ,public java.lang.String getHandler() ,public java.lang.String getLanguage() ,public static org.mp4parser.streaming.input.h264.H264NalUnitHeader getNalUnitHeader(java.nio.ByteBuffer) ,public org.mp4parser.... |
sannies_mp4parser | mp4parser/streaming/src/main/java/org/mp4parser/streaming/input/h264/PictureOrderCountType0SampleExtension.java | PictureOrderCountType0SampleExtension | toString | class PictureOrderCountType0SampleExtension implements SampleExtension {
int picOrderCntMsb;
int picOrderCountLsb;
public PictureOrderCountType0SampleExtension(SliceHeader currentSlice, PictureOrderCountType0SampleExtension previous) {
int prevPicOrderCntLsb = 0;
int prevPicOrderCntMsb = 0;... |
return "picOrderCntMsb=" + picOrderCntMsb + ", picOrderCountLsb=" + picOrderCountLsb;
| 519 | 38 | 557 | <no_super_class> |
sannies_mp4parser | mp4parser/streaming/src/main/java/org/mp4parser/streaming/input/h264/spspps/AspectRatio.java | AspectRatio | fromValue | class AspectRatio {
public static final AspectRatio Extended_SAR = new AspectRatio(255);
private int value;
private AspectRatio(int value) {
this.value = value;
}
public static AspectRatio fromValue(int value) {<FILL_FUNCTION_BODY>}
public int getValue() {
return value;
... |
if (value == Extended_SAR.value) {
return Extended_SAR;
}
return new AspectRatio(value);
| 172 | 41 | 213 | <no_super_class> |
sannies_mp4parser | mp4parser/streaming/src/main/java/org/mp4parser/streaming/input/h264/spspps/ByteBufferBitreader.java | ByteBufferBitreader | readNBit | class ByteBufferBitreader {
ByteBuffer buffer;
int nBit;
private int currentByte;
private int nextByte;
public ByteBufferBitreader(ByteBuffer buffer) {
this.buffer = buffer;
currentByte = get();
nextByte = get();
}
public int get() {
try {
int... |
if (n > 64)
throw new IllegalArgumentException("Can not readByte more then 64 bit");
long val = 0;
for (int i = 0; i < n; i++) {
val <<= 1;
val |= read1Bit();
}
return val;
| 580 | 80 | 660 | <no_super_class> |
sannies_mp4parser | mp4parser/streaming/src/main/java/org/mp4parser/streaming/input/h264/spspps/ChromaFormat.java | ChromaFormat | fromId | class ChromaFormat {
public static ChromaFormat MONOCHROME = new ChromaFormat(0, 0, 0);
public static ChromaFormat YUV_420 = new ChromaFormat(1, 2, 2);
public static ChromaFormat YUV_422 = new ChromaFormat(2, 2, 1);
public static ChromaFormat YUV_444 = new ChromaFormat(3, 1, 1);
private int id;
... |
if (id == MONOCHROME.id) {
return MONOCHROME;
} else if (id == YUV_420.id) {
return YUV_420;
} else if (id == YUV_422.id) {
return YUV_422;
} else if (id == YUV_444.id) {
return YUV_444;
}
return null;
| 357 | 121 | 478 | <no_super_class> |
sannies_mp4parser | mp4parser/streaming/src/main/java/org/mp4parser/streaming/input/h264/spspps/HRDParameters.java | HRDParameters | toString | class HRDParameters {
public int cpb_cnt_minus1;
public int bit_rate_scale;
public int cpb_size_scale;
public int[] bit_rate_value_minus1;
public int[] cpb_size_value_minus1;
public boolean[] cbr_flag;
public int initial_cpb_removal_delay_length_minus1;
public int cpb_removal_delay_leng... |
return "HRDParameters{" +
"cpb_cnt_minus1=" + cpb_cnt_minus1 +
", bit_rate_scale=" + bit_rate_scale +
", cpb_size_scale=" + cpb_size_scale +
", bit_rate_value_minus1=" + Arrays.toString(bit_rate_value_minus1) +
", cpb_size_value_mi... | 169 | 269 | 438 | <no_super_class> |
sannies_mp4parser | mp4parser/streaming/src/main/java/org/mp4parser/streaming/input/h264/spspps/ScalingList.java | ScalingList | read | class ScalingList {
public int[] scalingList;
public boolean useDefaultScalingMatrixFlag;
public static ScalingList read(ByteBufferBitreader is, int sizeOfScalingList)
throws IOException {<FILL_FUNCTION_BODY>}
@Override
public String toString() {
return "ScalingList{" +
... |
ScalingList sl = new ScalingList();
sl.scalingList = new int[sizeOfScalingList];
int lastScale = 8;
int nextScale = 8;
for (int j = 0; j < sizeOfScalingList; j++) {
if (nextScale != 0) {
int deltaScale = is.readSE();
nextScale = (last... | 130 | 181 | 311 | <no_super_class> |
sannies_mp4parser | mp4parser/streaming/src/main/java/org/mp4parser/streaming/input/h264/spspps/ScalingMatrix.java | ScalingMatrix | toString | class ScalingMatrix {
public ScalingList[] ScalingList4x4;
public ScalingList[] ScalingList8x8;
@Override
public String toString() {<FILL_FUNCTION_BODY>}
} |
return "ScalingMatrix{" +
"ScalingList4x4=" + (ScalingList4x4 == null ? null : Arrays.asList(ScalingList4x4)) + "\n" +
", ScalingList8x8=" + (ScalingList8x8 == null ? null : Arrays.asList(ScalingList8x8)) + "\n" +
'}';
| 62 | 101 | 163 | <no_super_class> |
sannies_mp4parser | mp4parser/streaming/src/main/java/org/mp4parser/streaming/input/h264/spspps/SliceHeader.java | SliceHeader | toString | class SliceHeader {
public int first_mb_in_slice;
public SliceType slice_type;
public int pic_parameter_set_id;
public int colour_plane_id;
public int frame_num;
public boolean field_pic_flag = false;
public boolean bottom_field_flag = false;
public int idr_pic_id = -1;
public int p... |
return "SliceHeader{" +
"first_mb_in_slice=" + first_mb_in_slice +
", slice_type=" + slice_type +
", pic_parameter_set_id=" + pic_parameter_set_id +
", colour_plane_id=" + colour_plane_id +
", frame_num=" + frame_num +
... | 1,112 | 207 | 1,319 | <no_super_class> |
sannies_mp4parser | mp4parser/streaming/src/main/java/org/mp4parser/streaming/input/h264/spspps/VUIParameters.java | BitstreamRestriction | toString | class BitstreamRestriction {
public boolean motion_vectors_over_pic_boundaries_flag;
public int max_bytes_per_pic_denom;
public int max_bits_per_mb_denom;
public int log2_max_mv_length_horizontal;
public int log2_max_mv_length_vertical;
public int num_reorder_frames;
... |
final StringBuilder sb = new StringBuilder("BitstreamRestriction{");
sb.append("motion_vectors_over_pic_boundaries_flag=").append(motion_vectors_over_pic_boundaries_flag);
sb.append(", max_bytes_per_pic_denom=").append(max_bytes_per_pic_denom);
sb.append(", max_bits_per_... | 138 | 254 | 392 | <no_super_class> |
sannies_mp4parser | mp4parser/streaming/src/main/java/org/mp4parser/streaming/input/mp4/DiscardingByteArrayOutputStream.java | DiscardingByteArrayOutputStream | grow | class DiscardingByteArrayOutputStream extends OutputStream {
/**
* The buffer where data is stored.
*/
protected byte buf[];
/**
* The number of valid bytes in the buffer.
*/
protected int count;
protected long startOffset = 0;
/**
* Creates a new byte array output s... |
// overflow-conscious code
int oldCapacity = buf.length;
int newCapacity = oldCapacity << 1;
if (newCapacity - minCapacity < 0)
newCapacity = minCapacity;
if (newCapacity < 0) {
if (minCapacity < 0) // overflow
throw new OutOfMemoryError()... | 1,615 | 121 | 1,736 | <methods>public void <init>() ,public void close() throws java.io.IOException,public void flush() throws java.io.IOException,public static java.io.OutputStream nullOutputStream() ,public abstract void write(int) throws java.io.IOException,public void write(byte[]) throws java.io.IOException,public void write(byte[], in... |
sannies_mp4parser | mp4parser/streaming/src/main/java/org/mp4parser/streaming/output/mp4/DefaultBoxes.java | DefaultBoxes | createTkhd | class DefaultBoxes {
public Box createFtyp() {
List<String> minorBrands = new LinkedList<String>();
minorBrands.add("isom");
minorBrands.add("iso2");
minorBrands.add("avc1");
minorBrands.add("iso6");
minorBrands.add("mp41");
return new FileTypeBox("isom", 512... |
TrackHeaderBox tkhd = new TrackHeaderBox();
tkhd.setTrackId(streamingTrack.getTrackExtension(TrackIdTrackExtension.class).getTrackId());
DimensionTrackExtension dte = streamingTrack.getTrackExtension(DimensionTrackExtension.class);
if (dte != null) {
tkhd.setHeight(dte.getHe... | 862 | 120 | 982 | <no_super_class> |
baomidou_mybatis-plus-samples | mybatis-plus-samples/mybatis-plus-sample-active-record/src/main/java/com/baomidou/mybatisplus/samples/ar/entity/User.java | User | pkVal | class User extends Model<User> {
private Long id;
private String name;
private Integer age;
private String email;
@Override
public Serializable pkVal() {<FILL_FUNCTION_BODY>}
} |
/**
* AR 模式这个必须有,否则 xxById 的方法都将失效!
* 另外 UserMapper 也必须 AR 依赖该层注入,有可无 XML
*/
return id;
| 62 | 57 | 119 | <no_super_class> |
baomidou_mybatis-plus-samples | mybatis-plus-samples/mybatis-plus-sample-assembly/src/main/java/com/baomidou/mybatisplus/samples/assembly/controller/UserController.java | UserController | test | class UserController {
private static final Logger LOGGER = LoggerFactory.getLogger(UserController.class);
@Autowired
private IUserService userService;
// 测试地址 http://localhost:8080/test
@RequestMapping(value = "test")
public String test(){<FILL_FUNCTION_BODY>}
} |
User user = new User();
user.setEmail("papapapap@qq.com");
user.setAge(18);
user.setName("啪啪啪");
userService.save(user);
List<User> list = userService.list(new LambdaQueryWrapper<>(new User()).select(User::getId, User::getName));
list.forEach(u -> LOGGER.info("当前... | 93 | 131 | 224 | <no_super_class> |
baomidou_mybatis-plus-samples | mybatis-plus-samples/mybatis-plus-sample-association/src/main/java/com/baomidou/mybatisplus/samples/association/config/MybatisPlusConfig.java | MybatisPlusConfig | mybatisPlusInterceptor | class MybatisPlusConfig {
/**
* 分页插件
*/
@Bean
public MybatisPlusInterceptor mybatisPlusInterceptor() {<FILL_FUNCTION_BODY>}
/**
* 注入主键生成器
*/
@Bean
public IKeyGenerator keyGenerator(){
return new H2KeyGenerator();
}
} |
MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor();
interceptor.addInnerInterceptor(new PaginationInnerInterceptor());
return interceptor;
| 107 | 53 | 160 | <no_super_class> |
baomidou_mybatis-plus-samples | mybatis-plus-samples/mybatis-plus-sample-ddl-mysql/src/main/java/com/baomidou/mybatisplus/samples/ddl/mysql/MysqlDdl.java | MysqlDdl | getSqlFiles | class MysqlDdl extends SimpleDdl {
/**
* 执行 SQL 脚本方式
*/
@Override
public List<String> getSqlFiles() {<FILL_FUNCTION_BODY>}
} |
return Arrays.asList(
// 测试存储过程
"db/test_procedure.sql#$$",
// 内置包方式
"db/tag-schema.sql",
"db/tag-data.sql"
// 文件绝对路径方式(修改为你电脑的地址)
// "D:\\sql\\tag-data.sql"
);
| 59 | 104 | 163 | <no_super_class> |
baomidou_mybatis-plus-samples | mybatis-plus-samples/mybatis-plus-sample-deluxe/src/main/java/com/baomidou/mybatisplus/samples/deluxe/MyLogicSqlInjector.java | MyLogicSqlInjector | getMethodList | class MyLogicSqlInjector extends DefaultSqlInjector {
/**
* 如果只需增加方法,保留MP自带方法
* 可以super.getMethodList() 再add
* @return
*/
@Override
public List<AbstractMethod> getMethodList(Class<?> mapperClass, TableInfo tableInfo) {<FILL_FUNCTION_BODY>}
} |
List<AbstractMethod> methodList = super.getMethodList(mapperClass, tableInfo);
methodList.add(new DeleteAll("deleteAll"));
methodList.add(new MyInsertAll("myInsertAll"));
methodList.add(new MysqlInsertAllBatch("mysqlInsertAllBatch"));
methodList.add(new SelectById());
re... | 101 | 93 | 194 | <no_super_class> |
baomidou_mybatis-plus-samples | mybatis-plus-samples/mybatis-plus-sample-deluxe/src/main/java/com/baomidou/mybatisplus/samples/deluxe/MyMetaObjectHandler.java | MyMetaObjectHandler | insertFill | class MyMetaObjectHandler implements MetaObjectHandler {
private static final Logger LOGGER = LoggerFactory.getLogger(MyMetaObjectHandler.class);
@Override
public void insertFill(MetaObject metaObject) {<FILL_FUNCTION_BODY>}
@Override
public void updateFill(MetaObject metaObject) {
LOGGER... |
LOGGER.info("start insert fill ....");
//避免使用metaObject.setValue()
this.strictInsertFill(metaObject, "createTime", Timestamp.class, new Timestamp(System.currentTimeMillis()));
| 102 | 57 | 159 | <no_super_class> |
baomidou_mybatis-plus-samples | mybatis-plus-samples/mybatis-plus-sample-deluxe/src/main/java/com/baomidou/mybatisplus/samples/deluxe/config/MybatisPlusConfig.java | MybatisPlusConfig | mybatisPlusInterceptor | class MybatisPlusConfig {
@Bean
public MybatisPlusInterceptor mybatisPlusInterceptor() {<FILL_FUNCTION_BODY>}
/**
* 自定义 SqlInjector
* 里面包含自定义的全局方法
*/
@Bean
public MyLogicSqlInjector myLogicSqlInjector() {
return new MyLogicSqlInjector();
}
} |
MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor();
interceptor.addInnerInterceptor(new PaginationInnerInterceptor());
interceptor.addInnerInterceptor(new OptimisticLockerInnerInterceptor());
return interceptor;
| 115 | 75 | 190 | <no_super_class> |
baomidou_mybatis-plus-samples | mybatis-plus-samples/mybatis-plus-sample-deluxe/src/main/java/com/baomidou/mybatisplus/samples/deluxe/methods/DeleteAll.java | DeleteAll | injectMappedStatement | class DeleteAll extends AbstractMethod {
public DeleteAll(String methodName) {
super(methodName);
}
@Override
public MappedStatement injectMappedStatement(Class<?> mapperClass, Class<?> modelClass, TableInfo tableInfo) {<FILL_FUNCTION_BODY>}
} |
/* 执行 SQL ,动态 SQL 参考类 SqlMethod */
String sql = "delete from " + tableInfo.getTableName();
/* mapper 接口方法名一致 */
SqlSource sqlSource = languageDriver.createSqlSource(configuration, sql, modelClass);
return this.addDeleteMappedStatement(mapperClass, methodName, sqlSource);
| 81 | 90 | 171 | <no_super_class> |
baomidou_mybatis-plus-samples | mybatis-plus-samples/mybatis-plus-sample-deluxe/src/main/java/com/baomidou/mybatisplus/samples/deluxe/methods/MyInsertAll.java | MyInsertAll | injectMappedStatement | class MyInsertAll extends AbstractMethod {
public MyInsertAll(String methodName) {
super(methodName);
}
@Override
public MappedStatement injectMappedStatement(Class<?> mapperClass, Class<?> modelClass, TableInfo tableInfo) {<FILL_FUNCTION_BODY>}
} |
String sql = "insert into %s %s values %s";
StringBuilder fieldSql = new StringBuilder();
fieldSql.append(tableInfo.getKeyColumn()).append(",");
StringBuilder valueSql = new StringBuilder();
valueSql.append("#{").append(tableInfo.getKeyProperty()).append("},");
tableInfo... | 83 | 290 | 373 | <no_super_class> |
baomidou_mybatis-plus-samples | mybatis-plus-samples/mybatis-plus-sample-deluxe/src/main/java/com/baomidou/mybatisplus/samples/deluxe/methods/MysqlInsertAllBatch.java | MysqlInsertAllBatch | prepareFieldSql | class MysqlInsertAllBatch extends AbstractMethod {
public MysqlInsertAllBatch(String methodName) {
super(methodName);
}
@Override
public MappedStatement injectMappedStatement(Class<?> mapperClass, Class<?> modelClass, TableInfo tableInfo) {
final String sql = "<script>insert into %s %s... |
StringBuilder fieldSql = new StringBuilder();
fieldSql.append(tableInfo.getKeyColumn()).append(",");
tableInfo.getFieldList().forEach(x -> {
fieldSql.append(x.getColumn()).append(",");
});
fieldSql.delete(fieldSql.length() - 1, fieldSql.length());
fieldSql.in... | 422 | 116 | 538 | <no_super_class> |
baomidou_mybatis-plus-samples | mybatis-plus-samples/mybatis-plus-sample-dynamic-tablename/src/main/java/com/baomidou/mybatisplus/samples/dytablename/config/MybatisPlusConfig.java | MybatisPlusConfig | mybatisPlusInterceptor | class MybatisPlusConfig {
@Bean
public MybatisPlusInterceptor mybatisPlusInterceptor() {<FILL_FUNCTION_BODY>}
} |
MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor();
DynamicTableNameInnerInterceptor dynamicTableNameInnerInterceptor = new DynamicTableNameInnerInterceptor();
dynamicTableNameInnerInterceptor.setTableNameHandler((sql, tableName) -> {
// 获取参数方法
Map<String,... | 46 | 252 | 298 | <no_super_class> |
baomidou_mybatis-plus-samples | mybatis-plus-samples/mybatis-plus-sample-dynamic-tablename/src/main/java/com/baomidou/mybatisplus/samples/dytablename/config/RequestDataHelper.java | RequestDataHelper | getRequestData | class RequestDataHelper {
/**
* 请求参数存取
*/
private static final ThreadLocal<Map<String, Object>> REQUEST_DATA = new ThreadLocal<>();
/**
* 设置请求参数
*
* @param requestData 请求参数 MAP 对象
*/
public static void setRequestData(Map<String, Object> requestData) {
REQUEST_DATA.... |
Map<String, Object> dataMap = getRequestData();
if (CollectionUtils.isNotEmpty(dataMap)) {
return (T) dataMap.get(param);
}
return null;
| 234 | 54 | 288 | <no_super_class> |
baomidou_mybatis-plus-samples | mybatis-plus-samples/mybatis-plus-sample-execution-analysis/src/main/java/com/baomidou/samples/execution/config/MybatisPlusConfig.java | MybatisPlusConfig | mybatisPlusInterceptor | class MybatisPlusConfig {
@Bean
public MybatisPlusInterceptor mybatisPlusInterceptor() {<FILL_FUNCTION_BODY>}
} |
MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor();
interceptor.addInnerInterceptor(new BlockAttackInnerInterceptor());
return interceptor;
| 46 | 53 | 99 | <no_super_class> |
baomidou_mybatis-plus-samples | mybatis-plus-samples/mybatis-plus-sample-id-generator/src/main/java/com/baomidou/samples/incrementer/CustomIdGenerator.java | CustomIdGenerator | nextId | class CustomIdGenerator implements IdentifierGenerator {
private final AtomicLong al = new AtomicLong(1);
@Override
public Long nextId(Object entity) {<FILL_FUNCTION_BODY>}
} |
//可以将当前传入的class全类名来作为bizKey,或者提取参数来生成bizKey进行分布式Id调用生成.
String bizKey = entity.getClass().getName();
log.info("bizKey:{}", bizKey);
MetaObject metaObject = SystemMetaObject.forObject(entity);
String name = (String) metaObject.getValue("name");
final long id = al.getAndAd... | 57 | 144 | 201 | <no_super_class> |
baomidou_mybatis-plus-samples | mybatis-plus-samples/mybatis-plus-sample-jsonb/src/main/java/com/baomidou/mybatisplus/samples/jsonb/entity/JsonbTypeHandler.java | JsonbTypeHandler | setNonNullParameter | class JsonbTypeHandler extends JacksonTypeHandler {
private static final PGobject jsonObject = new PGobject();
public JsonbTypeHandler(Class<?> type) {
super(type);
}
@Override
public void setNonNullParameter(PreparedStatement ps, int i, Object parameter, JdbcType jdbcType) throws SQLExcep... |
if (ps != null) {
jsonObject.setType("jsonb");
jsonObject.setValue(toJson(parameter));
ps.setObject(i, jsonObject);
}
| 103 | 52 | 155 | <no_super_class> |
baomidou_mybatis-plus-samples | mybatis-plus-samples/mybatis-plus-sample-jsonb/src/main/java/com/baomidou/mybatisplus/samples/jsonb/entity/TestContent.java | TestContent | of | class TestContent {
private String title;
private String content;
public static TestContent of(String title, String content) {<FILL_FUNCTION_BODY>}
} |
TestContent tc = new TestContent();
tc.setTitle(title);
tc.setContent(content);
return tc;
| 47 | 40 | 87 | <no_super_class> |
baomidou_mybatis-plus-samples | mybatis-plus-samples/mybatis-plus-sample-mysql/src/main/java/com/baomidou/mybatisplus/samples/mysql/config/MybatisPlusConfig.java | MybatisPlusConfig | globalConfig | class MybatisPlusConfig {
@Bean("mybatisSqlSession")
public SqlSessionFactory sqlSessionFactory(DataSource dataSource, GlobalConfig globalConfig) throws Exception {
MybatisSqlSessionFactoryBean sqlSessionFactory = new MybatisSqlSessionFactoryBean();
/* 数据源 */
sqlSessionFactory.setDataSo... |
GlobalConfig conf = new GlobalConfig();
conf.setDbConfig(new GlobalConfig.DbConfig().setColumnFormat("`%s`"));
DefaultSqlInjector logicSqlInjector = new DefaultSqlInjector() {
/**
* 注入自定义全局方法
*/
@Override
public List<AbstractMethod> ... | 488 | 307 | 795 | <no_super_class> |
baomidou_mybatis-plus-samples | mybatis-plus-samples/mybatis-plus-sample-mysql/src/main/java/com/baomidou/mybatisplus/samples/mysql/config/MysqlMetaObjectHandler.java | MysqlMetaObjectHandler | insertFill | class MysqlMetaObjectHandler implements MetaObjectHandler {
/**
* 测试 user 表 name 字段为空自动填充
*/
@Override
public void insertFill(MetaObject metaObject) {<FILL_FUNCTION_BODY>}
@Override
public void updateFill(MetaObject metaObject) {
System.out.println("*************************");
... |
System.out.println("*************************");
System.out.println("insert of mysql fill");
System.out.println("*************************");
// 测试下划线
Object createDatetime = this.getFieldValByName("createDatetime", metaObject);
System.out.println("createDatetime=" + cre... | 201 | 176 | 377 | <no_super_class> |
baomidou_mybatis-plus-samples | mybatis-plus-samples/mybatis-plus-sample-no-spring/src/main/java/com/baomidou/mybatisplus/no/spring/NoSpring.java | NoSpring | dataSource | class NoSpring {
private static SqlSessionFactory sqlSessionFactory = initSqlSessionFactory();
public static void main(String[] args) {
try (SqlSession session = sqlSessionFactory.openSession(true)) {
PersonMapper mapper = session.getMapper(PersonMapper.class);
Person person = ... |
PooledDataSource dataSource = new PooledDataSource();
dataSource.setDriver(org.h2.Driver.class.getName());
dataSource.setUrl("jdbc:h2:mem:test");
dataSource.setUsername("root");
dataSource.setPassword("test");
try {
Connection connection = dataSource.getConne... | 264 | 185 | 449 | <no_super_class> |
baomidou_mybatis-plus-samples | mybatis-plus-samples/mybatis-plus-sample-optimistic-locker/src/main/java/com/baomidou/mybatisplus/samples/optlocker/config/MybatisPlusOptLockerConfig.java | MybatisPlusOptLockerConfig | mybatisPlusInterceptor | class MybatisPlusOptLockerConfig {
@Bean
public MybatisPlusInterceptor mybatisPlusInterceptor() {<FILL_FUNCTION_BODY>}
} |
MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor();
interceptor.addInnerInterceptor(new OptimisticLockerInnerInterceptor());
return interceptor;
| 49 | 54 | 103 | <no_super_class> |
baomidou_mybatis-plus-samples | mybatis-plus-samples/mybatis-plus-sample-pagination/src/main/java/com/baomidou/mybatisplus/samples/pagination/config/MybatisPlusConfig.java | MybatisPlusConfig | mybatisPlusInterceptor | class MybatisPlusConfig {
/**
* 新的分页插件,一缓和二缓遵循mybatis的规则,需要设置 MybatisConfiguration#useDeprecatedExecutor = false 避免缓存出现问题
*/
@Bean
public MybatisPlusInterceptor mybatisPlusInterceptor() {<FILL_FUNCTION_BODY>}
// @Bean
// public ConfigurationCustomizer configurationCustomizer() {
// ... |
MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor();
interceptor.addInnerInterceptor(new PaginationInnerInterceptor(DbType.H2));
return interceptor;
| 133 | 59 | 192 | <no_super_class> |
baomidou_mybatis-plus-samples | mybatis-plus-samples/mybatis-plus-sample-quickstart-springmvc/src/main/java/com/baomidou/mybatisplus/samples/quickstart/springmvc/MpConfig.java | MpConfig | globalConfiguration | class MpConfig {
@Bean
public GlobalConfig globalConfiguration() {<FILL_FUNCTION_BODY>}
} |
GlobalConfig conf = new GlobalConfig();
conf.setDbConfig(new GlobalConfig.DbConfig().setKeyGenerators(Arrays.asList(
// h2 1.x 的写法(默认 2.x 的写法)
new IKeyGenerator() {
@Override
public String executeSql(String incrementerName) {
... | 34 | 153 | 187 | <no_super_class> |
baomidou_mybatis-plus-samples | mybatis-plus-samples/mybatis-plus-sample-reduce-springmvc/src/main/java/com/baomidou/mybatisplus/samples/reduce/springmvc/configurations/DbConfigurations.java | DbConfigurations | globalConfiguration | class DbConfigurations {
@Bean
public MybatisPlusInterceptor mybatisPlusInterceptor() {
MybatisPlusInterceptor mybatisPlusInterceptor = new MybatisPlusInterceptor();
mybatisPlusInterceptor.addInnerInterceptor(new PaginationInnerInterceptor());
return mybatisPlusInterceptor;
}
@... |
GlobalConfig conf = new GlobalConfig();
conf.setDbConfig(new GlobalConfig.DbConfig().setKeyGenerators(Arrays.asList(
// h2 1.x 的写法(默认 2.x 的写法)
new IKeyGenerator() {
@Override
public String executeSql(String incrementerName) {
... | 125 | 153 | 278 | <no_super_class> |
baomidou_mybatis-plus-samples | mybatis-plus-samples/mybatis-plus-sample-reduce-springmvc/src/main/java/org/mybatis/spring/annotation/AutoMapperScannerRegistrar.java | AutoMapperScannerRegistrar | registerBeanDefinitions | class AutoMapperScannerRegistrar implements ImportBeanDefinitionRegistrar, ResourceLoaderAware {
private ResourceLoader resourceLoader;
/**
* {@inheritDoc}
*/
@Override
public void setResourceLoader(ResourceLoader resourceLoader) {
this.resourceLoader = resourceLoader;
}
/**... |
ClassPathAutoMapperScanner scanner = new ClassPathAutoMapperScanner(registry);
// this check is needed in Spring 3.1
Optional.ofNullable(resourceLoader).ifPresent(scanner::setResourceLoader);
Class<? extends Annotation> annotationClass = annoAttrs.getClass("annotationClass");
... | 453 | 912 | 1,365 | <no_super_class> |
baomidou_mybatis-plus-samples | mybatis-plus-samples/mybatis-plus-sample-sql-injector/src/main/java/com/baomidou/samples/injector/base/MySqlInjector.java | MySqlInjector | getMethodList | class MySqlInjector extends DefaultSqlInjector {
@Override
public List<AbstractMethod> getMethodList(Class<?> mapperClass, TableInfo tableInfo) {<FILL_FUNCTION_BODY>}
} |
List<AbstractMethod> methodList = super.getMethodList(mapperClass, tableInfo);
//增加自定义方法
methodList.add(new DeleteAll("deleteAll"));
methodList.add(new FindOne("findOne"));
/**
* 以下 3 个为内置选装件
* 头 2 个支持字段筛选函数
*/
// 例: 不要指定了 update 填充的字段
... | 59 | 184 | 243 | <no_super_class> |
baomidou_mybatis-plus-samples | mybatis-plus-samples/mybatis-plus-sample-sql-injector/src/main/java/com/baomidou/samples/injector/methods/DeleteAll.java | DeleteAll | injectMappedStatement | class DeleteAll extends AbstractMethod {
public DeleteAll(String methodName) {
super(methodName);
}
@Override
public MappedStatement injectMappedStatement(Class<?> mapperClass, Class<?> modelClass, TableInfo tableInfo) {<FILL_FUNCTION_BODY>}
} |
/* 执行 SQL ,动态 SQL 参考类 SqlMethod */
String sql = "delete from " + tableInfo.getTableName();
/* mapper 接口方法名一致 */
SqlSource sqlSource = languageDriver.createSqlSource(configuration, sql, modelClass);
return this.addDeleteMappedStatement(mapperClass, methodName, sqlSource);
| 81 | 90 | 171 | <no_super_class> |
baomidou_mybatis-plus-samples | mybatis-plus-samples/mybatis-plus-sample-sql-injector/src/main/java/com/baomidou/samples/injector/methods/FindOne.java | FindOne | injectMappedStatement | class FindOne extends AbstractMethod {
public FindOne(String methodName) {
super(methodName);
}
@Override
public MappedStatement injectMappedStatement(Class<?> mapperClass, Class<?> modelClass, TableInfo tableInfo) {<FILL_FUNCTION_BODY>}
} |
/* 执行 SQL ,动态 SQL 参考类 SqlMethod */
String sql = "select * from " + tableInfo.getTableName()
+ " where " + tableInfo.getKeyColumn() + "=#{" + tableInfo.getKeyProperty() + "}";
/* mapper 接口方法名一致 */
SqlSource sqlSource = languageDriver.createSqlSource(configuration, sql, mo... | 81 | 125 | 206 | <no_super_class> |
baomidou_mybatis-plus-samples | mybatis-plus-samples/mybatis-plus-sample-tenant/src/main/java/com/baomidou/mybatisplus/samples/tenant/config/MybatisPlusConfig.java | MybatisPlusConfig | mybatisPlusInterceptor | class MybatisPlusConfig {
/**
* 新多租户插件配置,一缓和二缓遵循mybatis的规则,需要设置 MybatisConfiguration#useDeprecatedExecutor = false 避免缓存万一出现问题
*/
@Bean
public MybatisPlusInterceptor mybatisPlusInterceptor() {<FILL_FUNCTION_BODY>}
// @Bean
// public ConfigurationCustomizer configurationCustomizer() {
// ... |
MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor();
interceptor.addInnerInterceptor(new TenantLineInnerInterceptor(new TenantLineHandler() {
@Override
public Expression getTenantId() {
return new LongValue(1);
}
// 这是 defau... | 137 | 226 | 363 | <no_super_class> |
baomidou_mybatis-plus-samples | mybatis-plus-samples/mybatis-plus-sample-typehandler/src/main/java/com/baomidou/mybatisplus/samples/typehandler/WalletListTypeHandler.java | WalletListTypeHandler | parse | class WalletListTypeHandler extends JacksonTypeHandler {
public WalletListTypeHandler(Class<?> type) {
super(type);
}
@Override
public Object parse(String json) {<FILL_FUNCTION_BODY>}
} |
try {
return getObjectMapper().readValue(json, new TypeReference<List<Wallet>>() {
});
} catch (IOException e) {
throw new RuntimeException(e);
}
| 67 | 53 | 120 | <no_super_class> |
baomidou_mybatis-plus-samples | mybatis-plus-samples/mybatis-plus-sample-typehandler/src/main/java/com/baomidou/mybatisplus/samples/typehandler/config/MpJsonConfig.java | MpJsonConfig | mybatisPlusInterceptor | class MpJsonConfig implements CommandLineRunner {
/**
* 可以set进去自己的
*/
@Override
public void run(String... args) throws Exception {
JacksonTypeHandler.setObjectMapper(new ObjectMapper());
GsonTypeHandler.setGson(new Gson());
}
@Bean
public MybatisPlusInterceptor mybati... |
MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor();
interceptor.addInnerInterceptor(new PaginationInnerInterceptor());
return interceptor;
| 113 | 53 | 166 | <no_super_class> |
baomidou_mybatis-plus-samples | mybatis-plus-samples/mybatis-plus-startup-analysis/src/main/java/com/baomidou/MybatisPlusConfig.java | MybatisPlusConfig | sqlInjector | class MybatisPlusConfig {
@Value("${mybatis.plus.parallel:false}")
private boolean parallel;
// 模拟并行注入性能测试(请注意,低版本的mybatis缓存的为hashmap结构,并不能并行注入,mp3.5.6开始通过mybatis源码修改为了ConcurrentHashMap)
@Bean
public ISqlInjector sqlInjector() {<FILL_FUNCTION_BODY>}
} |
if (parallel) {
System.out.println("并行注入.");
} else {
System.out.println("串行注入.");
}
return new DefaultSqlInjector() {
@Override
public void inspectInject(MapperBuilderAssistant builderAssistant, Class<?> mapperClass) {
Cla... | 125 | 382 | 507 | <no_super_class> |
baomidou_mybatis-plus-samples | mybatis-plus-samples/mybatis-plus-startup-analysis/src/main/java/com/baomidou/StartupAnalysisApplication.java | StartupAnalysisApplication | run | class StartupAnalysisApplication implements CommandLineRunner {
@Autowired
private SqlSessionFactory sqlSessionFactory;
public static void main(String[] args) {
SpringApplication.run(StartupAnalysisApplication.class, args);
}
@Override
public void run(String... args) throws Exception ... |
Configuration configuration = sqlSessionFactory.getConfiguration();
System.out.println("注册Mapper数量:" + configuration.getMapperRegistry().getMappers().size());
System.out.println("注册MappedStatements数量:" + configuration.getMappedStatements().size());
| 93 | 67 | 160 | <no_super_class> |
normanmaurer_netty-in-action | netty-in-action/chapter1/src/main/java/nia/chapter1/BlockingIoExample.java | BlockingIoExample | serve | class BlockingIoExample {
/**
* Listing 1.1 Blocking I/O example
* */
public void serve(int portNumber) throws IOException {<FILL_FUNCTION_BODY>}
private String processRequest(String request){
return "Processed";
}
} |
ServerSocket serverSocket = new ServerSocket(portNumber);
Socket clientSocket = serverSocket.accept();
BufferedReader in = new BufferedReader(
new InputStreamReader(clientSocket.getInputStream()));
PrintWriter out =
new PrintWriter(clientSocket.getOutputS... | 79 | 135 | 214 | <no_super_class> |
normanmaurer_netty-in-action | netty-in-action/chapter1/src/main/java/nia/chapter1/ConnectExample.java | ConnectExample | connect | class ConnectExample {
private static final Channel CHANNEL_FROM_SOMEWHERE = new NioSocketChannel();
/**
* Listing 1.3 Asynchronous connect
*
* Listing 1.4 Callback in action
* */
public static void connect() {<FILL_FUNCTION_BODY>}
} |
Channel channel = CHANNEL_FROM_SOMEWHERE; //reference form somewhere
// Does not block
ChannelFuture future = channel.connect(
new InetSocketAddress("192.168.0.1", 25));
future.addListener(new ChannelFutureListener() {
@Override
public void operat... | 86 | 187 | 273 | <no_super_class> |
normanmaurer_netty-in-action | netty-in-action/chapter10/src/main/java/nia/chapter10/SafeByteToMessageDecoder.java | SafeByteToMessageDecoder | decode | class SafeByteToMessageDecoder extends ByteToMessageDecoder {
private static final int MAX_FRAME_SIZE = 1024;
@Override
public void decode(ChannelHandlerContext ctx, ByteBuf in,
List<Object> out) throws Exception {<FILL_FUNCTION_BODY>}
} |
int readable = in.readableBytes();
if (readable > MAX_FRAME_SIZE) {
in.skipBytes(readable);
throw new TooLongFrameException("Frame too big!");
}
// do something
// ...
| 78 | 66 | 144 | <no_super_class> |
normanmaurer_netty-in-action | netty-in-action/chapter10/src/main/java/nia/chapter10/WebSocketConvertHandler.java | WebSocketConvertHandler | decode | class WebSocketConvertHandler extends
MessageToMessageCodec<WebSocketFrame,
WebSocketConvertHandler.MyWebSocketFrame> {
@Override
protected void encode(ChannelHandlerContext ctx,
WebSocketConvertHandler.MyWebSocketFrame msg,
List<Object> out) throws Exception {
ByteBuf pay... |
ByteBuf payload = msg.content().duplicate().retain();
if (msg instanceof BinaryWebSocketFrame) {
out.add(new MyWebSocketFrame(
MyWebSocketFrame.FrameType.BINARY, payload));
} else
if (msg instanceof CloseWebSocketFrame) {
out.add(new MyWebSock... | 480 | 310 | 790 | <no_super_class> |
normanmaurer_netty-in-action | netty-in-action/chapter11/src/main/java/nia/chapter11/ChunkedWriteHandlerInitializer.java | ChunkedWriteHandlerInitializer | initChannel | class ChunkedWriteHandlerInitializer
extends ChannelInitializer<Channel> {
private final File file;
private final SslContext sslCtx;
public ChunkedWriteHandlerInitializer(File file, SslContext sslCtx) {
this.file = file;
this.sslCtx = sslCtx;
}
@Override
protected void initC... |
ChannelPipeline pipeline = ch.pipeline();
pipeline.addLast(new SslHandler(sslCtx.newEngine(ch.alloc())));
pipeline.addLast(new ChunkedWriteHandler());
pipeline.addLast(new WriteStreamHandler());
| 195 | 65 | 260 | <no_super_class> |
normanmaurer_netty-in-action | netty-in-action/chapter11/src/main/java/nia/chapter11/CmdHandlerInitializer.java | CmdHandlerInitializer | initChannel | class CmdHandlerInitializer extends ChannelInitializer<Channel> {
private static final byte SPACE = (byte)' ';
@Override
protected void initChannel(Channel ch) throws Exception {<FILL_FUNCTION_BODY>}
public static final class Cmd {
private final ByteBuf name;
private final ByteBuf args;... |
ChannelPipeline pipeline = ch.pipeline();
pipeline.addLast(new CmdDecoder(64 * 1024));
pipeline.addLast(new CmdHandler());
| 385 | 49 | 434 | <no_super_class> |
normanmaurer_netty-in-action | netty-in-action/chapter11/src/main/java/nia/chapter11/FileRegionWriteHandler.java | FileRegionWriteHandler | channelActive | class FileRegionWriteHandler extends ChannelInboundHandlerAdapter {
private static final Channel CHANNEL_FROM_SOMEWHERE = new NioSocketChannel();
private static final File FILE_FROM_SOMEWHERE = new File("");
@Override
public void channelActive(final ChannelHandlerContext ctx) throws Exception {<FILL_FU... |
File file = FILE_FROM_SOMEWHERE; //get reference from somewhere
Channel channel = CHANNEL_FROM_SOMEWHERE; //get reference from somewhere
//...
FileInputStream in = new FileInputStream(file);
FileRegion region = new DefaultFileRegion(
in.getChannel(), 0, file.leng... | 89 | 160 | 249 | <no_super_class> |
normanmaurer_netty-in-action | netty-in-action/chapter11/src/main/java/nia/chapter11/HttpAggregatorInitializer.java | HttpAggregatorInitializer | initChannel | class HttpAggregatorInitializer extends ChannelInitializer<Channel> {
private final boolean isClient;
public HttpAggregatorInitializer(boolean isClient) {
this.isClient = isClient;
}
@Override
protected void initChannel(Channel ch) throws Exception {<FILL_FUNCTION_BODY>}
} |
ChannelPipeline pipeline = ch.pipeline();
if (isClient) {
pipeline.addLast("codec", new HttpClientCodec());
} else {
pipeline.addLast("codec", new HttpServerCodec());
}
pipeline.addLast("aggregator",
new HttpObjectAggregator(512 * 1024));
... | 83 | 90 | 173 | <no_super_class> |
normanmaurer_netty-in-action | netty-in-action/chapter11/src/main/java/nia/chapter11/HttpCompressionInitializer.java | HttpCompressionInitializer | initChannel | class HttpCompressionInitializer extends ChannelInitializer<Channel> {
private final boolean isClient;
public HttpCompressionInitializer(boolean isClient) {
this.isClient = isClient;
}
@Override
protected void initChannel(Channel ch) throws Exception {<FILL_FUNCTION_BODY>}
} |
ChannelPipeline pipeline = ch.pipeline();
if (isClient) {
pipeline.addLast("codec", new HttpClientCodec());
pipeline.addLast("decompressor",
new HttpContentDecompressor());
} else {
pipeline.addLast("codec", new HttpServerCodec());
pip... | 83 | 103 | 186 | <no_super_class> |
normanmaurer_netty-in-action | netty-in-action/chapter11/src/main/java/nia/chapter11/HttpPipelineInitializer.java | HttpPipelineInitializer | initChannel | class HttpPipelineInitializer extends ChannelInitializer<Channel> {
private final boolean client;
public HttpPipelineInitializer(boolean client) {
this.client = client;
}
@Override
protected void initChannel(Channel ch) throws Exception {<FILL_FUNCTION_BODY>}
} |
ChannelPipeline pipeline = ch.pipeline();
if (client) {
pipeline.addLast("decoder", new HttpResponseDecoder());
pipeline.addLast("encoder", new HttpRequestEncoder());
} else {
pipeline.addLast("decoder", new HttpRequestDecoder());
pipeline.addLast... | 79 | 94 | 173 | <no_super_class> |
normanmaurer_netty-in-action | netty-in-action/chapter11/src/main/java/nia/chapter11/HttpsCodecInitializer.java | HttpsCodecInitializer | initChannel | class HttpsCodecInitializer extends ChannelInitializer<Channel> {
private final SslContext context;
private final boolean isClient;
public HttpsCodecInitializer(SslContext context, boolean isClient) {
this.context = context;
this.isClient = isClient;
}
@Override
protected void ... |
ChannelPipeline pipeline = ch.pipeline();
SSLEngine engine = context.newEngine(ch.alloc());
pipeline.addFirst("ssl", new SslHandler(engine));
if (isClient) {
pipeline.addLast("codec", new HttpClientCodec());
} else {
pipeline.addLast("codec", new HttpSer... | 109 | 95 | 204 | <no_super_class> |
normanmaurer_netty-in-action | netty-in-action/chapter11/src/main/java/nia/chapter11/IdleStateHandlerInitializer.java | IdleStateHandlerInitializer | initChannel | class IdleStateHandlerInitializer extends ChannelInitializer<Channel>
{
@Override
protected void initChannel(Channel ch) throws Exception {<FILL_FUNCTION_BODY>}
public static final class HeartbeatHandler
extends ChannelInboundHandlerAdapter {
private static final ByteBuf HEARTBEAT_SEQUE... |
ChannelPipeline pipeline = ch.pipeline();
pipeline.addLast(
new IdleStateHandler(0, 0, 60, TimeUnit.SECONDS));
pipeline.addLast(new HeartbeatHandler());
| 238 | 58 | 296 | <no_super_class> |
normanmaurer_netty-in-action | netty-in-action/chapter11/src/main/java/nia/chapter11/LengthBasedInitializer.java | LengthBasedInitializer | initChannel | class LengthBasedInitializer extends ChannelInitializer<Channel> {
@Override
protected void initChannel(Channel ch) throws Exception {<FILL_FUNCTION_BODY>}
public static final class FrameHandler
extends SimpleChannelInboundHandler<ByteBuf> {
@Override
public void channelRead0(Channe... |
ChannelPipeline pipeline = ch.pipeline();
pipeline.addLast(
new LengthFieldBasedFrameDecoder(64 * 1024, 0, 8));
pipeline.addLast(new FrameHandler());
| 108 | 59 | 167 | <no_super_class> |
normanmaurer_netty-in-action | netty-in-action/chapter11/src/main/java/nia/chapter11/LineBasedHandlerInitializer.java | LineBasedHandlerInitializer | initChannel | class LineBasedHandlerInitializer extends ChannelInitializer<Channel>
{
@Override
protected void initChannel(Channel ch) throws Exception {<FILL_FUNCTION_BODY>}
public static final class FrameHandler
extends SimpleChannelInboundHandler<ByteBuf> {
@Override
public void channelRea... |
ChannelPipeline pipeline = ch.pipeline();
pipeline.addLast(new LineBasedFrameDecoder(64 * 1024));
pipeline.addLast(new FrameHandler());
| 114 | 49 | 163 | <no_super_class> |
normanmaurer_netty-in-action | netty-in-action/chapter11/src/main/java/nia/chapter11/MarshallingInitializer.java | MarshallingInitializer | initChannel | class MarshallingInitializer extends ChannelInitializer<Channel> {
private final MarshallerProvider marshallerProvider;
private final UnmarshallerProvider unmarshallerProvider;
public MarshallingInitializer(
UnmarshallerProvider unmarshallerProvider,
MarshallerProvider marshallerPro... |
ChannelPipeline pipeline = channel.pipeline();
pipeline.addLast(new MarshallingDecoder(unmarshallerProvider));
pipeline.addLast(new MarshallingEncoder(marshallerProvider));
pipeline.addLast(new ObjectHandler());
| 203 | 63 | 266 | <no_super_class> |
normanmaurer_netty-in-action | netty-in-action/chapter11/src/main/java/nia/chapter11/ProtoBufInitializer.java | ProtoBufInitializer | initChannel | class ProtoBufInitializer extends ChannelInitializer<Channel> {
private final MessageLite lite;
public ProtoBufInitializer(MessageLite lite) {
this.lite = lite;
}
@Override
protected void initChannel(Channel ch) throws Exception {<FILL_FUNCTION_BODY>}
public static final class ObjectH... |
ChannelPipeline pipeline = ch.pipeline();
pipeline.addLast(new ProtobufVarint32FrameDecoder());
pipeline.addLast(new ProtobufEncoder());
pipeline.addLast(new ProtobufDecoder(lite));
pipeline.addLast(new ObjectHandler());
| 147 | 76 | 223 | <no_super_class> |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.